1 using NUnit.Framework;
3 using System.Collections.Generic;
4 using Tizen.NUI.BaseComponents;
5 using Tizen.NUI.Binding;
7 namespace Tizen.NUI.Devel.Tests
9 using tlog = Tizen.Log;
12 [Description("public/Theme/Theme")]
13 internal class PublicThemeTest
15 private const string tag = "NUITEST";
16 private Theme theme = null;
17 private string path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Test_Theme.xaml";
18 private string image = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
19 private string IOException_file = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "1.xaml";
20 private string ParseException_file = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Test_View.xaml";
21 private IEnumerable<KeyValuePair<string, string>> changedResources = new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Version", "2.0") };
26 tlog.Info(tag, "Init() is called!");
27 theme = new Theme(path);
34 tlog.Info(tag, "Destroy() is called!");
39 [Description("Theme construcotr. xaml file path is null.")]
40 [Property("SPEC", "Tizen.NUI.Theme.Theme C")]
41 [Property("SPEC_URL", "-")]
42 [Property("CRITERIA", "CONSTR")]
43 [Property("COVPARAM", "")]
44 public void ThemeConstructorWithUnavailablePath()
46 tlog.Debug(tag, $"ThemeConstructorWithUnavailablePath START");
50 var testingTarget = new Theme("");
52 catch (ArgumentNullException e)
54 tlog.Debug(tag, e.Message.ToString());
55 tlog.Debug(tag, $"ThemeConstructorWithUnavailablePath END (OK)");
56 Assert.Pass("Caught ArgumentNullException : Passed!");
62 [Description("Theme construcotr. Could not parse.")]
63 [Property("SPEC", "Tizen.NUI.Theme.Theme C")]
64 [Property("SPEC_URL", "-")]
65 [Property("CRITERIA", "CONSTR")]
66 [Property("COVPARAM", "")]
67 public void ThemeConstructorWithFileCouldNotBeParsed()
69 tlog.Debug(tag, $"ThemeConstructorWithFileCouldNotBeParsed START");
73 var testingTarget = new Theme(image);
77 tlog.Debug(tag, e.Message.ToString());
78 tlog.Debug(tag, $"ThemeConstructorWithFileCouldNotBeParsed END (OK)");
79 Assert.Pass("Caught Exception : Passed!");
85 [Description("Theme construcotr. IOException.")]
86 [Property("SPEC", "Tizen.NUI.Theme.Theme C")]
87 [Property("SPEC_URL", "-")]
88 [Property("CRITERIA", "CONSTR")]
89 [Property("COVPARAM", "")]
90 public void ThemeConstructorIOException()
92 tlog.Debug(tag, $"ThemeConstructorIOException START");
96 var testingTarget = new Theme(IOException_file);
100 tlog.Debug(tag, e.Message.ToString());
101 tlog.Debug(tag, $"ThemeConstructorIOException END (OK)");
102 Assert.Pass("Caught IOException : Passed!");
108 [Description("Theme construcotr. XamlParseException.")]
109 [Property("SPEC", "Tizen.NUI.Theme.Theme C")]
110 [Property("SPEC_URL", "-")]
111 [Property("CRITERIA", "CONSTR")]
112 [Property("COVPARAM", "")]
113 public void ThemeConstructorXamlParseException()
115 tlog.Debug(tag, $"ThemeConstructorXamlParseException START");
119 var testingTarget = new Theme(ParseException_file);
123 tlog.Debug(tag, e.Message.ToString());
124 tlog.Debug(tag, $"ThemeConstructorXamlParseException END (OK)");
125 Assert.Pass("Caught XamlParseException : Passed!");
131 [Description("test Theme BasedOn.")]
132 [Property("SPEC", "Tizen.NUI.Theme.BasedOn A")]
133 [Property("SPEC_URL", "-")]
134 [Property("CRITERIA", "PRW")]
135 [Property("COVPARAM", "")]
136 public void ThemeBasedOn()
138 tlog.Debug(tag, $"ThemeBasedOn START");
140 var baseOn = "Tizen.NUI.Theme.Common";
141 theme.BasedOn = baseOn;
142 tlog.Debug(tag, "BaseOn : " + theme.BasedOn);
144 tlog.Debug(tag, $"ThemeBasedOn END (OK)");
149 [Description("test Theme IsResourcesCreated .")]
150 [Property("SPEC", "Tizen.NUI.Theme.IsResourcesCreated A")]
151 [Property("SPEC_URL", "-")]
152 [Property("CRITERIA", "PRW")]
153 [Property("COVPARAM", "")]
154 public void ThemeIsResourcesCreated()
156 tlog.Debug(tag, $"ThemeIsResourcesCreated START");
158 var result = theme.IsResourcesCreated;
159 tlog.Debug(tag, "IsResourcesCreated : " + result);
161 tlog.Debug(tag, $"ThemeIsResourcesCreated END (OK)");
166 [Description("test Theme Resources .")]
167 [Property("SPEC", "Tizen.NUI.Theme.Resources A")]
168 [Property("SPEC_URL", "-")]
169 [Property("CRITERIA", "PRW")]
170 [Property("COVPARAM", "")]
171 public void ThemeResources()
173 tlog.Debug(tag, $"ThemeResources START");
175 var result = theme.Resources;
176 tlog.Debug(tag, "Resources : " + result);
178 theme.SetChangedResources(changedResources);
180 // resources == value
181 theme.Resources = result;
182 tlog.Debug(tag, "Resouces : " + theme.Resources);
185 ResourceDictionary dic = new ResourceDictionary();
186 theme.Resources = dic;
187 tlog.Debug(tag, "Resouces : " + theme.Resources);
189 tlog.Debug(tag, $"ThemeResources END (OK)");
194 [Description("test Theme this .")]
195 [Property("SPEC", "Tizen.NUI.Theme.this A")]
196 [Property("SPEC_URL", "-")]
197 [Property("CRITERIA", "PRW")]
198 [Property("COVPARAM", "")]
199 public void ThemeThis()
201 tlog.Debug(tag, $"ThemeThis START");
203 ViewStyle style = new ViewStyle()
208 theme.AddStyle("style", style);
210 tlog.Debug(tag, "Count : " + theme.Count);
211 tlog.Debug(tag, "theme[\"style\"] : " + theme["style"]);
213 ViewStyle newStyle = new ViewStyle()
215 Size = new Size(100, 50),
219 theme["Style"] = newStyle;
220 tlog.Debug(tag, "theme[\"style\"] : " + theme["style"]);
222 tlog.Debug(tag, $"ThemeThis END (OK)");
227 [Description("test Theme this .")]
228 [Property("SPEC", "Tizen.NUI.Theme.this A")]
229 [Property("SPEC_URL", "-")]
230 [Property("CRITERIA", "PRW")]
231 [Property("COVPARAM", "")]
232 public void ThemeThisSetVauleIsNUll()
234 tlog.Debug(tag, $"ThemeThisSetVauleIsNUll START");
236 ViewStyle style = new ViewStyle()
241 theme.AddStyle("style", style);
243 tlog.Debug(tag, "Count : " + theme.Count);
244 tlog.Debug(tag, "theme[\"style\"] : " + theme["style"]);
246 ViewStyle newStyle = null;
248 theme["Style"] = newStyle;
249 tlog.Debug(tag, "theme[\"style\"] : " + theme["style"]);
251 tlog.Debug(tag, $"ThemeThisSetVauleIsNUll END (OK)");
256 [Description("test Theme Clear .")]
257 [Property("SPEC", "Tizen.NUI.Theme.Clear M")]
258 [Property("SPEC_URL", "-")]
259 [Property("CRITERIA", "MR")]
260 [Property("COVPARAM", "")]
261 public void ThemeClear()
263 tlog.Debug(tag, $"ThemeClear START");
271 tlog.Debug(tag, e.Message.ToString());
272 Assert.Fail("Caught Exception : Failed!");
275 tlog.Debug(tag, $"ThemeClear END (OK)");
280 [Description("test Theme AddStyle .")]
281 [Property("SPEC", "Tizen.NUI.Theme.AddStyle M")]
282 [Property("SPEC_URL", "-")]
283 [Property("CRITERIA", "MR")]
284 [Property("COVPARAM", "")]
285 public void ThemeAddStyle()
287 tlog.Debug(tag, $"ThemeAddStyle START");
289 ViewStyle style = new ViewStyle()
296 theme.AddStyle("style", style);
300 tlog.Debug(tag, e.Message.ToString());
301 Assert.Fail("Caught Exception : Failed!");
304 tlog.Debug(tag, "HasStyle : " + theme.HasStyle("style"));
305 tlog.Debug(tag, "RemoveStyle : " + theme.RemoveStyle("style"));
307 tlog.Debug(tag, $"ThemeAddStyle END (OK)");
312 [Description("test Theme AddStyle .")]
313 [Property("SPEC", "Tizen.NUI.Theme.AddStyle M")]
314 [Property("SPEC_URL", "-")]
315 [Property("CRITERIA", "MR")]
316 [Property("COVPARAM", "")]
317 public void ThemeAddStyleNullStyleName()
319 tlog.Debug(tag, $"ThemeAddStyleNullStyleName START");
321 ViewStyle style = new ViewStyle()
328 theme.AddStyle(null, style);
330 catch (ArgumentNullException e)
332 tlog.Debug(tag, e.Message.ToString());
333 tlog.Debug(tag, $"ThemeAddStyleNullStyleName END (OK)");
334 Assert.Pass("Caught Exception : Passed!");
340 [Description("test Theme Clone .")]
341 [Property("SPEC", "Tizen.NUI.Theme.Clone M")]
342 [Property("SPEC_URL", "-")]
343 [Property("CRITERIA", "MR")]
344 [Property("COVPARAM", "")]
345 public void ThemeClone()
347 tlog.Debug(tag, $"ThemeClone START");
355 tlog.Debug(tag, e.Message.ToString());
356 Assert.Fail("Caught Exception : Failed!");
359 tlog.Debug(tag, $"ThemeClone END (OK)");
364 [Description("Theme Merge .")]
365 [Property("SPEC", "Tizen.NUI.Theme.Merge M")]
366 [Property("SPEC_URL", "-")]
367 [Property("CRITERIA", "MR")]
368 [Property("COVPARAM", "")]
369 public void ThemeMerge()
371 tlog.Debug(tag, $"ThemeMerge START");
373 var testingTarget = new Theme();
374 Assert.IsNotNull(testingTarget, "should be not null");
375 Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
377 ViewStyle style = new ViewStyle()
379 Size = new Size2D(100, 30),
382 testingTarget.Version = "0.1";
383 testingTarget.AddStyle("myStyle", style);
387 theme.Merge(testingTarget); // merge with Theme
388 theme.Merge(path); // merge with xaml file
392 tlog.Debug(tag, e.Message.ToString());
393 Assert.Fail("Caught Exception: Failed!");
396 tlog.Debug(tag, $"ThemeMerge END (OK)");
401 [Description("Theme Merge. Parameter is null.")]
402 [Property("SPEC", "Tizen.NUI.Theme.Merge M")]
403 [Property("SPEC_URL", "-")]
404 [Property("CRITERIA", "MR")]
405 [Property("COVPARAM", "")]
406 public void ThemeMergeWithNullParameter()
408 tlog.Debug(tag, $"ThemeMergeWithNullParameter START");
412 Theme newtheme = null;
413 theme.Merge(newtheme);
415 catch (ArgumentNullException e)
417 tlog.Debug(tag, e.Message.ToString());
418 tlog.Debug(tag, $"ThemeMergeWithNullParameter END (OK)");
419 Assert.Pass("Caught ArgumentNullException: Passed!");
425 [Description("Theme Merge.")]
426 [Property("SPEC", "Tizen.NUI.Theme.Merge M")]
427 [Property("SPEC_URL", "-")]
428 [Property("CRITERIA", "MR")]
429 [Property("COVPARAM", "")]
430 public void ThemeMergeIdAndVersionIsNull()
432 tlog.Debug(tag, $"ThemeMergeIdAndVersionIsNull START");
434 var testingTarget = new Theme();
435 Assert.IsNotNull(testingTarget, "should be not null");
436 Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
438 testingTarget.Merge(theme);
439 Assert.AreEqual(testingTarget.Id, theme.Id, "Should be equal!");
440 Assert.AreEqual(testingTarget.Version, theme.Version, "Should be equal!");
442 testingTarget = null;
443 tlog.Debug(tag, $"ThemeMergeIdAndVersionIsNull END (OK)");
448 [Description("test Theme HasSameIdAndVersion .")]
449 [Property("SPEC", "Tizen.NUI.Theme.HasSameIdAndVersion M")]
450 [Property("SPEC_URL", "-")]
451 [Property("CRITERIA", "MR")]
452 [Property("COVPARAM", "")]
453 public void ThemeHasSameIdAndVersion()
455 tlog.Debug(tag, $"ThemeHasSameIdAndVersion START");
457 var result = theme.HasSameIdAndVersion("Tizen.NUI.Theme.Wearable", "1.0");
458 tlog.Debug(tag, "HasSameIdAndVersion : " + result);
460 tlog.Debug(tag, $"ThemeHasSameIdAndVersion END (OK)");