[NUI] Add TCs for NUI.Components.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / TSTab.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.Tab;
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("Controls/Tab")]
15     public class TabTest
16     {
17         private const string tag = "NUITEST";
18
19         [Obsolete]
20         internal class MyTab : Tab
21         {
22             public MyTab() : base()
23             { }
24
25             public void MyOnUpdate()
26             {
27                 base.OnUpdate();
28             }
29         }
30
31         [SetUp]
32         public void Init()
33         {
34             tlog.Info(tag, "Init() is called!");
35         }
36
37         [TearDown]
38         public void Destroy()
39         {
40             tlog.Info(tag, "Destroy() is called!");
41         }
42
43         [Test]
44         [Category("P1")]
45         [Description("Tab contructor.")]
46         [Property("SPEC", "Tizen.NUI.Components.Tab.Tab C")]
47         [Property("SPEC_URL", "-")]
48         [Property("CRITERIA", "CONSTR")]
49         [Property("COVPARAM", "")]
50         [Property("AUTHOR", "guowei.wang@samsung.com")]
51         [Obsolete]
52         public void TabContructor()
53         {
54             tlog.Debug(tag, $"TabContructor START");
55
56             var testingTarget = new Tab();
57             Assert.IsNotNull(testingTarget, "null handle");
58             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
59
60             testingTarget.Dispose();
61             tlog.Debug(tag, $"TabContructor END (OK)");
62         }
63
64         [Test]
65         [Category("P1")]
66         [Description("Tab contructor.")]
67         [Property("SPEC", "Tizen.NUI.Components.Tab.Tab C")]
68         [Property("SPEC_URL", "-")]
69         [Property("CRITERIA", "CONSTR")]
70         [Property("COVPARAM", "")]
71         [Property("AUTHOR", "guowei.wang@samsung.com")]
72         [Obsolete]
73         public void TabContructorWithTabStyle()
74         {
75             tlog.Debug(tag, $"TabContructorWithTabStyle START");
76
77             TabStyle style = new TabStyle()
78             { 
79                 Size = new Size(100, 200),
80             };
81
82             var testingTarget = new Tab(style);
83             Assert.IsNotNull(testingTarget, "null handle");
84             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
85
86             testingTarget.Dispose();
87             tlog.Debug(tag, $"TabContructorWithTabStyle END (OK)");
88         }
89
90         [Test]
91         [Category("P1")]
92         [Description("Tab Underline.")]
93         [Property("SPEC", "Tizen.NUI.Components.Tab.Underline A")]
94         [Property("SPEC_URL", "-")]
95         [Property("CRITERIA", "PRW")]
96         [Property("COVPARAM", "")]
97         [Property("AUTHOR", "guowei.wang@samsung.com")]
98         [Obsolete]
99         public void TabUnderline()
100         {
101             tlog.Debug(tag, $"TabUnderline START");
102
103             using (View view = new View() { Size = new Size(2, 20) })
104             {
105                 var testingTarget = new Tab();
106                 Assert.IsNotNull(testingTarget, "null handle");
107                 Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
108
109                 testingTarget.Underline = view;
110                 tlog.Debug(tag, "Underline : " + testingTarget.Underline);
111
112                 testingTarget.Dispose();
113             }
114
115             tlog.Debug(tag, $"TabUnderline END (OK)");
116         }
117
118         [Test]
119         [Category("P1")]
120         [Description("Tab SelectedItemIndex.")]
121         [Property("SPEC", "Tizen.NUI.Components.Tab.SelectedItemIndex A")]
122         [Property("SPEC_URL", "-")]
123         [Property("CRITERIA", "PRW")]
124         [Property("COVPARAM", "")]
125         [Property("AUTHOR", "guowei.wang@samsung.com")]
126         [Obsolete]
127         public void TabSelectedItemIndex()
128         {
129             tlog.Debug(tag, $"TabSelectedItemIndex START");
130
131             var testingTarget = new Tab();
132             Assert.IsNotNull(testingTarget, "null handle");
133             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
134
135             testingTarget.SelectedItemIndex = 1;
136             tlog.Debug(tag, "SelectedItemIndex : " + testingTarget.SelectedItemIndex);
137
138             testingTarget.Dispose();
139             tlog.Debug(tag, $"TabSelectedItemIndex END (OK)");
140         }
141
142         [Test]
143         [Category("P1")]
144         [Description("Tab UseTextNaturalSize.")]
145         [Property("SPEC", "Tizen.NUI.Components.Tab.UseTextNaturalSize A")]
146         [Property("SPEC_URL", "-")]
147         [Property("CRITERIA", "PRW")]
148         [Property("COVPARAM", "")]
149         [Property("AUTHOR", "guowei.wang@samsung.com")]
150         [Obsolete]
151         public void TabUseTextNaturalSize()
152         {
153             tlog.Debug(tag, $"TabUseTextNaturalSize START");
154
155             var testingTarget = new Tab();
156             Assert.IsNotNull(testingTarget, "null handle");
157             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
158
159             testingTarget.UseTextNaturalSize = true;
160             tlog.Debug(tag, "UseTextNaturalSize : " + testingTarget.UseTextNaturalSize);
161
162             testingTarget.UseTextNaturalSize = false;
163             tlog.Debug(tag, "UseTextNaturalSize : " + testingTarget.UseTextNaturalSize);
164
165             testingTarget.Dispose();
166             tlog.Debug(tag, $"TabUseTextNaturalSize END (OK)");
167         }
168
169         [Test]
170         [Category("P1")]
171         [Description("Tab ItemSpace.")]
172         [Property("SPEC", "Tizen.NUI.Components.Tab.ItemSpace A")]
173         [Property("SPEC_URL", "-")]
174         [Property("CRITERIA", "PRW")]
175         [Property("COVPARAM", "")]
176         [Property("AUTHOR", "guowei.wang@samsung.com")]
177         [Obsolete]
178         public void TabItemSpace()
179         {
180             tlog.Debug(tag, $"TabItemSpace START");
181
182             var testingTarget = new Tab();
183             Assert.IsNotNull(testingTarget, "null handle");
184             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
185
186             testingTarget.ItemSpace = 10;
187             tlog.Debug(tag, "ItemSpace : " + testingTarget.ItemSpace);
188
189             testingTarget.Dispose();
190             tlog.Debug(tag, $"TabItemSpace END (OK)");
191         }
192
193         [Test]
194         [Category("P1")]
195         [Description("Tab Space.")]
196         [Property("SPEC", "Tizen.NUI.Components.Tab.Space A")]
197         [Property("SPEC_URL", "-")]
198         [Property("CRITERIA", "PRW")]
199         [Property("COVPARAM", "")]
200         [Property("AUTHOR", "guowei.wang@samsung.com")]
201         [Obsolete]
202         public void TabSpace()
203         {
204             tlog.Debug(tag, $"TabSpace START");
205
206             var testingTarget = new Tab();
207             Assert.IsNotNull(testingTarget, "null handle");
208             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
209
210             testingTarget.Space = new Extents(4, 4, 4, 4);
211             tlog.Debug(tag, "Space : " + testingTarget.Space);
212
213             testingTarget.Dispose();
214             tlog.Debug(tag, $"TabSpace END (OK)");
215         }
216
217         [Test]
218         [Category("P1")]
219         [Description("Tab ItemPadding.")]
220         [Property("SPEC", "Tizen.NUI.Components.Tab.ItemPadding A")]
221         [Property("SPEC_URL", "-")]
222         [Property("CRITERIA", "PRW")]
223         [Property("COVPARAM", "")]
224         [Property("AUTHOR", "guowei.wang@samsung.com")]
225         [Obsolete]
226         public void TabItemPadding()
227         {
228             tlog.Debug(tag, $"TabItemPadding START");
229
230             var testingTarget = new Tab();
231             Assert.IsNotNull(testingTarget, "null handle");
232             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
233
234             testingTarget.ItemPadding = new Extents(4, 4, 4, 4);
235             tlog.Debug(tag, "ItemPadding : " + testingTarget.ItemPadding);
236
237             testingTarget.Dispose();
238             tlog.Debug(tag, $"TabItemPadding END (OK)");
239         }
240
241         [Test]
242         [Category("P1")]
243         [Description("Tab UnderLineSize.")]
244         [Property("SPEC", "Tizen.NUI.Components.Tab.UnderLineSize A")]
245         [Property("SPEC_URL", "-")]
246         [Property("CRITERIA", "PRW")]
247         [Property("COVPARAM", "")]
248         [Property("AUTHOR", "guowei.wang@samsung.com")]
249         [Obsolete]
250         public void TabUnderLineSize()
251         {
252             tlog.Debug(tag, $"TabUnderLineSize START");
253
254             var testingTarget = new Tab();
255             Assert.IsNotNull(testingTarget, "null handle");
256             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
257
258             testingTarget.UnderLineSize = new Size(10, 20);
259             tlog.Debug(tag, "UnderLineSize : " + testingTarget.UnderLineSize);
260
261             testingTarget.Dispose();
262             tlog.Debug(tag, $"TabUnderLineSize END (OK)");
263         }
264
265         [Test]
266         [Category("P1")]
267         [Description("Tab UnderLineBackgroundColor.")]
268         [Property("SPEC", "Tizen.NUI.Components.Tab.UnderLineBackgroundColor A")]
269         [Property("SPEC_URL", "-")]
270         [Property("CRITERIA", "PRW")]
271         [Property("COVPARAM", "")]
272         [Property("AUTHOR", "guowei.wang@samsung.com")]
273         [Obsolete]
274         public void TabUnderLineBackgroundColor()
275         {
276             tlog.Debug(tag, $"TabUnderLineBackgroundColor START");
277
278             var testingTarget = new Tab();
279             Assert.IsNotNull(testingTarget, "null handle");
280             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
281
282             testingTarget.UnderLineBackgroundColor = Color.Red;
283             tlog.Debug(tag, "UnderLineBackgroundColor : " + testingTarget.UnderLineBackgroundColor);
284
285             testingTarget.Dispose();
286             tlog.Debug(tag, $"TabUnderLineBackgroundColor END (OK)");
287         }
288
289         [Test]
290         [Category("P1")]
291         [Description("Tab PointSize.")]
292         [Property("SPEC", "Tizen.NUI.Components.Tab.PointSize A")]
293         [Property("SPEC_URL", "-")]
294         [Property("CRITERIA", "PRW")]
295         [Property("COVPARAM", "")]
296         [Property("AUTHOR", "guowei.wang@samsung.com")]
297         [Obsolete]
298         public void TabPointSize()
299         {
300             tlog.Debug(tag, $"TabPointSize START");
301
302             var testingTarget = new Tab();
303             Assert.IsNotNull(testingTarget, "null handle");
304             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
305
306             testingTarget.PointSize = 0.3f;
307             tlog.Debug(tag, "PointSize : " + testingTarget.PointSize);
308
309             testingTarget.Dispose();
310             tlog.Debug(tag, $"TabPointSize END (OK)");
311         }
312
313         [Test]
314         [Category("P1")]
315         [Description("Tab FontFamily.")]
316         [Property("SPEC", "Tizen.NUI.Components.Tab.FontFamily A")]
317         [Property("SPEC_URL", "-")]
318         [Property("CRITERIA", "PRW")]
319         [Property("COVPARAM", "")]
320         [Property("AUTHOR", "guowei.wang@samsung.com")]
321         [Obsolete]
322         public void TabFontFamily()
323         {
324             tlog.Debug(tag, $"TabFontFamily START");
325
326             var testingTarget = new Tab();
327             Assert.IsNotNull(testingTarget, "null handle");
328             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
329
330             testingTarget.FontFamily = "BreezeSans";
331             tlog.Debug(tag, "FontFamily : " + testingTarget.FontFamily);
332
333             testingTarget.Dispose();
334             tlog.Debug(tag, $"TabFontFamily END (OK)");
335         }
336
337         [Test]
338         [Category("P1")]
339         [Description("Tab TextColor.")]
340         [Property("SPEC", "Tizen.NUI.Components.Tab.TextColor A")]
341         [Property("SPEC_URL", "-")]
342         [Property("CRITERIA", "PRW")]
343         [Property("COVPARAM", "")]
344         [Property("AUTHOR", "guowei.wang@samsung.com")]
345         [Obsolete]
346         public void TabTextColor()
347         {
348             tlog.Debug(tag, $"TabTextColor START");
349
350             var testingTarget = new Tab();
351             Assert.IsNotNull(testingTarget, "null handle");
352             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
353
354             testingTarget.TextColor = Color.Green;
355             tlog.Debug(tag, "TextColor : " + testingTarget.TextColor);
356
357             testingTarget.Dispose();
358             tlog.Debug(tag, $"TabTextColor END (OK)");
359         }
360
361         [Test]
362         [Category("P1")]
363         [Description("Tab TextColorSelector.")]
364         [Property("SPEC", "Tizen.NUI.Components.Tab.TextColorSelector A")]
365         [Property("SPEC_URL", "-")]
366         [Property("CRITERIA", "PRW")]
367         [Property("COVPARAM", "")]
368         [Property("AUTHOR", "guowei.wang@samsung.com")]
369         [Obsolete]
370         public void TabTextColorSelector()
371         {
372             tlog.Debug(tag, $"TabTextColorSelector START");
373
374             var testingTarget = new Tab();
375             Assert.IsNotNull(testingTarget, "null handle");
376             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
377
378             var textColorSelector = new ColorSelector();
379             textColorSelector.Add(ControlState.All, Color.Cyan);
380             testingTarget.TextColorSelector = textColorSelector;
381             tlog.Debug(tag, "TextColorSelector : " + testingTarget.TextColorSelector);
382
383             testingTarget.Dispose();
384             tlog.Debug(tag, $"TabTextColorSelector END (OK)");
385         }
386
387         [Test]
388         [Category("P2")]
389         [Description("Tab TextColorSelector.")]
390         [Property("SPEC", "Tizen.NUI.Components.Tab.TextColorSelector A")]
391         [Property("SPEC_URL", "-")]
392         [Property("CRITERIA", "PRW")]
393         [Property("COVPARAM", "")]
394         [Property("AUTHOR", "guowei.wang@samsung.com")]
395         [Obsolete]
396         public void TabTextColorSelectorNullReferenceException()
397         {
398             tlog.Debug(tag, $"TabTextColorSelectorNullReferenceException START");
399
400             var testingTarget = new Tab();
401             Assert.IsNotNull(testingTarget, "null handle");
402             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
403
404             try
405             {
406                 ColorSelector textColorSelector = null;
407                 testingTarget.TextColorSelector = textColorSelector;
408             }
409             catch (NullReferenceException)
410             {
411                 testingTarget.Dispose();
412                 tlog.Debug(tag, $"TabTextColorSelectorNullReferenceException END (OK)");
413                 Assert.Pass("Caught NullReferenceException :  Passed!");
414             }
415         }
416
417         [Test]
418         [Category("P1")]
419         [Description("Tab AddItem.")]
420         [Property("SPEC", "Tizen.NUI.Components.Tab.AddItem M")]
421         [Property("SPEC_URL", "-")]
422         [Property("CRITERIA", "MR")]
423         [Property("COVPARAM", "")]
424         [Property("AUTHOR", "guowei.wang@samsung.com")]
425         [Obsolete]
426         public void TabAddItem()
427         {
428             tlog.Debug(tag, $"TabAddItem START");
429
430             var testingTarget = new Tab();
431             Assert.IsNotNull(testingTarget, "null handle");
432             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
433
434             try
435             {
436                 TabItemData item1 = new TabItemData();
437                 testingTarget.AddItem(item1);
438                 TabItemData item2 = new TabItemData();
439                 testingTarget.InsertItem(item2, 1);
440
441                 testingTarget.SelectedItemIndex = 1;
442
443                 try
444                 {
445                     testingTarget.DeleteItem(0);
446                 }
447                 catch (Exception e)
448                 {
449                     tlog.Debug(tag, e.Message.ToString());
450                     Assert.Fail("Caught Exception : Failed!");
451                 }
452             }
453             catch (Exception e)
454             {
455                 tlog.Debug(tag, e.Message.ToString());
456                 Assert.Fail("Caught Exception : Failed!");
457             }
458             
459             testingTarget.Dispose();
460             tlog.Debug(tag, $"TabAddItem END (OK)");
461         }
462
463         [Test]
464         [Category("P1")]
465         [Description("Tab Style.")]
466         [Property("SPEC", "Tizen.NUI.Components.Tab.Style M")]
467         [Property("SPEC_URL", "-")]
468         [Property("CRITERIA", "MR")]
469         [Property("COVPARAM", "")]
470         [Property("AUTHOR", "guowei.wang@samsung.com")]
471         [Obsolete]
472         public void TabStyle()
473         {
474             tlog.Debug(tag, $"TabStyle START");
475
476             var testingTarget = new Tab();
477             Assert.IsNotNull(testingTarget, "null handle");
478             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
479
480             var result = testingTarget.Style;
481             tlog.Debug(tag, "Style : " + result);
482
483             testingTarget.Dispose();
484             tlog.Debug(tag, $"TabStyle END (OK)");
485         }
486
487         [Test]
488         [Category("P1")]
489         [Description("Tab OnUpdate.")]
490         [Property("SPEC", "Tizen.NUI.Components.Tab.OnUpdate M")]
491         [Property("SPEC_URL", "-")]
492         [Property("CRITERIA", "MR")]
493         [Property("COVPARAM", "")]
494         [Property("AUTHOR", "guowei.wang@samsung.com")]
495         [Obsolete]
496         public void TabOnUpdate()
497         {
498             tlog.Debug(tag, $"TabOnUpdate START");
499
500             var testingTarget = new MyTab()
501             {
502                 LayoutDirection = ViewLayoutDirectionType.RTL,
503                 UseTextNaturalSize = true,
504             };
505             Assert.IsNotNull(testingTarget, "null handle");
506             Assert.IsInstanceOf<Tab>(testingTarget, "Should return Tab instance.");
507
508             try
509             {
510                 testingTarget.MyOnUpdate();
511             }
512             catch (Exception e)
513             {
514                 tlog.Debug(tag, e.Message.ToString());
515                 Assert.Fail("Caught Exception : Failed!");
516             }
517
518             testingTarget.Dispose();
519             tlog.Debug(tag, $"TabOnUpdate END (OK)");
520         }
521     }
522 }