1aefdaa205ec66c05b9354127093cb90ad885777
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Utils / TSStyleManager.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI;
5 using Tizen.NUI.Components;
6 using Tizen.NUI.BaseComponents;
7
8 namespace Tizen.NUI.Components.Devel.Tests
9 {
10     using static Tizen.NUI.Components.StyleManager;
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("Utils/StyleManager")]
15     class TSStyleManager
16     {
17         private const string tag = "NUITEST";
18
19         internal class FoodRadioButtonStyle : StyleBase
20         {
21             public ViewStyle MyGetViewStyle()
22             {
23                 base.GetViewStyle();
24                 ButtonStyle style = new ButtonStyle
25                 {
26                     Icon = new ImageViewStyle
27                     {
28                         Size = new Size(48, 48),
29                         Position = new Position(0, 0),
30                         ResourceUrl = new StringSelector
31                         {
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",
36                         },
37                         Opacity = new FloatSelector
38                         {
39                             Normal = 1.0f,
40                             Selected = 1.0f,
41                             Disabled = 0.4f,
42                             DisabledSelected = 0.4f
43                         },
44                     },
45                 };
46
47                 return style;
48             }
49         }
50
51         [SetUp]
52         public void Init()
53         {
54             tlog.Info(tag, "Init() is called!");
55         }
56
57         [TearDown]
58         public void Destroy()
59         {
60             tlog.Info(tag, "Destroy() is called!");
61         }
62
63         //Todo: this causes BLOCK, should be fixed.
64         //[Test]
65         [Category("P1")]
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")]
72         [Obsolete]
73         public void StyleManagerTheme()
74         {
75             tlog.Debug(tag, $"StyleManagerTheme START");
76
77             var testingTarget = StyleManager.Instance;
78             Assert.IsNotNull(testingTarget, "null handle");
79             Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
80
81             tlog.Debug(tag, "Theme : " + testingTarget.Theme);
82
83             Theme theme = new Theme()
84             {
85                 Id = "theme",
86                 Version = "1.0",
87             };
88             testingTarget.Theme = theme.Id;
89
90             tlog.Debug(tag, $"StyleManagerTheme END (OK)");
91         }
92
93         [Test]
94         [Category("P1")]
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")]
101         [Obsolete]
102         public void StyleManagerGetViewStyle()
103         {
104             tlog.Debug(tag, $"StyleManagerGetViewStyle START");
105
106             var testingTarget = StyleManager.Instance;
107             Assert.IsNotNull(testingTarget, "null handle");
108             Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
109
110             StyleManager.Instance.RegisterStyle("RadioButton", "Food", typeof(FoodRadioButtonStyle), true);
111
112             var result = testingTarget.GetViewStyle("RadioButton");
113             tlog.Debug(tag, "GetViewStyle : " + result);
114
115             tlog.Debug(tag, $"StyleManagerGetViewStyle END (OK)");
116         }
117
118         [Test]
119         [Category("P2")]
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")]
126         [Obsolete]
127         public void StyleManagerGetViewStyleGetNullStyle()
128         {
129             tlog.Debug(tag, $"StyleManagerGetViewStyleGetNullStyle START");
130
131             var testingTarget = StyleManager.Instance;
132             Assert.IsNotNull(testingTarget, "null handle");
133             Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
134
135             string style = null;
136             var result = testingTarget.GetViewStyle(style);
137             tlog.Debug(tag, "GetViewStyle : " + result);
138
139             tlog.Debug(tag, $"StyleManagerGetViewStyleGetNullStyle END (OK)");
140         }
141
142         [Test]
143         [Category("P1")]
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")]
150         [Obsolete]
151         public void StyleManagerRegisterComponentStyle()
152         {
153             tlog.Debug(tag, $"StyleManagerRegisterComponentStyle START");
154
155             var testingTarget = StyleManager.Instance;
156             Assert.IsNotNull(testingTarget, "null handle");
157             Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
158
159             StyleManager.Instance.RegisterComponentStyle("RadioButton", typeof(RadioButton), typeof(FoodRadioButtonStyle));
160
161             var result = testingTarget.GetComponentStyle(typeof(RadioButton));
162             tlog.Debug(tag, "GetComponentStyle : " + result);
163
164             tlog.Debug(tag, $"StyleManagerRegisterComponentStyle END (OK)");
165         }
166
167         [Test]
168         [Category("P1")]
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")]
175         [Obsolete]
176         public void ThemeChangeEventArgsCurrentTheme()
177         {
178             tlog.Debug(tag, $"ThemeChangeEventArgsCurrentTheme START");
179
180             var testingTarget = new ThemeChangeEventArgs();
181             Assert.IsNotNull(testingTarget, "null handle");
182             Assert.IsInstanceOf<ThemeChangeEventArgs>(testingTarget, "Should return ThemeChangeEventArgs instance.");
183
184             testingTarget.CurrentTheme = "themeTest";
185             tlog.Debug(tag, "CurrentTheme : " + testingTarget.CurrentTheme);
186
187             tlog.Debug(tag, $"ThemeChangeEventArgsCurrentTheme END (OK)");
188         }
189
190         [Test]
191         [Category("P2")]
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")]
198         [Obsolete]
199         public void StyleManagerRegisterStyle()
200         {
201             tlog.Debug(tag, $"StyleManagerRegisterComponentStyle START");
202
203             var testingTarget = StyleManager.Instance;
204             Assert.IsNotNull(testingTarget, "null handle");
205             Assert.IsInstanceOf<StyleManager>(testingTarget, "Should return StyleManager instance.");
206
207             try
208             {
209                 string style = null;
210                 StyleManager.Instance.RegisterStyle(style, "Food", typeof(FoodRadioButtonStyle));
211             }
212             catch (InvalidOperationException)
213             {
214                 tlog.Debug(tag, $"StyleManagerRegisterComponentStyle END (OK)");
215                 Assert.Pass("Caught InvalidOperationException :  Passed!");
216             } 
217         }
218     }
219 }