3 using NUnit.Framework.TUnit;
5 using Tizen.NUI.Components;
6 using Tizen.NUI.BaseComponents;
8 namespace Tizen.NUI.Components.Devel.Tests
10 using static Tizen.NUI.Components.StyleManager;
11 using tlog = Tizen.Log;
14 [Description("Utils/StyleManager")]
17 private const string tag = "NUITEST";
19 internal class FoodRadioButtonStyle : StyleBase
21 public ViewStyle MyGetViewStyle()
24 ButtonStyle style = new ButtonStyle
26 Icon = new ImageViewStyle
28 Size = new Size(48, 48),
29 Position = new Position(0, 0),
30 ResourceUrl = new StringSelector
32 Normal = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png",
33 Selected = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "arrow.png",
34 Disabled = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "button_9patch.png",
35 DisabledSelected = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png",
37 Opacity = new FloatSelector
42 DisabledSelected = 0.4f
54 tlog.Info(tag, "Init() is called!");
60 tlog.Info(tag, "Destroy() is called!");
63 //Todo: this causes BLOCK, should be fixed.
66 [Description("StyleManager Theme.")]
67 [Property("SPEC", "Tizen.NUI.Components.StyleManager.Theme A")]
68 [Property("SPEC_URL", "-")]
69 [Property("CRITERIA", "PRW")]
70 [Property("COVPARAM", "")]
71 [Property("AUTHOR", "guowei.wang@samsung.com")]
73 public void StyleManagerTheme()
75 tlog.Debug(tag, $"StyleManagerTheme START");
77 var testingTarget = StyleManager.Instance;
78 Assert.IsNotNull(testingTarget, "null handle");
79 Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
81 tlog.Debug(tag, "Theme : " + testingTarget.Theme);
83 Theme theme = new Theme()
88 testingTarget.Theme = theme.Id;
90 tlog.Debug(tag, $"StyleManagerTheme END (OK)");
95 [Description("StyleManager GetViewStyle.")]
96 [Property("SPEC", "Tizen.NUI.Components.StyleManager.GetViewStyle M")]
97 [Property("SPEC_URL", "-")]
98 [Property("CRITERIA", "MR")]
99 [Property("COVPARAM", "")]
100 [Property("AUTHOR", "guowei.wang@samsung.com")]
102 public void StyleManagerGetViewStyle()
104 tlog.Debug(tag, $"StyleManagerGetViewStyle START");
106 var testingTarget = StyleManager.Instance;
107 Assert.IsNotNull(testingTarget, "null handle");
108 Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
110 StyleManager.Instance.RegisterStyle("RadioButton", "Food", typeof(FoodRadioButtonStyle), true);
112 var result = testingTarget.GetViewStyle("RadioButton");
113 tlog.Debug(tag, "GetViewStyle : " + result);
115 tlog.Debug(tag, $"StyleManagerGetViewStyle END (OK)");
120 [Description("StyleManager GetViewStyle.")]
121 [Property("SPEC", "Tizen.NUI.Components.StyleManager.GetViewStyle M")]
122 [Property("SPEC_URL", "-")]
123 [Property("CRITERIA", "MR")]
124 [Property("COVPARAM", "")]
125 [Property("AUTHOR", "guowei.wang@samsung.com")]
127 public void StyleManagerGetViewStyleGetNullStyle()
129 tlog.Debug(tag, $"StyleManagerGetViewStyleGetNullStyle START");
131 var testingTarget = StyleManager.Instance;
132 Assert.IsNotNull(testingTarget, "null handle");
133 Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
136 var result = testingTarget.GetViewStyle(style);
137 tlog.Debug(tag, "GetViewStyle : " + result);
139 tlog.Debug(tag, $"StyleManagerGetViewStyleGetNullStyle END (OK)");
144 [Description("StyleManager RegisterComponentStyle.")]
145 [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterComponentStyle M")]
146 [Property("SPEC_URL", "-")]
147 [Property("CRITERIA", "MR")]
148 [Property("COVPARAM", "")]
149 [Property("AUTHOR", "guowei.wang@samsung.com")]
151 public void StyleManagerRegisterComponentStyle()
153 tlog.Debug(tag, $"StyleManagerRegisterComponentStyle START");
155 var testingTarget = StyleManager.Instance;
156 Assert.IsNotNull(testingTarget, "null handle");
157 Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
159 StyleManager.Instance.RegisterComponentStyle("RadioButton", typeof(RadioButton), typeof(FoodRadioButtonStyle));
161 var result = testingTarget.GetComponentStyle(typeof(RadioButton));
162 tlog.Debug(tag, "GetComponentStyle : " + result);
164 tlog.Debug(tag, $"StyleManagerRegisterComponentStyle END (OK)");
169 [Description("ThemeChangeEventArgs CurrentTheme.")]
170 [Property("SPEC", "Tizen.NUI.Components.ThemeChangeEventArgs.CurrentTheme M")]
171 [Property("SPEC_URL", "-")]
172 [Property("CRITERIA", "MR")]
173 [Property("COVPARAM", "")]
174 [Property("AUTHOR", "guowei.wang@samsung.com")]
176 public void ThemeChangeEventArgsCurrentTheme()
178 tlog.Debug(tag, $"ThemeChangeEventArgsCurrentTheme START");
180 var testingTarget = new ThemeChangeEventArgs();
181 Assert.IsNotNull(testingTarget, "null handle");
182 Assert.IsInstanceOf<ThemeChangeEventArgs>(testingTarget, "Should return ThemeChangeEventArgs instance.");
184 testingTarget.CurrentTheme = "themeTest";
185 tlog.Debug(tag, "CurrentTheme : " + testingTarget.CurrentTheme);
187 tlog.Debug(tag, $"ThemeChangeEventArgsCurrentTheme END (OK)");
192 [Description("StyleManager RegisterStyle.")]
193 [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
194 [Property("SPEC_URL", "-")]
195 [Property("CRITERIA", "MR")]
196 [Property("COVPARAM", "")]
197 [Property("AUTHOR", "guowei.wang@samsung.com")]
199 public void StyleManagerRegisterStyle()
201 tlog.Debug(tag, $"StyleManagerRegisterComponentStyle START");
203 var testingTarget = StyleManager.Instance;
204 Assert.IsNotNull(testingTarget, "null handle");
205 Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
210 StyleManager.Instance.RegisterStyle(style, "Food", typeof(FoodRadioButtonStyle));
212 catch (InvalidOperationException)
214 tlog.Debug(tag, $"StyleManagerRegisterComponentStyle END (OK)");
215 Assert.Pass("Caught InvalidOperationException : Passed!");