3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
8 namespace Tizen.NUI.Devel.Tests
10 using tlog = Tizen.Log;
13 [Description("public/BaseComponents/ControlState")]
14 public class PublicControlStateTest
16 private const string tag = "NUITEST";
21 tlog.Info(tag, "Init() is called!");
27 tlog.Info(tag, "Destroy() is called!");
32 [Description("ControlState Create. Parameter is null.")]
33 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
34 [Property("SPEC_URL", "-")]
35 [Property("CRITERIA", "MR")]
36 [Property("AUTHOR", "guowei.wang@samsung.com")]
37 public void ControlStateCreateWithNullString()
39 tlog.Debug(tag, $"ControlStateCreateWithNullString START");
44 ControlState.Create(str);
46 catch (ArgumentNullException e)
48 tlog.Debug(tag, e.Message.ToString());
49 tlog.Debug(tag, $"ControlStateCreateWithNullString END (OK)");
50 Assert.Pass("Caught ArgumentNullException: Passed!");
56 [Description("ControlState Create. Parameter is empty.")]
57 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
58 [Property("SPEC_URL", "-")]
59 [Property("CRITERIA", "MR")]
60 [Property("AUTHOR", "guowei.wang@samsung.com")]
61 public void ControlStateCreateWithEmptyString()
63 tlog.Debug(tag, $"ControlStateCreateWithEmptyString START");
68 ControlState.Create(str);
70 catch (ArgumentException e)
72 tlog.Debug(tag, e.Message.ToString());
73 tlog.Debug(tag, $"ControlStateCreateWithEmptyString END (OK)");
74 Assert.Pass("Caught ArgumentException: Passed!");
80 [Description("ControlState Create. State is added.")]
81 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
82 [Property("SPEC_URL", "-")]
83 [Property("CRITERIA", "MR")]
84 [Property("AUTHOR", "guowei.wang@samsung.com")]
85 public void ControlStateCreateWithAddedState()
87 tlog.Debug(tag, $"ControlStateCreateWithAddedState START");
89 var testingTarget = ControlState.Create("Focused");
90 Assert.IsNotNull(testingTarget);
91 Assert.AreEqual(ControlState.Focused, testingTarget, "Should be equal!");
93 tlog.Debug(tag, $"ControlStateCreateWithAddedState END (OK)");
98 [Description("ControlState Create. StateList length is 0.")]
99 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
100 [Property("SPEC_URL", "-")]
101 [Property("CRITERIA", "MR")]
102 [Property("AUTHOR", "guowei.wang@samsung.com")]
103 public void ControlStateCreateStateListLengthEqualZero()
105 tlog.Debug(tag, $"ControlStateCreateStateListLengthEqualZero START");
107 ControlState[] states = new ControlState[0];
108 var testingTarget = ControlState.Create(states);
109 Assert.IsNotNull(testingTarget);
110 Assert.AreEqual("Normal", testingTarget.ToString(), "Should be equal!");
112 tlog.Debug(tag, $"ControlStateCreateStateListLengthEqualZero END (OK)");
117 [Description("ControlState Create. StateList length is 1.")]
118 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
119 [Property("SPEC_URL", "-")]
120 [Property("CRITERIA", "MR")]
121 [Property("AUTHOR", "guowei.wang@samsung.com")]
122 public void ControlStateCreateStateListLengthEqualOne()
124 tlog.Debug(tag, $"ControlStateCreateStateListLengthEqualOne START");
126 ControlState[] states = new ControlState[1];
127 states[0] = ControlState.Other;
128 var testingTarget = ControlState.Create(states);
129 Assert.IsNotNull(testingTarget);
130 Assert.AreEqual("Other", testingTarget.ToString(), "Should be equal!");
132 tlog.Debug(tag, $"ControlStateCreateStateListLengthEqualOne END (OK)");
137 [Description("ControlState Create. StateList length greater than 1.")]
138 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
139 [Property("SPEC_URL", "-")]
140 [Property("CRITERIA", "MR")]
141 [Property("AUTHOR", "guowei.wang@samsung.com")]
142 public void ControlStateCreateStateListLengthGreaterThanOne()
144 tlog.Debug(tag, $"ControlStateCreateStateListLengthGreaterThanOne START");
146 ControlState[] states = new ControlState[5];
147 states[0] = ControlState.Normal;
148 states[1] = ControlState.Selected;
149 states[2] = ControlState.Focused;
150 states[3] = ControlState.Pressed;
151 states[4] = ControlState.Disabled;
152 var testingTarget = ControlState.Create(states);
153 Assert.IsNotNull(testingTarget);
154 Assert.AreEqual("Selected, Focused, Pressed, Disabled", testingTarget.ToString(), "Should be equal!");
156 tlog.Debug(tag, $"ControlStateCreateStateListLengthGreaterThanOne END (OK)");
161 [Description("ControlState Create. StateList contain All.")]
162 [Property("SPEC", "Tizen.NUI.ControlState.Create M")]
163 [Property("SPEC_URL", "-")]
164 [Property("CRITERIA", "MR")]
165 [Property("AUTHOR", "guowei.wang@samsung.com")]
166 public void ControlStateCreateStateListContainAll()
168 tlog.Debug(tag, $"ControlStateCreateStateListContainAll START");
170 ControlState[] states = new ControlState[5];
171 states[0] = ControlState.Normal;
172 states[1] = ControlState.Selected;
173 states[2] = ControlState.All;
174 states[3] = ControlState.Pressed;
175 states[4] = ControlState.Disabled;
176 var testingTarget = ControlState.Create(states);
177 Assert.IsNotNull(testingTarget);
178 Assert.AreEqual("All", testingTarget.ToString(), "Should be equal!");
180 tlog.Debug(tag, $"ControlStateCreateStateListContainAll END (OK)");
185 [Description("ControlState Contains.")]
186 [Property("SPEC", "Tizen.NUI.ControlState.Contains M")]
187 [Property("SPEC_URL", "-")]
188 [Property("CRITERIA", "MR")]
189 [Property("AUTHOR", "guowei.wang@samsung.com")]
190 public void ControlStateContains()
192 tlog.Debug(tag, $"ControlStateContains START");
194 ControlState[] states = new ControlState[5];
195 states[0] = ControlState.Normal;
196 states[1] = ControlState.Selected;
197 states[2] = ControlState.Focused;
198 states[3] = ControlState.Pressed;
199 states[4] = ControlState.Disabled;
200 var testingTarget = ControlState.Create(states);
202 Assert.AreEqual(false, testingTarget.Contains(ControlState.All), "Should be equal!");
203 Assert.AreEqual(true, testingTarget.Contains(ControlState.Selected), "Should be equal!");
205 tlog.Debug(tag, $"ControlStateContains END (OK)");
210 [Description("ControlState Contains. IsCombined is false.")]
211 [Property("SPEC", "Tizen.NUI.ControlState.Contains M")]
212 [Property("SPEC_URL", "-")]
213 [Property("CRITERIA", "MR")]
214 [Property("AUTHOR", "guowei.wang@samsung.com")]
215 public void ControlStateContainsWithFalseIsCombined()
217 tlog.Debug(tag, $"ControlStateContainsWithFalseIsCombined START");
219 ControlState[] states = new ControlState[1];
220 states[0] = ControlState.Normal;
221 var testingTarget = ControlState.Create(states);
223 Assert.AreEqual(true, testingTarget.Contains(ControlState.Normal), "Should be equal!");
225 tlog.Debug(tag, $"ControlStateContainsWithFalseIsCombined END (OK)");
230 [Description("ControlState Contains. State is null.")]
231 [Property("SPEC", "Tizen.NUI.ControlState.Contains M")]
232 [Property("SPEC_URL", "-")]
233 [Property("CRITERIA", "MR")]
234 [Property("AUTHOR", "guowei.wang@samsung.com")]
235 public void ControlStateContainsWithNullState()
237 tlog.Debug(tag, $"ControlStateContainsWithNullState START");
239 ControlState state = ControlState.Create("Focused");
243 state.Contains(null);
245 catch (ArgumentNullException e)
247 tlog.Debug(tag, e.Message.ToString());
248 tlog.Debug(tag, $"ControlStateContainsWithNullState END (OK)");
249 Assert.Pass("Caught ArgumentNullException: Passed!");
255 [Description("ControlState ==. Both null.")]
256 [Property("SPEC", "Tizen.NUI.ControlState.== M")]
257 [Property("SPEC_URL", "-")]
258 [Property("CRITERIA", "MR")]
259 [Property("AUTHOR", "guowei.wang@samsung.com")]
260 public void ControlStateEquivalentWithBothNullVaule()
262 tlog.Debug(tag, $"ControlStateEquivalentWithBothNullVaule START");
264 Assert.True(null == null);
266 tlog.Debug(tag, $"ControlStateEquivalentWithBothNullVaule END (OK)");
271 [Description("ControlState ==. Right null.")]
272 [Property("SPEC", "Tizen.NUI.ControlState.== M")]
273 [Property("SPEC_URL", "-")]
274 [Property("CRITERIA", "MR")]
275 [Property("AUTHOR", "guowei.wang@samsung.com")]
276 public void ControlStateEquivalentWithOneNullValue()
278 tlog.Debug(tag, $"ControlStateEquivalentWithOneNullValue START");
280 Assert.False(null == ControlState.Focused);
281 Assert.True(null != ControlState.Focused);
283 tlog.Debug(tag, $"ControlStateEquivalentWithOneNullValue END (OK)");
288 [Description("ControlState subtraction.")]
289 [Property("SPEC", "Tizen.NUI.ControlState.- M")]
290 [Property("SPEC_URL", "-")]
291 [Property("CRITERIA", "MR")]
292 [Property("AUTHOR", "guowei.wang@samsung.com")]
293 public void ControlStateSubtraction()
295 tlog.Debug(tag, $"ControlStateSubtraction START");
297 var result = ControlState.Focused - ControlState.Focused;
298 Assert.AreEqual("Normal", result.ToString(), "Should be equal!");
300 result = ControlState.Focused - ControlState.Pressed;
301 Assert.AreEqual("Focused", result.ToString(), "Should be equal!");
303 tlog.Debug(tag, $"ControlStateSubtraction END (OK)");
308 [Description("ControlState subtraction. IsCombined")]
309 [Property("SPEC", "Tizen.NUI.ControlState.- M")]
310 [Property("SPEC_URL", "-")]
311 [Property("CRITERIA", "MR")]
312 [Property("AUTHOR", "guowei.wang@samsung.com")]
313 public void ControlStateSubtractionWithTrueIsCombined()
315 tlog.Debug(tag, $"ControlStateSubtractionWithTrueIsCombined START");
317 ControlState[] states1 = new ControlState[2];
318 states1[0] = ControlState.Selected;
319 states1[1] = ControlState.Focused;
320 var testingTarget1 = ControlState.Create(states1);
322 ControlState[] states2 = new ControlState[2];
323 states2[0] = ControlState.Pressed;
324 states2[1] = ControlState.Focused;
325 var testingTarget2 = ControlState.Create(states2);
327 var result = testingTarget1 - testingTarget2;
328 Assert.AreEqual("Selected", result.ToString(), "Should be equal!");
330 ControlState[] states3 = new ControlState[2];
331 states3[0] = ControlState.Selected;
332 states3[1] = ControlState.Focused;
333 var testingTarget3 = ControlState.Create(states3);
335 ControlState[] states4 = new ControlState[2];
336 states4[0] = ControlState.Pressed;
337 states4[1] = ControlState.Disabled;
338 var testingTarget4 = ControlState.Create(states4);
340 result = testingTarget3 - testingTarget4;
341 Assert.AreEqual("Selected, Focused", result.ToString(), "Should be equal!");
343 tlog.Debug(tag, $"ControlStateSubtractionWithTrueIsCombined END (OK)");
348 [Description("ControlState subtraction. lhs is null.")]
349 [Property("SPEC", "Tizen.NUI.ControlState.- M")]
350 [Property("SPEC_URL", "-")]
351 [Property("CRITERIA", "MR")]
352 [Property("AUTHOR", "guowei.wang@samsung.com")]
353 public void ControlStateSubtractionWithNullFirstParameter()
355 tlog.Debug(tag, $"ControlStateSubtractionWithNullFirstParameter START");
359 var result = null - ControlState.Normal;
361 catch (ArgumentNullException e)
363 tlog.Debug(tag, e.Message.ToString());
364 tlog.Debug(tag, $"ControlStateSubtractionWithNullFirstParameter END (OK)");
365 Assert.Pass("Caught ArgumentNullException: Passed!");
371 [Description("ControlState subtraction. rhs is null.")]
372 [Property("SPEC", "Tizen.NUI.ControlState.- M")]
373 [Property("SPEC_URL", "-")]
374 [Property("CRITERIA", "MR")]
375 [Property("AUTHOR", "guowei.wang@samsung.com")]
376 public void ControlStateSubtractionWithNullSecondParameter()
378 tlog.Debug(tag, $"ControlStateSubtractionWithNullSecondParameter START");
382 var result = ControlState.Normal - null;
384 catch (ArgumentNullException e)
386 tlog.Debug(tag, e.Message.ToString());
387 tlog.Debug(tag, $"ControlStateSubtractionWithNullSecondParameter END (OK)");
388 Assert.Pass("Caught ArgumentNullException: Passed!");