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 tlog.Debug(tag, "Window : " + testingTarget.Window);
70 tlog.Debug(tag, $"NUIApplicationConstructor END (OK)");
75 [Description("NUIApplication constructor. With window size and position")]
76 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
77 [Property("SPEC_URL", "-")]
78 [Property("CRITERIA", "CONSTR")]
79 [Property("AUTHOR", "guowei.wang@samsung.com")]
80 public void NUIApplicationConstructorWithWindowSizeAndPosition()
82 tlog.Debug(tag, $"NUIApplicationConstructorWithWindowSizeAndPosition START");
84 Size size = new Size(100, 200);
85 Position pos = new Position(200, 300);
86 var testingTarget = new NUIApplication(size, pos);
87 Assert.IsNotNull(testingTarget, "Should be not null.");
88 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
90 tlog.Debug(tag, "ApplicationHandle : " + testingTarget.ApplicationHandle);
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 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheet END (OK)");
117 [Description("NUIApplication constructor. With stylesheet, window size, position.")]
118 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
119 [Property("SPEC_URL", "-")]
120 [Property("CRITERIA", "CONSTR")]
121 [Property("AUTHOR", "guowei.wang@samsung.com")]
122 public void NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion()
124 tlog.Debug(tag, $"NUIApplicationConstructorWithStyleSheetAndWindowSizeAndPostion START");
126 var testingTarget = new NUIApplication("stylesheet", new Size(100, 200), new Position(200, 300));
127 Assert.IsNotNull(testingTarget, "Should be not null.");
128 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
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 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowMode END (OK)");
153 [Description("NUIApplication constructor. With stylesheet, WindowMode, window size and position")]
154 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
155 [Property("SPEC_URL", "-")]
156 [Property("CRITERIA", "CONSTR")]
157 [Property("AUTHOR", "guowei.wang@samsung.com")]
158 public void NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition()
160 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition START");
162 var testingTarget = new NUIApplication("stylesheet", NUIApplication.WindowMode.Opaque, new Size(100, 200), new Position(200, 300));
163 Assert.IsNotNull(testingTarget, "Should be not null.");
164 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
166 tlog.Debug(tag, $"NUIApplicationConstructorWithStringAndWindowModeAndWindowSizeAndPosition END (OK)");
171 [Description("NUIApplication constructor. With BackendType.")]
172 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
173 [Property("SPEC_URL", "-")]
174 [Property("CRITERIA", "CONSTR")]
175 [Property("AUTHOR", "guowei.wang@samsung.com")]
176 public void NUIApplicationConstructorWithBackendType()
178 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType START");
180 var testingTarget = new NUIApplication(Graphics.BackendType.Vulkan);
181 Assert.IsNotNull(testingTarget, "Should be not null.");
182 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
184 tlog.Debug(tag, $"NUIApplicationConstructorWithBackendType END (OK)");
189 [Description("NUIApplication constructor. With ThemeOptions.")]
190 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
191 [Property("SPEC_URL", "-")]
192 [Property("CRITERIA", "CONSTR")]
193 [Property("AUTHOR", "guowei.wang@samsung.com")]
194 public void NUIApplicationConstructorWithThemeOptions()
196 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions START");
198 var testingTarget = new NUIApplication(NUIApplication.ThemeOptions.PlatformThemeEnabled);
199 Assert.IsNotNull(testingTarget, "Should be not null.");
200 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
202 tlog.Debug(tag, $"NUIApplicationConstructorWithThemeOptions END (OK)");
207 [Description("NUIApplication constructor. With windowSize, windowPosition and options.")]
208 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
209 [Property("SPEC_URL", "-")]
210 [Property("CRITERIA", "CONSTR")]
211 [Property("AUTHOR", "guowei.wang@samsung.com")]
212 public void NUIApplicationConstructorWithSizePositionAndThemeOptions()
214 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions START");
216 Size2D windowSize = new Size2D(100, 50);
217 Position2D windowPosition = new Position2D(20, 30);
218 var testingTarget = new NUIApplication(windowSize, windowPosition, NUIApplication.ThemeOptions.PlatformThemeEnabled);
219 Assert.IsNotNull(testingTarget, "Should be not null.");
220 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
222 windowSize.Dispose();
223 windowPosition.Dispose();
224 tlog.Debug(tag, $"NUIApplicationConstructorWithSizePositionAndThemeOptions END (OK)");
229 [Description("NUIApplication constructor. Support IME window.")]
230 [Property("SPEC", "Tizen.NUI.NUIApplication.NUIApplication C")]
231 [Property("SPEC_URL", "-")]
232 [Property("CRITERIA", "CONSTR")]
233 [Property("AUTHOR", "guowei.wang@samsung.com")]
234 public void NUIApplicationConstructorForImeWindow()
236 tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow START");
238 var testingTarget = new NUIApplication("", NUIApplication.WindowMode.Opaque, WindowType.Dialog);
239 Assert.IsNotNull(testingTarget, "Should be not null.");
240 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
242 tlog.Debug(tag, $"NUIApplicationConstructorForImeWindow END (OK)");
247 [Description("NUIApplication RegisterAssembly.")]
248 [Property("SPEC", "Tizen.NUI.NUIApplication.RegisterAssembly M")]
249 [Property("SPEC_URL", "-")]
250 [Property("CRITERIA", "MR")]
251 [Property("AUTHOR", "guowei.wang@samsung.com")]
252 public void NUIApplicationRegisterAssembly()
254 tlog.Debug(tag, $"NUIApplicationRegisterAssembly START");
258 NUIApplication.RegisterAssembly(typeof(NUIApplication).Assembly);
262 tlog.Error(tag, "Caught Exception" + e.ToString());
263 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
264 Assert.Fail("Caught Exception" + e.ToString());
267 tlog.Debug(tag, $"NUIApplicationRegisterAssembly END (OK)");
272 [Description("NUIApplication MultilingualResourceManager.")]
273 [Property("SPEC", "Tizen.NUI.NUIApplication.MultilingualResourceManager A")]
274 [Property("SPEC_URL", "-")]
275 [Property("CRITERIA", "PRW")]
276 [Property("AUTHOR", "guowei.wang@samsung.com")]
277 public void NUIApplicationMultilingualResourceManager()
279 tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager START");
281 NUIApplication.MultilingualResourceManager = Resource.ResourceManager;
282 Assert.IsNotNull(NUIApplication.MultilingualResourceManager, "Should be not null!");
285 str = NUIApplication.MultilingualResourceManager?.GetString("Test");
286 Assert.AreEqual("Test", str, "Picture should be Beeld in Dutch");
288 tlog.Debug(tag, $"NUIApplicationMultilingualResourceManager END (OK)");
293 [Description("NUIApplication AppId")]
294 [Property("SPEC", "Tizen.NUI.NUIApplication.AppId A")]
295 [Property("SPEC_URL", "-")]
296 [Property("CRITERIA", "PRO")]
297 [Property("AUTHOR", "guowei.wang@samsung.com")]
298 public void NUIApplicationAppId()
300 tlog.Debug(tag, $"NUIApplicationAppId START");
302 var testingTarget = new NUIApplication();
303 Assert.IsNotNull(testingTarget, "Should be not null.");
304 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of NUIApplication type.");
306 var result = testingTarget.AppId;
307 Assert.IsNotNull(result, "Should be not null.");
309 tlog.Debug(tag, $"NUIApplicationAppId END (OK)");
314 [Description("NUIApplication GetDefaultWindow")]
315 [Property("SPEC", "Tizen.NUI.NUIApplication.GetDefaultWindow M")]
316 [Property("SPEC_URL", "-")]
317 [Property("CRITERIA", "MR")]
318 [Property("AUTHOR", "guowei.wang@samsung.com")]
319 public void NUIApplicationGetDefaultWindow()
321 tlog.Debug(tag, $"NUIApplicationGetDefaultWindow START");
323 var testingTarget = NUIApplication.GetDefaultWindow();
324 Assert.IsNotNull(testingTarget, "Should be not null.");
325 Assert.IsInstanceOf<Window>(testingTarget, "Should be an instance of Window type.");
327 tlog.Debug(tag, $"NUIApplicationGetDefaultWindow END (OK)");
332 [Description("NUIApplication AddIdle")]
333 [Property("SPEC", "Tizen.NUI.NUIApplication.AddIdle M")]
334 [Property("SPEC_URL", "-")]
335 [Property("CRITERIA", "MR")]
336 [Property("AUTHOR", "guowei.wang@samsung.com")]
337 public void NUIApplicationAddIdle()
339 tlog.Debug(tag, $"NUIApplicationAddIdle START");
341 dummyCallback callback = OnDummyCallback;
342 var result = Application.Instance.AddIdle(callback);
343 Assert.IsTrue(result);
345 tlog.Debug(tag, $"NUIApplicationAddIdle END (OK)");
350 [Description("NUIApplication SetRenderRefreshRate")]
351 [Property("SPEC", "Tizen.NUI.NUIApplication.SetRenderRefreshRate M")]
352 [Property("SPEC_URL", "-")]
353 [Property("CRITERIA", "MR")]
354 [Property("AUTHOR", "guowei.wang@samsung.com")]
355 public void NUIApplicationSetRenderRefreshRate()
357 tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate START");
361 NUIApplication.SetRenderRefreshRate(2);
365 tlog.Error(tag, "Caught Exception" + e.ToString());
366 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
367 Assert.Fail("Caught Exception" + e.ToString());
370 tlog.Debug(tag, $"NUIApplicationSetRenderRefreshRate END (OK)");
375 [Description("NUIApplication OnTerminate")]
376 [Property("SPEC", "Tizen.NUI.NUIApplication.OnTerminate M")]
377 [Property("SPEC_URL", "-")]
378 [Property("CRITERIA", "MR")]
379 [Property("AUTHOR", "guowei.wang@samsung.com")]
380 public void NUIApplicationOnTerminate()
382 tlog.Debug(tag, $"NUIApplicationOnTerminate START");
384 var testingTarget = new MyNUIApplication();
385 Assert.IsNotNull(testingTarget, "Should be not null.");
386 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
390 testingTarget.MyOnTerminate();
394 tlog.Debug(tag, e.Message.ToString());
395 Assert.Fail("Caught Exception : Failed!");
398 tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");
403 [Description("NUIApplication OnLocaleChanged")]
404 [Property("SPEC", "Tizen.NUI.NUIApplication.OnLocaleChanged M")]
405 [Property("SPEC_URL", "-")]
406 [Property("CRITERIA", "MR")]
407 [Property("AUTHOR", "guowei.wang@samsung.com")]
408 public void NUIApplicationOnLocaleChanged()
410 tlog.Debug(tag, $"NUIApplicationOnLocaleChanged START");
412 var testingTarget = new MyNUIApplication();
413 Assert.IsNotNull(testingTarget, "Should be not null.");
414 Assert.IsInstanceOf<NUIApplication>(testingTarget, "Should be an instance of Window type.");
418 testingTarget.MyOnLocaleChanged(new LocaleChangedEventArgs("Shanghai"));
422 tlog.Debug(tag, e.Message.ToString());
423 Assert.Fail("Caught Exception : Failed!");
426 tlog.Debug(tag, $"NUIApplicationOnTerminate END (OK)");