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.");
91 testingTarget.Dispose();
92 tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition END (OK)");
97 [Description("NUIApplication constructor. With stylesheet.")]
98 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
99 [Property("SPEC_URL", "-")]
100 [Property("CRITERIA", "CONSTR")]
101 [Property("AUTHOR", "guowei.wang@samsung.com")]
102 public void NUIApplicationConstructorWithStyleSheet()
104 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet START");
106 var testingTarget = new NUIApplication("stylesheet");
107 Assert.IsNotNull(testingTarget, "Should be not null.");
108 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
110 testingTarget.Dispose();
111 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet END (OK)");
116 [Description("NUIApplication constructor. With stylesheet, window size, position.")]
117 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
118 [Property("SPEC_URL", "-")]
119 [Property("CRITERIA", "CONSTR")]
120 [Property("AUTHOR", "guowei.wang@samsung.com")]
121 public void NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion()
123 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion START");
125 var testingTarget = new NUIApplication("stylesheet", new Size(100, 200), new Position(200, 300));
126 Assert.IsNotNull(testingTarget, "Should be not null.");
127 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
129 testingTarget.Dispose();
130 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion END (OK)");
135 [Description("NUIApplication constructor. With stylesheet and WindowMode.")]
136 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
137 [Property("SPEC_URL", "-")]
138 [Property("CRITERIA", "CONSTR")]
139 [Property("AUTHOR", "guowei.wang@samsung.com")]
140 public void NUIApplicationConstructorWithStringAndWindowMode()
142 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode START");
144 var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque);
145 Assert.IsNotNull(testingTarget, "Should be not null.");
146 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
148 testingTarget.Dispose();
149 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode END (OK)");
154 [Description("NUIApplication constructor. With stylesheet, WindowMode, window size and position")]
155 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
156 [Property("SPEC_URL", "-")]
157 [Property("CRITERIA", "CONSTR")]
158 [Property("AUTHOR", "guowei.wang@samsung.com")]
159 public void NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition()
161 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition START");
163 var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque, new Size(100, 200), new Position(200, 300));
164 Assert.IsNotNull(testingTarget, "Should be not null.");
165 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
167 testingTarget.Dispose();
168 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition END (OK)");
173 [Description("NUIApplication constructor. With BackendType.")]
174 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
175 [Property("SPEC_URL", "-")]
176 [Property("CRITERIA", "CONSTR")]
177 [Property("AUTHOR", "guowei.wang@samsung.com")]
178 public void NUIApplicationConstructorWithBackendType()
180 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType START");
182 var testingTarget = new NUIApplication(Graphics.BackendType.Vulkan);
183 Assert.IsNotNull(testingTarget, "Should be not null.");
184 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
186 testingTarget.Dispose();
187 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType END (OK)");
192 [Description("NUIApplication constructor. With ThemeOptions.")]
193 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
194 [Property("SPEC_URL", "-")]
195 [Property("CRITERIA", "CONSTR")]
196 [Property("AUTHOR", "guowei.wang@samsung.com")]
197 public void NUIApplicationConstructorWithThemeOptions()
199 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions START");
201 var testingTarget = new NUIApplication(NUIApplication.ThemeOptions.PlatformThemeEnabled);
202 Assert.IsNotNull(testingTarget, "Should be not null.");
203 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
205 testingTarget.Dispose();
206 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions END (OK)");
211 [Description("NUIApplication constructor. With windowSize, windowPosition and options.")]
212 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
213 [Property("SPEC_URL", "-")]
214 [Property("CRITERIA", "CONSTR")]
215 [Property("AUTHOR", "guowei.wang@samsung.com")]
216 public void NUIApplicationConstructorWithSizePositionAndThemeOptions()
218 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions START");
220 Size2D windowSize = new Size2D(100, 50);
221 Position2D windowPosition = new Position2D(20, 30);
222 var testingTarget = new NUIApplication(windowSize, windowPosition, NUIApplication.ThemeOptions.PlatformThemeEnabled);
223 Assert.IsNotNull(testingTarget, "Should be not null.");
224 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
226 windowSize.Dispose();
227 windowPosition.Dispose();
228 testingTarget.Dispose();
229 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions END (OK)");
234 [Description("NUIApplication constructor. Support IME window.")]
235 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
236 [Property("SPEC_URL", "-")]
237 [Property("CRITERIA", "CONSTR")]
238 [Property("AUTHOR", "guowei.wang@samsung.com")]
239 public void NUIApplicationConstructorForImeWindow()
241 tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow START");
243 var application = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque, WindowType.Ime);
244 Assert.IsNotNull(application, "NUIApplication Should return NUIApplication instance.");
245 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
247 windowSize.Dispose();
248 windowPosition.Dispose();
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)");