52633baef93d36820773783daf18f31681f1f7a2
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / TSCheckBoxGroup.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 tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("Controls/CheckBoxGroup")]
14     public class CheckBoxGroupTest
15     {
16         private const string tag = "NUITEST";
17         private string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
18
19         [SetUp]
20         public void Init()
21         {
22             tlog.Info(tag, "Init() is called!");
23         }
24
25         [TearDown]
26         public void Destroy()
27         {
28             tlog.Info(tag, "Destroy() is called!");
29         }
30
31         [Test]
32         [Category("P1")]
33         [Description("CheckBoxGroup contructor.")]
34         [Property("SPEC", "Tizen.NUI.Components.CheckBoxGroup.CheckBoxGroup C")]
35         [Property("SPEC_URL", "-")]
36         [Property("CRITERIA", "CONSTR")]
37         [Property("COVPARAM", "")]
38         [Property("AUTHOR", "guowei.wang@samsung.com")]
39         public void CheckBoxGroupContructor()
40         {
41             tlog.Debug(tag, $"CheckBoxGroupContructor START");
42
43             var testingTarget = new CheckBoxGroup();
44             Assert.IsNotNull(testingTarget, "null handle");
45             Assert.IsInstanceOf<CheckBoxGroup>(testingTarget, "Should return CheckBoxGroup instance.");
46
47             tlog.Debug(tag, $"CheckBoxGroupContructor END (OK)");
48         }
49
50         [Test]
51         [Category("P1")]
52         [Description("CheckBoxGroup SetIsGroupHolder.")]
53         [Property("SPEC", "Tizen.NUI.Components.CheckBoxGroup.SetIsGroupHolder M")]
54         [Property("SPEC_URL", "-")]
55         [Property("CRITERIA", "CONSTR")]
56         [Property("COVPARAM", "")]
57         [Property("AUTHOR", "guowei.wang@samsung.com")]
58         public void CheckBoxGroupSetIsGroupHolder()
59         {
60             tlog.Debug(tag, $"CheckBoxSetIsGroupHolder START");
61
62             View view = new View()
63             {
64                 Size = new Size(100, 200),
65                 BackgroundColor = Color.Green,
66             };
67
68             CheckBoxGroup.SetIsGroupHolder(view, true);
69             tlog.Debug(tag, "GetIsGroupHolder : " + CheckBoxGroup.GetIsGroupHolder(view));
70
71             tlog.Debug(tag, "GetCheckBoxGroup : " + CheckBoxGroup.GetCheckBoxGroup(view));
72
73             view.Dispose();
74             tlog.Debug(tag, $"CheckBoxSetIsGroupHolder END (OK)");
75         }
76
77         [Test]
78         [Category("P1")]
79         [Description("CheckBoxGroup Add.")]
80         [Property("SPEC", "Tizen.NUI.Components.CheckBoxGroup.Add M")]
81         [Property("SPEC_URL", "-")]
82         [Property("CRITERIA", "MR")]
83         [Property("COVPARAM", "")]
84         [Property("AUTHOR", "guowei.wang@samsung.com")]
85         public void CheckBoxGroupAdd()
86         {
87             tlog.Debug(tag, $"CheckBoxGroupAdd START");
88
89             var testingTarget = new CheckBoxGroup();
90             Assert.IsNotNull(testingTarget, "null handle");
91             Assert.IsInstanceOf<CheckBoxGroup>(testingTarget, "Should return CheckBoxGroup instance.");
92
93             CheckBox cb = new CheckBox()
94             { 
95                 Size = new Size(48, 48)
96             };
97
98             try
99             {
100                 testingTarget.Add(cb);
101                 tlog.Debug(tag, "GetItem : " + testingTarget.GetItem(0));
102
103                 testingTarget.Remove(cb);
104             }
105             catch (Exception e)
106             {
107                 tlog.Debug(tag, e.Message.ToString());
108                 Assert.Fail("Caught Exception : Failed!");
109             }
110
111             tlog.Debug(tag, $"CheckBoxGroupAdd END (OK)");
112         }
113
114         [Test]
115         [Category("P1")]
116         [Description("CheckBoxGroup CheckAll.")]
117         [Property("SPEC", "Tizen.NUI.Components.CheckBoxGroup.CheckAll M")]
118         [Property("SPEC_URL", "-")]
119         [Property("CRITERIA", "MR")]
120         [Property("COVPARAM", "")]
121         [Property("AUTHOR", "guowei.wang@samsung.com")]
122         public void CheckBoxGroupCheckAll()
123         {
124             tlog.Debug(tag, $"CheckBoxGroupCheckAll START");
125
126             var testingTarget = new CheckBoxGroup();
127             Assert.IsNotNull(testingTarget, "null handle");
128             Assert.IsInstanceOf<CheckBoxGroup>(testingTarget, "Should return CheckBoxGroup instance.");
129
130             CheckBox cb1 = new CheckBox()
131             {
132                 Size = new Size(48, 48),
133                 IsEnabled = true,
134                 IsSelectable = true,
135                 IsSelected = true,
136             };
137
138             CheckBox cb2 = new CheckBox()
139             {
140                 Size = new Size(48, 48),
141                 IsEnabled = true,
142                 IsSelectable = true,
143                 IsSelected = false,
144             };
145
146             try
147             {
148                 testingTarget.Add(cb1);
149                 testingTarget.Add(cb2);
150                 testingTarget.CheckAll(true);
151
152                 var result = testingTarget.IsCheckedAll();
153                 tlog.Debug(tag, "IsCheckedAll : " + result);
154
155                 tlog.Debug(tag, "GetCheckedItems : " + testingTarget.GetCheckedItems());
156                 tlog.Debug(tag, "GetCheckedIndices : " + testingTarget.GetCheckedIndices());
157             }
158             catch (Exception e)
159             {
160                 tlog.Debug(tag, e.Message.ToString());
161                 Assert.Fail("Caught Exception : Failed!");
162             }
163
164             tlog.Debug(tag, $"CheckBoxGroupCheckAll END (OK)");
165         }
166     }
167 }