a9e42259c8bf3c5cfb694ac02129fc83e983df7d
[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 Widget widget = null;
17         private string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
18         private delegate bool dummyCallback(IntPtr application);
19
20         private bool OnDummyCallback(IntPtr data)
21         {
22             return false;
23         }
24
25         internal class MyComponentApplication : ComponentApplication
26         {
27             public MyComponentApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
28             { }
29
30             public void OnDispose(DisposeTypes type)
31             {
32                 base.Dispose(type);
33             }
34         }
35
36         [SetUp]
37         public void Init()
38         {
39             tlog.Info(tag, "Init() is called!");
40
41             widget = new Widget();
42             tlog.Debug(tag, "widget.Id : " + widget.Id);
43         }
44
45         [TearDown]
46         public void Destroy()
47         {
48             widget.Dispose();
49             widget = null;
50
51             tlog.Info(tag, "Destroy() is called!");
52         }
53
54         [Test]
55         [Category("P1")]
56         [Description("ComponentApplication constructor.")]
57         [Property("SPEC", "Tizen.NUI.ComponentApplication.ComponentApplication C")]
58         [Property("SPEC_URL", "-")]
59         [Property("CRITERIA", "CONSTR")]
60         [Property("AUTHOR", "guowei.wang@samsung.com")]
61         public void ComponentApplicationConstructor()
62         {
63             tlog.Debug(tag, $"ComponentApplicationConstructor START");
64
65             var testingTarget = new ComponentApplication(widget.SwigCPtr.Handle, false);
66             Assert.IsNotNull(testingTarget, "should be not null");
67             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
68
69             testingTarget.Dispose();
70             tlog.Debug(tag, $"ComponentApplicationConstructor END (OK)");
71         }
72
73         [Test]
74         [Category("P1")]
75         [Description("ComponentApplication constructor. With ComponentApplication.")]
76         [Property("SPEC", "Tizen.NUI.ComponentApplication.ComponentApplication C")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "CONSTR")]
79         [Property("AUTHOR", "guowei.wang@samsung.com")]
80         public void ComponentApplicationConstructorWithComponentApplication()
81         {
82             tlog.Debug(tag, $"ComponentApplicationConstructorWithComponentApplication START");
83
84             ComponentApplication componentApplication = new ComponentApplication(widget.SwigCPtr.Handle, false);
85             Assert.IsNotNull(componentApplication, "should be not null");
86             Assert.IsInstanceOf<ComponentApplication>(componentApplication, "should be an instance of testing target class!");
87
88             var testingTarget = new ComponentApplication(componentApplication);
89             Assert.IsNotNull(testingTarget, "should be not null");
90             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
91
92             testingTarget.Dispose();
93             tlog.Debug(tag, $"ComponentApplicationConstructorWithComponentApplication END (OK)");
94         }
95
96         [Test]
97         [Category("P1")]
98         [Description("ComponentApplication CreateNativeSignal.")]
99         [Property("SPEC", "Tizen.NUI.ComponentApplication.CreateNativeSignal M")]
100         [Property("SPEC_URL", "-")]
101         [Property("CRITERIA", "MR")]
102         [Property("AUTHOR", "guowei.wang@samsung.com")]
103         public void ComponentApplicationCreateNativeSignal()
104         {
105             tlog.Debug(tag, $"ComponentApplicationCreateNativeSignal START");
106
107             var testingTarget = new ComponentApplication(widget.SwigCPtr.Handle, false);
108             Assert.IsNotNull(testingTarget, "should be not null");
109             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
110
111             try
112             {
113                 var result = testingTarget.CreateNativeSignal();
114                 Assert.IsNotNull(result, "should be not null");
115                 Assert.IsInstanceOf<ApplicationSignal>(result, "should be an instance of ApplicationSignal class!");
116             }
117             catch (Exception e)
118             {
119                 tlog.Debug(tag, e.Message.ToString());
120                 Assert.Fail("Caught Exception: Failed!");
121             }
122
123             testingTarget.Dispose();
124             tlog.Debug(tag, $"ComponentApplicationCreateNativeSignal END (OK)");
125         }
126
127         [Test]
128         [Category("P1")]
129         [Description("ComponentApplication Dispose.")]
130         [Property("SPEC", "Tizen.NUI.ComponentApplication.Dispose M")]
131         [Property("SPEC_URL", "-")]
132         [Property("CRITERIA", "MR")]
133         [Property("AUTHOR", "guowei.wang@samsung.com")]
134         public void ComponentApplicationDispose()
135         {
136             tlog.Debug(tag, $"ComponentApplicationDispose START");
137
138             var testingTarget = new MyComponentApplication(widget.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             tlog.Debug(tag, $"ComponentApplicationDispose END (OK)");
154         }
155
156         [Test]
157         [Category("P1")]
158         [Description("ComponentApplication Assign.")]
159         [Property("SPEC", "Tizen.NUI.ComponentApplication.Assign M")]
160         [Property("SPEC_URL", "-")]
161         [Property("CRITERIA", "MR")]
162         [Property("AUTHOR", "guowei.wang@samsung.com")]
163         public void ComponentApplicationAssign()
164         {
165             tlog.Debug(tag, $"ComponentApplicationAssign START");
166
167             var testingTarget = new ComponentApplication(widget.SwigCPtr.Handle, false);
168             Assert.IsNotNull(testingTarget, "should be not null");
169             Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
170
171             try
172             {
173                 testingTarget.Assign(testingTarget);
174             }
175             catch (Exception e)
176             {
177                 tlog.Debug(tag, e.Message.ToString());
178                 Assert.Fail("Caught Exception: Failed!");
179             }
180
181             testingTarget.Dispose();
182             tlog.Debug(tag, $"ComponentApplicationAssign END (OK)");
183         }
184
185         //[Test]
186         //[Category("P1")]
187         //[Description("ComponentApplication CreateNative.")]
188         //[Property("SPEC", "Tizen.NUI.ComponentApplication.CreateNative A")]
189         //[Property("SPEC_URL", "-")]
190         //[Property("CRITERIA", "PRW")]
191         //[Property("AUTHOR", "guowei.wang@samsung.com")]
192         //public void ComponentApplicationCreateNative()
193         //{
194         //    tlog.Debug(tag, $"ComponentApplicationCreateNative START");
195
196         //    var testingTarget = new ComponentApplication(widget.SwigCPtr.Handle, true);
197         //    Assert.IsNotNull(testingTarget, "should be not null");
198         //    Assert.IsInstanceOf<ComponentApplication>(testingTarget, "should be an instance of testing target class!");
199
200         //    testingTarget.CreateNative += OnApplicationCreateNative;
201         //    testingTarget.CreateNative -= OnApplicationCreateNative;
202
203         //    testingTarget.Dispose();
204         //    tlog.Debug(tag, $"ComponentApplicationCreateNative END (OK)");
205         //}
206
207         //private IntPtr OnApplicationCreateNative()
208         //{
209         //    return IntPtr.Zero;
210         //}
211     }
212 }