[NUI] Fix build error of Devel.NUI.Tests
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSComponentApplication.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("internal/Application/ComponentApplication")]
13     public class InternalComponentApplicationTest
14     {
15         private const string tag = "NUITEST";
16         private string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
17         private delegate bool dummyCallback(IntPtr application);
18
19         private bool OnDummyCallback(IntPtr data)
20         {
21             return false;
22         }
23
24         internal class MyComponentApplication : ComponentApplication
25         {
26             public MyComponentApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
27             { }
28
29             public void OnDispose(DisposeTypes type)
30             {
31                 base.Dispose(type);
32             }
33         }
34
35         [SetUp]
36         public void Init()
37         {
38             tlog.Info(tag, "Init() is called!");
39         }
40
41         [TearDown]
42         public void Destroy()
43         {
44             tlog.Info(tag, "Destroy() is called!");
45         }
46
47         [Test]
48         [Category("P1")]
49         [Description("ComponentApplication constructor.")]
50         [Property("SPEC", "Tizen.NUI.ComponentApplication.ComponentApplication C")]
51         [Property("SPEC_URL", "-")]
52         [Property("CRITERIA", "CONSTR")]
53         [Property("AUTHOR", "guowei.wang@samsung.com")]
54         public void ComponentApplicationConstructor()
55         {
56             tlog.Debug(tag, $"ComponentApplicationConstructor START");
57
58             ImageView view = new ImageView();
59             var testingTarget = new ComponentApplication(view.SwigCPtr.Handle, false);
60             Assert.IsNotNull(testingTarget, "should be not null");
61             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
62
63             view.Dispose();
64             testingTarget.Dispose();
65             tlog.Debug(tag, $"ComponentApplicationConstructor END (OK)");
66         }
67
68         [Test]
69         [Category("P1")]
70         [Description("ComponentApplication constructor. With ComponentApplication.")]
71         [Property("SPEC", "Tizen.NUI.ComponentApplication.ComponentApplication C")]
72         [Property("SPEC_URL", "-")]
73         [Property("CRITERIA", "CONSTR")]
74         [Property("AUTHOR", "guowei.wang@samsung.com")]
75         public void ComponentApplicationConstructorWithComponentApplication()
76         {
77             tlog.Debug(tag, $"ComponentApplicationConstructorWithComponentApplication START");
78
79             ImageView view = new ImageView();
80             ComponentApplication componentApplication = new ComponentApplication(view.SwigCPtr.Handle, false);
81             Assert.IsNotNull(componentApplication, "should be not null");
82             Assert.IsInstanceOf<ComponentApplication>(componentApplication, "should be an instance of testing target class!");
83
84             var testingTarget = new ComponentApplication(componentApplication);
85             Assert.IsNotNull(testingTarget, "should be not null");
86             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
87
88             view.Dispose();
89             testingTarget.Dispose();
90             tlog.Debug(tag, $"ComponentApplicationConstructorWithComponentApplication END (OK)");
91         }
92
93         [Test]
94         [Category("P1")]
95         [Description("ComponentApplication CreateNativeSignal.")]
96         [Property("SPEC", "Tizen.NUI.ComponentApplication.CreateNativeSignal M")]
97         [Property("SPEC_URL", "-")]
98         [Property("CRITERIA", "MR")]
99         [Property("AUTHOR", "guowei.wang@samsung.com")]
100         public void ComponentApplicationCreateNativeSignal()
101         {
102             tlog.Debug(tag, $"ComponentApplicationCreateNativeSignal START");
103
104             ImageView view = new ImageView();
105             var testingTarget = new ComponentApplication(view.SwigCPtr.Handle, false);
106             Assert.IsNotNull(testingTarget, "should be not null");
107             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
108
109             try
110             {
111                 var result = testingTarget.CreateNativeSignal();
112                 Assert.IsNotNull(result, "should be not null");
113                 Assert.IsInstanceOf<ApplicationSignal>(result, "should be an instance of ApplicationSignal class!");
114             }
115             catch (Exception e)
116             {
117                 tlog.Debug(tag, e.Message.ToString());
118                 Assert.Fail("Caught Exception: Failed!");
119             }
120
121             view.Dispose();
122             testingTarget.Dispose();
123             tlog.Debug(tag, $"ComponentApplicationCreateNativeSignal END (OK)");
124         }
125
126         [Test]
127         [Category("P1")]
128         [Description("ComponentApplication Dispose.")]
129         [Property("SPEC", "Tizen.NUI.ComponentApplication.Dispose M")]
130         [Property("SPEC_URL", "-")]
131         [Property("CRITERIA", "MR")]
132         [Property("AUTHOR", "guowei.wang@samsung.com")]
133         public void ComponentApplicationDispose()
134         {
135             tlog.Debug(tag, $"ComponentApplicationDispose START");
136
137             ImageView view = new ImageView();
138             var testingTarget = new MyComponentApplication(view.SwigCPtr.Handle, false);
139             Assert.IsNotNull(testingTarget, "should be not null");
140             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
141
142             try
143             {
144                 testingTarget.OnDispose(DisposeTypes.Explicit);
145                 testingTarget.OnDispose(DisposeTypes.Explicit);
146             }
147             catch (Exception e)
148             {
149                 tlog.Debug(tag, e.Message.ToString());
150                 Assert.Fail("Caught Exception: Failed!");
151             }
152
153             view.Dispose();
154             tlog.Debug(tag, $"ComponentApplicationDispose END (OK)");
155         }
156
157         [Test]
158         [Category("P1")]
159         [Description("ComponentApplication Assign.")]
160         [Property("SPEC", "Tizen.NUI.ComponentApplication.Assign M")]
161         [Property("SPEC_URL", "-")]
162         [Property("CRITERIA", "MR")]
163         [Property("AUTHOR", "guowei.wang@samsung.com")]
164         public void ComponentApplicationAssign()
165         {
166             tlog.Debug(tag, $"ComponentApplicationAssign START");
167
168             ImageView view = new ImageView();
169             var testingTarget = new ComponentApplication(view.SwigCPtr.Handle, false);
170             Assert.IsNotNull(testingTarget, "should be not null");
171             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
172
173             try
174             {
175                 testingTarget.Assign(testingTarget);
176             }
177             catch (Exception e)
178             {
179                 tlog.Debug(tag, e.Message.ToString());
180                 Assert.Fail("Caught Exception: Failed!");
181             }
182
183             tlog.Debug(tag, $"ComponentApplicationAssign END (OK)");
184         }
185     }
186 }