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/Style/Selector")]
14 public class PublicSelectorTest
16 private const string tag = "NUITEST";
21 tlog.Info(tag, "Init() is called!");
27 tlog.Info(tag, "Destroy() is called!");
32 [Description("Selector Add.")]
33 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.Add M")]
34 [Property("SPEC_URL", "-")]
35 [Property("CRITERIA", "PRW")]
36 [Property("AUTHOR", "guowei.wang@samsung.com")]
37 public void SelectorAddSelectorItem()
39 tlog.Debug(tag, $"SelectorAddSelectorItem START");
41 Selector<Color> colors = new Selector<Color>();
43 SelectorItem<Color> item = new SelectorItem<Color>();
44 item.Value = Color.White;
45 item.State = ControlState.All;
48 // if item be added, remove if first
51 colors.GetValue(ControlState.All, out Color color);
52 tlog.Debug(tag, "color : " + color);
54 tlog.Debug(tag, "Count :" + colors.Count);
55 tlog.Debug(tag, "IsReadOnly :" + colors.IsReadOnly);
57 var result = colors.Contains(item);
58 Assert.AreEqual(true, result, "Should be equal!");
62 colors.GetEnumerator();
66 tlog.Debug(tag, e.Message.ToString());
67 Assert.Fail("Caught Exception : Failed!");
70 result = colors.Remove(item);
71 Assert.AreEqual(true, result, "Should be equal!");
73 tlog.Debug(tag, $"SelectorAddSelectorItem END (OK)");
78 [Description("Selector Add.")]
79 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.Add M")]
80 [Property("SPEC_URL", "-")]
81 [Property("CRITERIA", "PRW")]
82 [Property("AUTHOR", "guowei.wang@samsung.com")]
83 public void SelectorAddNullSelectorItem()
85 tlog.Debug(tag, $"SelectorAddNullSelectorItem START");
87 Selector<Color> colors = new Selector<Color>();
89 SelectorItem<Color> item = null;
95 catch (ArgumentNullException)
97 tlog.Debug(tag, $"SelectorAddNullSelectorItem END (OK)");
98 Assert.Pass("Caught ArgumentNullException : Passed!");
104 [Description("Selector Contains.")]
105 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.Contains M")]
106 [Property("SPEC_URL", "-")]
107 [Property("CRITERIA", "PRW")]
108 [Property("AUTHOR", "guowei.wang@samsung.com")]
109 public void SelectorContainsNullSelectorItem()
111 tlog.Debug(tag, $"SelectorContainsNullSelectorItem START");
113 Selector<Color> colors = new Selector<Color>();
115 SelectorItem<Color> item = null;
119 colors.Contains(item);
121 catch (ArgumentNullException)
123 tlog.Debug(tag, $"SelectorContainsNullSelectorItem END (OK)");
124 Assert.Pass("Caught ArgumentNullException : Passed!");
130 [Description("SelectorExtensions Add.")]
131 [Property("SPEC", "Tizen.NUI.BaseComponents.SelectorExtensions.Add M")]
132 [Property("SPEC_URL", "-")]
133 [Property("CRITERIA", "PRW")]
134 [Property("AUTHOR", "guowei.wang@samsung.com")]
135 public void SelectorExtensionsAdd()
137 tlog.Debug(tag, $"SelectorExtensionsAdd START");
139 Selector<Color> colors = new Selector<Color>();
141 IList<SelectorItem<Color>> list = new List<SelectorItem<Color>>();
143 var item = new SelectorItem<Color>()
146 State = ControlState.All
153 SelectorExtensions.Add(list, ControlState.All, Color.White);
157 tlog.Debug(tag, e.Message.ToString());
158 Assert.Fail("Caught Exception : Failed!");
161 tlog.Debug(tag, $"SelectorExtensionsAdd END (OK)");
166 [Description("SelectorExtensions Add.")]
167 [Property("SPEC", "Tizen.NUI.BaseComponents.SelectorExtensions.Add M")]
168 [Property("SPEC_URL", "-")]
169 [Property("CRITERIA", "PRW")]
170 [Property("AUTHOR", "guowei.wang@samsung.com")]
171 public void SelectorExtensionsAddWithNullList()
173 tlog.Debug(tag, $"SelectorExtensionsAddWithNullList START");
175 Selector<Color> colors = new Selector<Color>();
177 IList<SelectorItem<Color>> list = null;
181 SelectorExtensions.Add(list, ControlState.All, Color.White);
183 catch (ArgumentNullException)
185 tlog.Debug(tag, $"SelectorExtensionsAddWithNullList END (OK)");
186 Assert.Pass("Caught ArgumentNullException : Passed!");
192 [Description("Selector GetHashCode.")]
193 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.GetHashCode M")]
194 [Property("SPEC_URL", "-")]
195 [Property("CRITERIA", "PRW")]
196 [Property("AUTHOR", "guowei.wang@samsung.com")]
197 public void SelectorGetHashCode()
199 tlog.Debug(tag, $"SelectorGetHashCode START");
201 Selector<Color> colors = new Selector<Color>();
203 SelectorItem<Color> item = new SelectorItem<Color>();
204 item.Value = Color.White;
205 item.State = ControlState.All;
208 var result = colors.GetHashCode();
209 tlog.Debug(tag, "HashCode : " + result);
211 tlog.Debug(tag, $"SelectorGetHashCode END (OK)");
216 [Description("Selector Equals.")]
217 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.Equals M")]
218 [Property("SPEC_URL", "-")]
219 [Property("CRITERIA", "PRW")]
220 [Property("AUTHOR", "guowei.wang@samsung.com")]
221 public void SelectorEquals()
223 tlog.Debug(tag, $"SelectorEquals START");
225 Selector<Color> colors = new Selector<Color>();
227 SelectorItem<Color> item = new SelectorItem<Color>();
228 item.Value = Color.White;
229 item.State = ControlState.All;
232 Selector<Color> dummy1 = new Selector<Color>(Color.Cyan);
233 Selector<string> dummy2 = new Selector<string>("mytest");
235 var result = colors.Equals(dummy1);
236 tlog.Debug(tag, "Equals : " + result);
238 result = colors.Equals(dummy2);
239 tlog.Debug(tag, "Equals : " + result);
241 tlog.Debug(tag, $"SelectorEquals END (OK)");
246 [Description("Selector ToString.")]
247 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.ToString M")]
248 [Property("SPEC_URL", "-")]
249 [Property("CRITERIA", "PRW")]
250 [Property("AUTHOR", "guowei.wang@samsung.com")]
251 public void SelectorToString()
253 tlog.Debug(tag, $"SelectorToString START");
255 var testingTarget = new Selector<Color>(Color.Cyan);
256 Assert.IsNotNull(testingTarget, "Can't create success object RenderTask.");
257 Assert.IsInstanceOf<Selector<Color>>(testingTarget, "Should return Selector<Color> instance.");
259 var result = testingTarget.ToString();
260 tlog.Debug(tag, "ToString : " + result);
262 tlog.Debug(tag, $"SelectorToString END (OK)");
267 [Description("Selector CopyTo.")]
268 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.CopyTo M")]
269 [Property("SPEC_URL", "-")]
270 [Property("CRITERIA", "PRW")]
271 [Property("AUTHOR", "guowei.wang@samsung.com")]
272 public void SelectorCopyTo()
274 tlog.Debug(tag, $"SelectorCopyTo START");
276 var testingTarget = new Selector<Color>(Color.Cyan);
277 Assert.IsNotNull(testingTarget, "Can't create success object RenderTask.");
278 Assert.IsInstanceOf<Selector<Color>>(testingTarget, "Should return Selector<Color> instance.");
280 SelectorItem<Color>[] item = new SelectorItem<Color>[2];
281 item[0] = new SelectorItem<Color>();
282 item[0].Value = Color.Cyan;
283 item[0].State = ControlState.All;
285 item[1] = new SelectorItem<Color>();
286 item[1].Value = Color.Yellow;
287 item[1].State = ControlState.Normal;
291 testingTarget.CopyTo(item, 0);
295 tlog.Debug(tag, e.Message.ToString());
296 Assert.Fail("Caught Exception : Failed!" );
299 tlog.Debug(tag, $"SelectorCopyTo END (OK)");
304 [Description("Selector GetValue.")]
305 [Property("SPEC", "Tizen.NUI.BaseComponents.Selector.GetValue M")]
306 [Property("SPEC_URL", "-")]
307 [Property("CRITERIA", "PRW")]
308 [Property("AUTHOR", "guowei.wang@samsung.com")]
309 public void SelectorGetValue()
311 tlog.Debug(tag, $"SelectorGetValue START");
313 var testingTarget = new Selector<Color>();
314 Assert.IsNotNull(testingTarget, "Can't create success object RenderTask.");
315 Assert.IsInstanceOf<Selector<Color>>(testingTarget, "Should return Selector<Color> instance.");
317 SelectorItem<Color>[] item = new SelectorItem<Color>[2];
318 item[0] = new SelectorItem<Color>();
319 item[0].Value = Color.Cyan;
320 item[0].State = ControlState.All;
322 item[1] = new SelectorItem<Color>();
323 item[1].Value = Color.Yellow;
324 item[1].State = ControlState.Normal;
326 testingTarget.CopyTo(item, 0);
327 testingTarget.GetValue(ControlState.Normal, out Color color);
328 tlog.Debug(tag, "color : " + color);
330 tlog.Debug(tag, $"SelectorGetValue END (OK)");