6c4e59019a5d862756d2f7e038e0368df9dd2a43
[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         internal class MyNUIApplication : NUIApplication
26         {
27             public MyNUIApplication() : base()
28             { }
29
30             public void MyOnTerminate()
31             {
32                 base.OnTerminate();
33             }
34
35             public void MyOnLocaleChanged(LocaleChangedEventArgs e)
36             {
37                 base.OnLocaleChanged(e);
38             }
39         }
40
41         [SetUp]
42         public void Init()
43         {
44             tlog.Info(tag, "Init() is called!");
45         }
46
47         [TearDown]
48         public void Destroy()
49         {
50             tlog.Info(tag, "Destroy() is called!");
51         }
52
53         [Test]
54         [Category("P1")]
55         [Description("NUIApplication constructor.")]
56         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
57         [Property("SPEC_URL", "-")]
58         [Property("CRITERIA", "CONSTR")]
59         [Property("AUTHOR", "guowei.wang@samsung.com")]
60         public void NUIApplicationConstructor()
61         {
62             tlog.Debug(tag, $"NUIApplicationConstructor START");
63
64             var testingTarget = new NUIApplication();
65             Assert.IsNotNull(testingTarget, "Should be not null.");
66             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
67
68             testingTarget.Dispose();
69             tlog.Debug(tag, $"NUIApplicationConstructor END (OK)");
70         }
71
72         [Test]
73         [Category("P1")]
74         [Description("NUIApplication constructor. With window size and position")]
75         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
76         [Property("SPEC_URL", "-")]
77         [Property("CRITERIA", "CONSTR")]
78         [Property("AUTHOR", "guowei.wang@samsung.com")]
79         public void NUIApplicationConstructorWithWindowSizeAndPosition()
80         {
81             tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition START");
82
83             Size size = new Size(100, 200);
84             Position pos = new Position(200, 300);
85             var testingTarget = new NUIApplication(size, pos);
86             Assert.IsNotNull(testingTarget, "Should be not null.");
87             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
88
89             tlog.Debug(tag, "ApplicationHandle : " + testingTarget.ApplicationHandle);
90
91             pos.Dispose();
92             size.Dispose();
93             testingTarget.Dispose();
94             tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition END (OK)");
95         }
96
97         [Test]
98         [Category("P1")]
99         [Description("NUIApplication constructor. With stylesheet.")]
100         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
101         [Property("SPEC_URL", "-")]
102         [Property("CRITERIA", "CONSTR")]
103         [Property("AUTHOR", "guowei.wang@samsung.com")]
104         public void NUIApplicationConstructorWithStyleSheet()
105         {
106             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet START");
107
108             var testingTarget = new NUIApplication("stylesheet");
109             Assert.IsNotNull(testingTarget, "Should be not null.");
110             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
111
112             testingTarget.Dispose();
113             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet END (OK)");
114         }
115
116         [Test]
117         [Category("P1")]
118         [Description("NUIApplication constructor. With stylesheet, window size, position.")]
119         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
120         [Property("SPEC_URL", "-")]
121         [Property("CRITERIA", "CONSTR")]
122         [Property("AUTHOR", "guowei.wang@samsung.com")]
123         public void NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion()
124         {
125             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion START");
126
127             var testingTarget = new NUIApplication("stylesheet", new Size(100, 200), new Position(200, 300));
128             Assert.IsNotNull(testingTarget, "Should be not null.");
129             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
130
131             testingTarget.Dispose();
132             tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion END (OK)");
133         }
134
135         [Test]
136         [Category("P1")]
137         [Description("NUIApplication constructor. With stylesheet and WindowMode.")]
138         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
139         [Property("SPEC_URL", "-")]
140         [Property("CRITERIA", "CONSTR")]
141         [Property("AUTHOR", "guowei.wang@samsung.com")]
142         public void NUIApplicationConstructorWithStringAndWindowMode()
143         {
144             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode START");
145
146             var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque);
147             Assert.IsNotNull(testingTarget, "Should be not null.");
148             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
149
150             testingTarget.Dispose();
151             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode END (OK)");
152         }
153
154         [Test]
155         [Category("P1")]
156         [Description("NUIApplication constructor. With stylesheet, WindowMode, window size and position")]
157         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
158         [Property("SPEC_URL", "-")]
159         [Property("CRITERIA", "CONSTR")]
160         [Property("AUTHOR", "guowei.wang@samsung.com")]
161         public void NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition()
162         {
163             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition START");
164
165             var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque, new Size(100, 200), new Position(200, 300));
166             Assert.IsNotNull(testingTarget, "Should be not null.");
167             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
168
169             testingTarget.Dispose();
170             tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition END (OK)");
171         }
172
173         [Test]
174         [Category("P1")]
175         [Description("NUIApplication constructor. With BackendType.")]
176         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
177         [Property("SPEC_URL", "-")]
178         [Property("CRITERIA", "CONSTR")]
179         [Property("AUTHOR", "guowei.wang@samsung.com")]
180         public void NUIApplicationConstructorWithBackendType()
181         {
182             tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType START");
183
184             var testingTarget = new NUIApplication(Graphics.BackendType.Vulkan);
185             Assert.IsNotNull(testingTarget, "Should be not null.");
186             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
187
188             testingTarget.Dispose();
189             tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType END (OK)");
190         }
191
192         [Test]
193         [Category("P1")]
194         [Description("NUIApplication constructor. With ThemeOptions.")]
195         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
196         [Property("SPEC_URL", "-")]
197         [Property("CRITERIA", "CONSTR")]
198         [Property("AUTHOR", "guowei.wang@samsung.com")]
199         public void NUIApplicationConstructorWithThemeOptions()
200         {
201             tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions START");
202
203             var testingTarget = new NUIApplication(NUIApplication.ThemeOptions.PlatformThemeEnabled);
204             Assert.IsNotNull(testingTarget, "Should be not null.");
205             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
206
207             testingTarget.Dispose();
208             tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions END (OK)");
209         }
210
211         [Test]
212         [Category("P1")]
213         [Description("NUIApplication constructor. With windowSize, windowPosition and options.")]
214         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
215         [Property("SPEC_URL", "-")]
216         [Property("CRITERIA", "CONSTR")]
217         [Property("AUTHOR", "guowei.wang@samsung.com")]
218         public void NUIApplicationConstructorWithSizePositionAndThemeOptions()
219         {
220             tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions START");
221
222             Size2D windowSize = new Size2D(100, 50);
223             Position2D windowPosition = new Position2D(20, 30);
224             var testingTarget = new NUIApplication(windowSize, windowPosition, NUIApplication.ThemeOptions.PlatformThemeEnabled);
225             Assert.IsNotNull(testingTarget, "Should be not null.");
226             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
227
228             windowSize.Dispose();
229             windowPosition.Dispose();
230             testingTarget.Dispose();
231             tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions END (OK)");
232         }
233
234         [Test]
235         [Category("P1")]
236         [Description("NUIApplication constructor. Support IME window.")]
237         [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
238         [Property("SPEC_URL", "-")]
239         [Property("CRITERIA", "CONSTR")]
240         [Property("AUTHOR", "guowei.wang@samsung.com")]
241         public void NUIApplicationConstructorForImeWindow()
242         {
243             tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow START");
244
245             var testingTarget = new NUIApplication("", NUIApplication.WindowMode.Opaque, WindowType.Dialog);
246             Assert.IsNotNull(testingTarget, "Should be not null.");
247             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
248
249             testingTarget.Dispose();
250             tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow END (OK)");
251         }
252
253         [Test]
254         [Category("P1")]
255         [Description("NUIApplication RegisterAssembly.")]
256         [Property("SPEC", "Tizen.NUI.NUIApplication.RegisterAssembly M")]
257         [Property("SPEC_URL", "-")]
258         [Property("CRITERIA", "MR")]
259         [Property("AUTHOR", "guowei.wang@samsung.com")]
260         public void NUIApplicationRegisterAssembly()
261         {
262             tlog.Debug(tag, $"NUIApplicationRegisterAssembly START");
263
264             try
265             {
266                 NUIApplication.RegisterAssembly(typeof(NUIApplication).Assembly);
267             }
268             catch (Exception e)
269             {
270                 tlog.Error(tag, "Caught Exception" + e.ToString());
271                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
272                 Assert.Fail("Caught Exception" + e.ToString());
273             }
274
275             tlog.Debug(tag, $"NUIApplicationRegisterAssembly END (OK)");
276         }
277
278         [Test]
279         [Category("P1")]
280         [Description("NUIApplication MultilingualResourceManager.")]
281         [Property("SPEC", "Tizen.NUI.NUIApplication.MultilingualResourceManager A")]
282         [Property("SPEC_URL", "-")]
283         [Property("CRITERIA", "PRW")]
284         [Property("AUTHOR", "guowei.wang@samsung.com")]
285         public void NUIApplicationMultilingualResourceManager()
286         {
287             tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager START");
288
289             NUIApplication.MultilingualResourceManager = Resource.ResourceManager;
290             Assert.IsNotNull(NUIApplication.MultilingualResourceManager, "Should be not null!");
291
292             string str = null;
293             str = NUIApplication.MultilingualResourceManager?.GetString("Test");
294             Assert.AreEqual("Test", str, "Picture should be Beeld in Dutch");
295
296             tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager END (OK)");
297         }
298
299         [Test]
300         [Category("P1")]
301         [Description("NUIApplication AppId")]
302         [Property("SPEC", "Tizen.NUI.NUIApplication.AppId A")]
303         [Property("SPEC_URL", "-")]
304         [Property("CRITERIA", "PRO")]
305         [Property("AUTHOR", "guowei.wang@samsung.com")]
306         public void NUIApplicationAppId()
307         {
308             tlog.Debug(tag, $"NUIApplicationAppId START");
309
310             var testingTarget = new NUIApplication();
311             Assert.IsNotNull(testingTarget, "Should be not null.");
312             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
313
314             var result = testingTarget.AppId;
315             Assert.IsNotNull(result, "Should be not null.");
316
317             tlog.Debug(tag, $"NUIApplicationAppId END (OK)");
318         }
319
320         [Test]
321         [Category("P1")]
322         [Description("NUIApplication GetDefaultWindow")]
323         [Property("SPEC", "Tizen.NUI.NUIApplication.GetDefaultWindow M")]
324         [Property("SPEC_URL", "-")]
325         [Property("CRITERIA", "MR")]
326         [Property("AUTHOR", "guowei.wang@samsung.com")]
327         public void NUIApplicationGetDefaultWindow()
328         {
329             tlog.Debug(tag, $"NUIApplicationGetDefaultWindow START");
330
331             var testingTarget = NUIApplication.GetDefaultWindow();
332             Assert.IsNotNull(testingTarget, "Should be not null.");
333             Assert.IsInstanceOf<Window>(testingTarget, "Should be an instance of Window type.");
334
335             testingTarget.Dispose();
336             tlog.Debug(tag, $"NUIApplicationGetDefaultWindow END (OK)");
337         }
338
339         [Test]
340         [Category("P1")]
341         [Description("NUIApplication AddIdle")]
342         [Property("SPEC", "Tizen.NUI.NUIApplication.AddIdle M")]
343         [Property("SPEC_URL", "-")]
344         [Property("CRITERIA", "MR")]
345         [Property("AUTHOR", "guowei.wang@samsung.com")]
346         public void NUIApplicationAddIdle()
347         {
348             tlog.Debug(tag, $"NUIApplicationAddIdle START");
349
350             dummyCallback callback = OnDummyCallback;
351             var result = Application.Instance.AddIdle(callback);
352             Assert.IsTrue(result);
353
354             tlog.Debug(tag, $"NUIApplicationAddIdle END (OK)");
355         }
356
357         [Test]
358         [Category("P1")]
359         [Description("NUIApplication SetRenderRefreshRate")]
360         [Property("SPEC", "Tizen.NUI.NUIApplication.SetRenderRefreshRate M")]
361         [Property("SPEC_URL", "-")]
362         [Property("CRITERIA", "MR")]
363         [Property("AUTHOR", "guowei.wang@samsung.com")]
364         public void NUIApplicationSetRenderRefreshRate()
365         {
366             tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate START");
367
368             try
369             {
370                 NUIApplication.SetRenderRefreshRate(2);
371             }
372             catch (Exception e)
373             {
374                 tlog.Error(tag, "Caught Exception" + e.ToString());
375                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
376                 Assert.Fail("Caught Exception" + e.ToString());
377             }
378
379             tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate END (OK)");
380         }
381
382         [Test]
383         [Category("P1")]
384         [Description("NUIApplication TransitionOptions")]
385         [Property("SPEC", "Tizen.NUI.NUIApplication.TransitionOptions A")]
386         [Property("SPEC_URL", "-")]
387         [Property("CRITERIA", "PRW")]
388         [Property("AUTHOR", "guowei.wang@samsung.com")]
389         public void NUIApplicationTransitionOptions()
390         {
391             tlog.Debug(tag, $"NUIApplicationTransitionOptions START");
392
393             var testingTarget = new NUIApplication();
394             Assert.IsNotNull(testingTarget, "Should be not null.");
395             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
396
397             TransitionOptions transitionOption = new TransitionOptions(Window.Instance);
398             testingTarget.TransitionOptions = transitionOption;
399
400             var result = testingTarget.TransitionOptions;
401             Assert.IsNotNull(result);
402             Assert.IsInstanceOf<TransitionOptions>(result, "Should be an instance of TransitionOptions type.");
403
404             result.Dispose();
405             transitionOption.Dispose();
406             testingTarget.Dispose();
407             tlog.Debug(tag, $"NUIApplicationTransitionOptions END (OK)");
408         }
409
410         [Test]
411         [Category("P1")]
412         [Description("NUIApplication OnTerminate")]
413         [Property("SPEC", "Tizen.NUI.NUIApplication.OnTerminate M")]
414         [Property("SPEC_URL", "-")]
415         [Property("CRITERIA", "MR")]
416         [Property("AUTHOR", "guowei.wang@samsung.com")]
417         public void NUIApplicationOnTerminate()
418         {
419             tlog.Debug(tag, $"NUIApplicationOnTerminate START");
420
421             var testingTarget = new MyNUIApplication();
422             Assert.IsNotNull(testingTarget, "Should be not null.");
423             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
424
425             try
426             {
427                 testingTarget.MyOnTerminate();
428             }
429             catch (Exception e)
430             {
431                 tlog.Debug(tag, e.Message.ToString());
432                 Assert.Fail("Caught Exception : Failed!");
433             }
434
435             tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");
436         }
437
438         [Test]
439         [Category("P1")]
440         [Description("NUIApplication OnLocaleChanged")]
441         [Property("SPEC", "Tizen.NUI.NUIApplication.OnLocaleChanged M")]
442         [Property("SPEC_URL", "-")]
443         [Property("CRITERIA", "MR")]
444         [Property("AUTHOR", "guowei.wang@samsung.com")]
445         public void NUIApplicationOnLocaleChanged()
446         {
447             tlog.Debug(tag, $"NUIApplicationOnLocaleChanged START");
448
449             var testingTarget = new MyNUIApplication();
450             Assert.IsNotNull(testingTarget, "Should be not null.");
451             Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
452
453             try
454             {
455                 testingTarget.MyOnLocaleChanged(new LocaleChangedEventArgs("Shanghai"));
456             }
457             catch (Exception e)
458             {
459                 tlog.Debug(tag, e.Message.ToString());
460                 Assert.Fail("Caught Exception : Failed!");
461             }
462
463             tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");
464         }
465     }
466 }