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;
10 namespace Tizen.NUI.Devel.Tests
12 using tlog = Tizen.Log;
15 [Description("public/Application/NUIApplication")]
16 class PublicNUIApplicationTest
18 private const string tag = "NUITEST";
19 private delegate bool dummyCallback(IntPtr NUIApplication);
20 private bool OnDummyCallback(IntPtr data)
25 internal class MyNUIApplication : NUIApplication
27 public MyNUIApplication() : base()
30 public void MyOnTerminate()
35 public void MyOnLocaleChanged(LocaleChangedEventArgs e)
37 base.OnLocaleChanged(e);
44 tlog.Info(tag, "Init() is called!");
50 tlog.Info(tag, "Destroy() is called!");
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()
62 tlog.Debug(tag, $"NUIApplicationConstructor START");
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.");
68 testingTarget.Dispose();
69 tlog.Debug(tag, $"NUIApplicationConstructor END (OK)");
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()
81 tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition START");
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.");
89 tlog.Debug(tag, "ApplicationHandle : " + testingTarget.ApplicationHandle);
93 testingTarget.Dispose();
94 tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition END (OK)");
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()
106 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet START");
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.");
112 testingTarget.Dispose();
113 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet END (OK)");
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()
125 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion START");
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.");
131 testingTarget.Dispose();
132 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion END (OK)");
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()
144 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode START");
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.");
150 testingTarget.Dispose();
151 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode END (OK)");
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()
163 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition START");
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.");
169 testingTarget.Dispose();
170 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition END (OK)");
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()
182 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType START");
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.");
188 testingTarget.Dispose();
189 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType END (OK)");
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()
201 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions START");
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.");
207 testingTarget.Dispose();
208 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions END (OK)");
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()
220 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions START");
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.");
228 windowSize.Dispose();
229 windowPosition.Dispose();
230 testingTarget.Dispose();
231 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions END (OK)");
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()
243 tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow START");
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.");
249 testingTarget.Dispose();
250 tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow END (OK)");
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()
262 tlog.Debug(tag, $"NUIApplicationRegisterAssembly START");
266 NUIApplication.RegisterAssembly(typeof(NUIApplication).Assembly);
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());
275 tlog.Debug(tag, $"NUIApplicationRegisterAssembly END (OK)");
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()
287 tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager START");
289 NUIApplication.MultilingualResourceManager = Resource.ResourceManager;
290 Assert.IsNotNull(NUIApplication.MultilingualResourceManager, "Should be not null!");
293 str = NUIApplication.MultilingualResourceManager?.GetString("Test");
294 Assert.AreEqual("Test", str, "Picture should be Beeld in Dutch");
296 tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager END (OK)");
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()
308 tlog.Debug(tag, $"NUIApplicationAppId START");
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.");
314 var result = testingTarget.AppId;
315 Assert.IsNotNull(result, "Should be not null.");
317 tlog.Debug(tag, $"NUIApplicationAppId END (OK)");
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()
329 tlog.Debug(tag, $"NUIApplicationGetDefaultWindow START");
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.");
335 testingTarget.Dispose();
336 tlog.Debug(tag, $"NUIApplicationGetDefaultWindow END (OK)");
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()
348 tlog.Debug(tag, $"NUIApplicationAddIdle START");
350 dummyCallback callback = OnDummyCallback;
351 var result = Application.Instance.AddIdle(callback);
352 Assert.IsTrue(result);
354 tlog.Debug(tag, $"NUIApplicationAddIdle END (OK)");
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()
366 tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate START");
370 NUIApplication.SetRenderRefreshRate(2);
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());
379 tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate END (OK)");
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()
391 tlog.Debug(tag, $"NUIApplicationTransitionOptions START");
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.");
397 TransitionOptions transitionOption = new TransitionOptions(Window.Instance);
398 testingTarget.TransitionOptions = transitionOption;
400 var result = testingTarget.TransitionOptions;
401 Assert.IsNotNull(result);
402 Assert.IsInstanceOf<TransitionOptions>(result, "Should be an instance of TransitionOptions type.");
405 transitionOption.Dispose();
406 testingTarget.Dispose();
407 tlog.Debug(tag, $"NUIApplicationTransitionOptions END (OK)");
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()
419 tlog.Debug(tag, $"NUIApplicationOnTerminate START");
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.");
427 testingTarget.MyOnTerminate();
431 tlog.Debug(tag, e.Message.ToString());
432 Assert.Fail("Caught Exception : Failed!");
435 tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");
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()
447 tlog.Debug(tag, $"NUIApplicationOnLocaleChanged START");
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.");
455 testingTarget.MyOnLocaleChanged(new LocaleChangedEventArgs("Shanghai"));
459 tlog.Debug(tag, e.Message.ToString());
460 Assert.Fail("Caught Exception : Failed!");
463 tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");