Merge remote-tracking branch 'origin/master' into tizen
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Application / TSNUIApplication.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 using System.Globalization;
7 using System.Resources;
8 using Tizen.Applications;
9
10 namespace Tizen.NUI.Devel.Tests
11 {
12     using tlog = Tizen.Log;
13
14     [TestFixture]
15     [Description("public/Application/NUIApplication")]
16     class PublicNUIApplicationTest
17     {
18         private const string tag = "NUITEST";
19         private delegate bool dummyCallback(IntPtr NUIApplication);
20         private bool OnDummyCallback(IntPtr data)
21         {
22             return false;
23         }
24
25         [SetUp]
26         public void Init()
27         {
28             tlog.Info(tag, "Init() is called!");
29         }
30
31         [TearDown]
32         public void Destroy()
33         {
34             tlog.Info(tag, "Destroy() is called!");
35         }
36
37         [Test]
38         [Category("P1")]
39         [Description("NUIApplication constructor.")]
40         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
41         [Property("SPEC_URL", "-")]
42         [Property("CRITERIA", "CONSTR")]
43         [Property("AUTHOR", "guowei.wang@samsung.com")]
44         public void NUIApplicationConstructor()
45         {
46             tlog.Debug(tag, $"NUIApplicationConstructor START");
47
48             var testingTarget = new NUIApplication();
49             Assert.IsNotNull(testingTarget, "Should be not null.");
50             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
51
52             testingTarget.Dispose();
53             tlog.Debug(tag, $"NUIApplicationConstructor END (OK)");
54         }
55
56         [Test]
57         [Category("P1")]
58         [Description("NUIApplication constructor. With window size and position")]
59         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
60         [Property("SPEC_URL", "-")]
61         [Property("CRITERIA", "CONSTR")]
62         [Property("AUTHOR", "guowei.wang@samsung.com")]
63         public void NUIApplicationConstructorWithWindowSizeAndPosition()
64         {
65             tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition START");
66
67             Size size = new Size(100, 200);
68             Position pos = new Position(200, 300);
69             var testingTarget = new NUIApplication(size, pos);
70             Assert.IsNotNull(testingTarget, "Should be not null.");
71             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
72
73             pos.Dispose();
74             size.Dispose();
75             testingTarget.Dispose();
76             tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition END (OK)");
77         }
78
79         [Test]
80         [Category("P1")]
81         [Description("NUIApplication constructor. With stylesheet.")]
82         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
83         [Property("SPEC_URL", "-")]
84         [Property("CRITERIA", "CONSTR")]
85         [Property("AUTHOR", "guowei.wang@samsung.com")]
86         public void NUIApplicationConstructorWithStyleSheet()
87         {
88             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet START");
89
90             var testingTarget = new NUIApplication("stylesheet");
91             Assert.IsNotNull(testingTarget, "Should be not null.");
92             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
93
94             testingTarget.Dispose();
95             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet END (OK)");
96         }
97
98         [Test]
99         [Category("P1")]
100         [Description("NUIApplication constructor. With stylesheet, window size, position.")]
101         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
102         [Property("SPEC_URL", "-")]
103         [Property("CRITERIA", "CONSTR")]
104         [Property("AUTHOR", "guowei.wang@samsung.com")]
105         public void NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion()
106         {
107             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion START");
108
109             var testingTarget = new NUIApplication("stylesheet", new Size(100, 200), new Position(200, 300));
110             Assert.IsNotNull(testingTarget, "Should be not null.");
111             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
112
113             testingTarget.Dispose();
114             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion END (OK)");
115         }
116
117         [Test]
118         [Category("P1")]
119         [Description("NUIApplication constructor. With stylesheet and WindowMode.")]
120         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
121         [Property("SPEC_URL", "-")]
122         [Property("CRITERIA", "CONSTR")]
123         [Property("AUTHOR", "guowei.wang@samsung.com")]
124         public void NUIApplicationConstructorWithStringAndWindowMode()
125         {
126             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode START");
127
128             var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque);
129             Assert.IsNotNull(testingTarget, "Should be not null.");
130             Assert.IsNotNull(testingTarget, "NUIApplication Should return NUIApplication instance.");
131
132             testingTarget.Dispose();
133             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode END (OK)");
134         }
135
136         [Test]
137         [Category("P1")]
138         [Description("NUIApplication constructor. With stylesheet, WindowMode, window size and position")]
139         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
140         [Property("SPEC_URL", "-")]
141         [Property("CRITERIA", "CONSTR")]
142         [Property("AUTHOR", "guowei.wang@samsung.com")]
143         public void NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition()
144         {
145             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition START");
146
147             var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque, new Size(100, 200), new Position(200, 300));
148             Assert.IsNotNull(testingTarget, "Should be not null.");
149             Assert.IsNotNull(testingTarget, "NUIApplication Should return NUIApplication instance.");
150
151             testingTarget.Dispose();
152             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition END (OK)");
153         }
154
155         [Test]
156         [Category("P1")]
157         [Description("NUIApplication RegisterAssembly.")]
158         [Property("SPEC", "Tizen.NUI.NUIApplication.RegisterAssembly M")]
159         [Property("SPEC_URL", "-")]
160         [Property("CRITERIA", "MR")]
161         [Property("AUTHOR", "guowei.wang@samsung.com")]
162         public void NUIApplicationRegisterAssembly()
163         {
164             tlog.Debug(tag, $"NUIApplicationRegisterAssembly START");
165
166             try
167             {
168                 NUIApplication.RegisterAssembly(typeof(NUIApplication).Assembly);
169             }
170             catch (Exception e)
171             {
172                 tlog.Error(tag, "Caught Exception" + e.ToString());
173                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
174                 Assert.Fail("Caught Exception" + e.ToString());
175             }
176
177             tlog.Debug(tag, $"NUIApplicationRegisterAssembly END (OK)");
178         }
179
180         [Test]
181         [Category("P1")]
182         [Description("NUIApplication MultilingualResourceManager.")]
183         [Property("SPEC", "Tizen.NUI.NUIApplication.MultilingualResourceManager A")]
184         [Property("SPEC_URL", "-")]
185         [Property("CRITERIA", "PRW")]
186         [Property("AUTHOR", "guowei.wang@samsung.com")]
187         public void NUIApplicationMultilingualResourceManager()
188         {
189             tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager START");
190
191             NUIApplication.MultilingualResourceManager = Resource.ResourceManager;
192             Assert.IsNotNull(NUIApplication.MultilingualResourceManager, "Should be not null!");
193
194             string str = null;
195             str = NUIApplication.MultilingualResourceManager?.GetString("Test");
196             Assert.AreEqual("Test", str, "Picture should be Beeld in Dutch");
197
198             tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager END (OK)");
199         }
200
201         [Test]
202         [Category("P1")]
203         [Description("NUIApplication AppId")]
204         [Property("SPEC", "Tizen.NUI.NUIApplication.AppId A")]
205         [Property("SPEC_URL", "-")]
206         [Property("CRITERIA", "PRO")]
207         [Property("AUTHOR", "guowei.wang@samsung.com")]
208         public void NUIApplicationAppId()
209         {
210             tlog.Debug(tag, $"NUIApplicationAppId START");
211
212             var testingTarget = new NUIApplication();
213             Assert.IsNotNull(testingTarget, "Should be not null.");
214             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
215
216             var result = testingTarget.AppId;
217             Assert.IsNotNull(result, "Should be not null.");
218
219             tlog.Debug(tag, $"NUIApplicationAppId END (OK)");
220         }
221
222         [Test]
223         [Category("P1")]
224         [Description("NUIApplication GetDefaultWindow")]
225         [Property("SPEC", "Tizen.NUI.NUIApplication.GetDefaultWindow M")]
226         [Property("SPEC_URL", "-")]
227         [Property("CRITERIA", "MR")]
228         [Property("AUTHOR", "guowei.wang@samsung.com")]
229         public void NUIApplicationGetDefaultWindow()
230         {
231             tlog.Debug(tag, $"NUIApplicationGetDefaultWindow START");
232
233             var testingTarget = NUIApplication.GetDefaultWindow();
234             Assert.IsNotNull(testingTarget, "Should be not null.");
235             Assert.IsInstanceOf<Window>(testingTarget, "Should be an instance of Window type.");
236
237             testingTarget.Dispose();
238             tlog.Debug(tag, $"NUIApplicationGetDefaultWindow END (OK)");
239         }
240
241         [Test]
242         [Category("P1")]
243         [Description("NUIApplication AddIdle")]
244         [Property("SPEC", "Tizen.NUI.NUIApplication.AddIdle M")]
245         [Property("SPEC_URL", "-")]
246         [Property("CRITERIA", "MR")]
247         [Property("AUTHOR", "guowei.wang@samsung.com")]
248         public void NUIApplicationAddIdle()
249         {
250             tlog.Debug(tag, $"NUIApplicationAddIdle START");
251
252             dummyCallback callback = OnDummyCallback;
253             var result = Application.Instance.AddIdle(callback);
254             Assert.IsTrue(result);
255
256             tlog.Debug(tag, $"NUIApplicationAddIdle END (OK)");
257         }
258
259         [Test]
260         [Category("P1")]
261         [Description("NUIApplication SetRenderRefreshRate")]
262         [Property("SPEC", "Tizen.NUI.NUIApplication.SetRenderRefreshRate M")]
263         [Property("SPEC_URL", "-")]
264         [Property("CRITERIA", "MR")]
265         [Property("AUTHOR", "guowei.wang@samsung.com")]
266         public void NUIApplicationSetRenderRefreshRate()
267         {
268             tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate START");
269
270             try
271             {
272                 NUIApplication.SetRenderRefreshRate(2);
273             }
274             catch (Exception e)
275             {
276                 tlog.Error(tag, "Caught Exception" + e.ToString());
277                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
278                 Assert.Fail("Caught Exception" + e.ToString());
279             }
280
281             tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate END (OK)");
282         }
283
284         [Test]
285         [Category("P1")]
286         [Description("NUIApplication TransitionOptions")]
287         [Property("SPEC", "Tizen.NUI.NUIApplication.TransitionOptions A")]
288         [Property("SPEC_URL", "-")]
289         [Property("CRITERIA", "PRW")]
290         [Property("AUTHOR", "guowei.wang@samsung.com")]
291         public void NUIApplicationTransitionOptions()
292         {
293             tlog.Debug(tag, $"NUIApplicationTransitionOptions START");
294
295             var testingTarget = new NUIApplication();
296             Assert.IsNotNull(testingTarget, "Should be not null.");
297             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
298
299             TransitionOptions transitionOption = new TransitionOptions(Window.Instance);
300             testingTarget.TransitionOptions = transitionOption;
301
302             var result = testingTarget.TransitionOptions;
303             Assert.IsNotNull(result);
304             Assert.IsInstanceOf<TransitionOptions>(result, "Should be an instance of TransitionOptions type.");
305
306             result.Dispose();
307             transitionOption.Dispose();
308             testingTarget.Dispose();
309             tlog.Debug(tag, $"NUIApplicationTransitionOptions END (OK)");
310         }
311     }
312 }