[NUI][NUI.Components.Devel] Fix build errors of NUI.Components.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / TSTabContent.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/TabContent")]
14     public class TabContentTest
15     {
16         private const string tag = "NUITEST";
17
18         internal class MyTabContent : TabContent
19         {
20             public MyTabContent() : base()
21             { }
22
23             public void OnDispose(DisposeTypes types)
24             {
25                 base.Dispose(types);
26             }
27
28             public void OnAddView(View view)
29             {
30                 base.AddView(view);
31             }
32
33             public void OnRemoveView(View view)
34             {
35                 base.RemoveView(view);
36             }
37         }
38
39         [SetUp]
40         public void Init()
41         {
42             tlog.Info(tag, "Init() is called!");
43         }
44
45         [TearDown]
46         public void Destroy()
47         {
48             tlog.Info(tag, "Destroy() is called!");
49         }
50
51         [Test]
52         [Category("P1")]
53         [Description("TabContent Dispose.")]
54         [Property("SPEC", "Tizen.NUI.Components.TabContent.Dispose M")]
55         [Property("SPEC_URL", "-")]
56         [Property("CRITERIA", "MR")]
57         [Property("COVPARAM", "")]
58         [Property("AUTHOR", "guowei.wang@samsung.com")]
59         public void TabContentDispose()
60         {
61             tlog.Debug(tag, $"TabContentDispose START");
62
63             var testingTarget = new MyTabContent();
64             Assert.IsNotNull(testingTarget, "null handle");
65             Assert.IsInstanceOf<TabContent>(testingTarget, "Should return TabContent instance.");
66
67             try
68             {
69                 testingTarget.OnDispose(DisposeTypes.Explicit);
70             }
71             catch (Exception e)
72             {
73                 tlog.Debug(tag, e.Message.ToString());
74                 Assert.Fail("Caught Exception : Failed!");
75             }
76
77             testingTarget.Dispose();
78             tlog.Debug(tag, $"TabContentDispose END (OK)");
79         }
80
81         [Test]
82         [Category("P1")]
83         [Description("TabContent RemoveView.")]
84         [Property("SPEC", "Tizen.NUI.Components.TabContent.RemoveView M")]
85         [Property("SPEC_URL", "-")]
86         [Property("CRITERIA", "MR")]
87         [Property("COVPARAM", "")]
88         [Property("AUTHOR", "guowei.wang@samsung.com")]
89         public void TabContentRemoveView()
90         {
91             tlog.Debug(tag, $"TabContentRemoveView START");
92
93             var testingTarget = new MyTabContent()
94             { 
95                 Size = new Size(100, 100),
96             };
97             Assert.IsNotNull(testingTarget, "null handle");
98             Assert.IsInstanceOf<TabContent>(testingTarget, "Should return TabContent instance.");
99
100             View dummy1 = new View()
101             {
102                 Size = new Size(50, 100),
103                 Position = new Position(0, 0),
104             };
105
106             View dummy2 = new View()
107             {
108                 Size = new Size(50, 100),
109                 Position = new Position(50, 0),
110             };
111
112             testingTarget.OnAddView(dummy1);
113             testingTarget.OnAddView(dummy2);
114
115             try
116             {
117                 testingTarget.OnRemoveView(dummy1);
118             }
119             catch (Exception e)
120             {
121                 tlog.Debug(tag, e.Message.ToString());
122                 Assert.Fail("Caught Exception : Failed!");
123             }
124
125             dummy1.Dispose();
126             dummy2.Dispose();
127             testingTarget.OnDispose(DisposeTypes.Explicit);
128             tlog.Debug(tag, $"TabContentRemoveView END (OK)");
129         }
130
131         [Test]
132         [Category("P2")]
133         [Description("TabContent AddView.")]
134         [Property("SPEC", "Tizen.NUI.Components.TabContent.AddView M")]
135         [Property("SPEC_URL", "-")]
136         [Property("CRITERIA", "MR")]
137         [Property("COVPARAM", "")]
138         [Property("AUTHOR", "guowei.wang@samsung.com")]
139         public void TabContentAddView()
140         {
141             tlog.Debug(tag, $"TabContentAddView START");
142
143             var testingTarget = new MyTabContent();
144             Assert.IsNotNull(testingTarget, "null handle");
145             Assert.IsInstanceOf<TabContent>(testingTarget, "Should return TabContent instance.");
146
147             View view = null;
148
149             try
150             {
151                 testingTarget.OnAddView(view);
152             }
153             catch (ArgumentNullException)
154             {
155                 testingTarget.Dispose();
156                 tlog.Debug(tag, $"TabContentAddView END (OK)");
157                 Assert.Pass("Caught ArgumentNullException : Passed!");
158             }
159         }
160
161
162         [Test]
163         [Category("P2")]
164         [Description("TabContent RemoveView.")]
165         [Property("SPEC", "Tizen.NUI.Components.TabContent.RemoveView M")]
166         [Property("SPEC_URL", "-")]
167         [Property("CRITERIA", "MR")]
168         [Property("COVPARAM", "")]
169         [Property("AUTHOR", "guowei.wang@samsung.com")]
170         public void TabContentRemoveViewWithNull()
171         {
172             tlog.Debug(tag, $"TabContentRemoveViewWithNull START");
173
174             var testingTarget = new MyTabContent();
175             Assert.IsNotNull(testingTarget, "null handle");
176             Assert.IsInstanceOf<TabContent>(testingTarget, "Should return TabContent instance.");
177
178             View view = null;
179
180             try
181             {
182                 testingTarget.OnRemoveView(view);
183             }
184             catch (ArgumentNullException)
185             {
186                 testingTarget.Dispose();
187                 tlog.Debug(tag, $"TabContentRemoveViewWithNull END (OK)");
188                 Assert.Pass("Caught ArgumentNullException : Passed!");
189             }
190         }
191
192     }
193 }