Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Application / TSNUICoreBackend.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 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("internal/Application/NUICoreBackend")]
12     public class InternalNUICoreBackendTest
13     {
14         private const string tag = "NUITEST";
15         private event EventHandler Created;
16
17         private delegate bool dummyCallback(IntPtr nuicorebackend);
18         private bool OnDummyCallback(IntPtr data)
19         {
20             return false;
21         }
22
23         protected virtual void OnCreate()
24         {
25             Created?.Invoke(this, EventArgs.Empty);
26         }
27
28         [SetUp]
29         public void Init()
30         {
31             tlog.Info(tag, "Init() is called!");
32         }
33
34         [TearDown]
35         public void Destroy()
36         {
37             tlog.Info(tag, "Destroy() is called!");
38         }
39
40         [Test]
41         [Category("P1")]
42         [Description("NUICoreBackend constructor.")]
43         [Property("SPEC", "Tizen.NUI.NUICoreBackend.NUICoreBackend C")]
44         [Property("SPEC_URL", "-")]
45         [Property("CRITERIA", "CONSTR")]
46         [Property("AUTHOR", "guowei.wang@samsung.com")]
47         public void NUICoreBackendConstructor()
48         {
49             tlog.Debug(tag, $"NUICoreBackendConstructor START");
50
51             var testingTarget = new NUICoreBackend();
52             Assert.IsNotNull(testingTarget, "should be not null");
53             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
54
55             testingTarget.Dispose();
56             tlog.Debug(tag, $"NUICoreBackendConstructor END (OK)");
57         }
58
59         [Test]
60         [Category("P1")]
61         [Description("NUICoreBackend constructor. With stylesheet.")]
62         [Property("SPEC", "Tizen.NUI.NUICoreBackend.NUICoreBackend C")]
63         [Property("SPEC_URL", "-")]
64         [Property("CRITERIA", "CONSTR")]
65         [Property("AUTHOR", "guowei.wang@samsung.com")]
66         public void NUICoreBackendConstructorWithStylesheet()
67         {
68             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheet START");
69
70             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
71             var testingTarget = new NUICoreBackend(dummy);
72             Assert.IsNotNull(testingTarget, "should be not null");
73             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
74
75             testingTarget.Dispose();
76             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheet END (OK)");
77         }
78
79         [Test]
80         [Category("P1")]
81         [Description("NUICoreBackend constructor. With stylesheet and windowMode.")]
82         [Property("SPEC", "Tizen.NUI.NUICoreBackend.NUICoreBackend C")]
83         [Property("SPEC_URL", "-")]
84         [Property("CRITERIA", "CONSTR")]
85         [Property("AUTHOR", "guowei.wang@samsung.com")]
86         public void NUICoreBackendConstructorWithStylesheetAndWindowmode()
87         {
88             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheetAndWindowmode START");
89
90             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
91             var testingTarget = new NUICoreBackend(dummy, NUIApplication.WindowMode.Opaque);
92             Assert.IsNotNull(testingTarget, "should be not null");
93             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
94
95             testingTarget.Dispose();
96             tlog.Debug(tag, $"NUICoreBackendConstructorWithStylesheetAndWindowmode END (OK)");
97         }
98
99         [Test]
100         [Category("P1")]
101         [Description("NUICoreBackend constructor. With stylesheet, mode, size, position")]
102         [Property("SPEC", "Tizen.NUI.NUICoreBackend.NUICoreBackend C")]
103         [Property("SPEC_URL", "-")]
104         [Property("CRITERIA", "CONSTR")]
105         [Property("AUTHOR", "guowei.wang@samsung.com")]
106         public void NUICoreBackendConstructorWithFourParameters()
107         {
108             tlog.Debug(tag, $"NUICoreBackendConstructorWithFourParameters START");
109
110             var dummy = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/style/Test_Style_Manager.json";
111             var testingTarget = new NUICoreBackend(dummy, NUIApplication.WindowMode.Opaque, new Size(400, 400), new Position(200, 300));
112             Assert.IsNotNull(testingTarget, "should be not null");
113             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
114
115             testingTarget.Dispose();
116             tlog.Debug(tag, $"NUICoreBackendConstructorWithFourParameters END (OK)");
117         }
118
119         [Test]
120         [Category("P1")]
121         [Description("NUICoreBackend AddEventHandler")]
122         [Property("SPEC", "Tizen.NUI.NUICoreBackend.AddEventHandler M")]
123         [Property("SPEC_URL", "-")]
124         [Property("CRITERIA", "MR")]
125         [Property("AUTHOR", "guowei.wang@samsung.com")]
126         public void NUICoreBackendAddEventHandler()
127         {
128             tlog.Debug(tag, $"NUICoreBackendAddEventHandler START");
129
130             var testingTarget = new NUICoreBackend();
131             Assert.IsNotNull(testingTarget, "should be not null");
132             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
133
134             testingTarget.AddEventHandler(Tizen.Applications.CoreBackend.EventType.Created, OnCreate);
135
136             testingTarget.Dispose();
137             tlog.Debug(tag, $"NUICoreBackendAddEventHandler END (OK)");
138         }
139
140         [Test]
141         [Category("P1")]
142         [Description("NUICoreBackend Dispose.")]
143         [Property("SPEC", "Tizen.NUI.NUICoreBackend.Dispose M")]
144         [Property("SPEC_URL", "-")]
145         [Property("CRITERIA", "MR")]
146         [Property("AUTHOR", "guowei.wang@samsung.com")]
147         public void NUICoreBackendDispose()
148         {
149             tlog.Debug(tag, $"NUICoreBackendDispose START");
150
151             var testingTarget = new NUICoreBackend();
152             Assert.IsNotNull(testingTarget, "should be not null");
153             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
154
155             try
156             {
157                 testingTarget.Dispose();
158             }
159             catch (Exception e)
160             {
161                 tlog.Error(tag, "Caught Exception" + e.ToString());
162                 Assert.Fail("Caught Exception" + e.ToString());
163             }
164
165             tlog.Debug(tag, $"NUICoreBackendDispose END (OK)");
166         }
167
168         [Test]
169         [Category("P1")]
170         [Description("NUICoreBackend Exit.")]
171         [Property("SPEC", "Tizen.NUI.NUICoreBackend.Exit M")]
172         [Property("SPEC_URL", "-")]
173         [Property("CRITERIA", "MR")]
174         [Property("AUTHOR", "guowei.wang@samsung.com")]
175         public void NUICoreBackendExit()
176         {
177             tlog.Debug(tag, $"NUICoreBackendExit START");
178
179             var testingTarget = new NUICoreBackend();
180             Assert.IsNotNull(testingTarget, "should be not null");
181             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
182
183             try
184             {
185                 testingTarget.Exit();
186             }
187             catch (Exception e)
188             {
189                 tlog.Error(tag, "Caught Exception" + e.ToString());
190                 Assert.Fail("Caught Exception" + e.ToString());
191             }
192
193             testingTarget.Dispose();
194             tlog.Debug(tag, $"NUICoreBackendExit END (OK)");
195         }
196
197         [Test]
198         [Category("P1")]
199         [Description("NUICoreBackend ApplicationHandle.")]
200         [Property("SPEC", "Tizen.NUI.NUICoreBackend.ApplicationHandle A")]
201         [Property("SPEC_URL", "-")]
202         [Property("CRITERIA", "PRO")]
203         [Property("AUTHOR", "guowei.wang@samsung.com")]
204         public void NUICoreBackendApplicationHandle()
205         {
206             tlog.Debug(tag, $"NUICoreBackendApplicationHandle START");
207
208             var testingTarget = new NUICoreBackend();
209             Assert.IsNotNull(testingTarget, "should be not null");
210             Assert.IsInstanceOf<NUICoreBackend>(testingTarget, "should be an instance of testing target class!");
211
212             try
213             {
214                 var result = testingTarget.ApplicationHandle;
215             }
216             catch (Exception e)
217             {
218                 tlog.Debug(tag, e.Message.ToString());
219                 Assert.Fail("Caught Exception: Failed!");
220             }
221
222             testingTarget.Dispose();
223             tlog.Debug(tag, $"NUICoreBackendApplicationHandle END (OK)");
224         }
225     }
226 }