[NUI] Components function coverage test
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / RecyclerView / Item / TSDefaultLinearItem.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Threading.Tasks;
6 using Tizen.NUI.BaseComponents;
7
8 namespace Tizen.NUI.Components.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     class TestDefaultLinearItem : DefaultLinearItem
13     {
14         public void LayoutTest()
15         {
16             base.LayoutChild();
17         }
18     }
19
20     [TestFixture]
21     [Description("Controls/RecyclerView/Item/DefaultLinearItem")]
22     class TSDefaultLinearItem
23     {
24         private const string tag = "NUITEST";
25
26         [SetUp]
27         public void Init()
28         {
29             tlog.Info(tag, "Init() is called!");
30         }
31
32         [TearDown]
33         public void Destroy()
34         {
35             tlog.Info(tag, "Destroy() is called!");
36         }
37
38         [Test]
39         [Category("P1")]
40         [Description("DefaultLinearItem constructor.")]
41         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem C")]
42         [Property("SPEC_URL", "-")]
43         [Property("CRITERIA", "CONSTR")]
44         [Property("COVPARAM", "")]
45         [Property("AUTHOR", "huayong.xu@samsung.com")]
46         public void DefaultLinearItemConstructor()
47         {
48             tlog.Debug(tag, $"DefaultGridItem START");
49
50             var testingTarget = new DefaultLinearItem();
51
52             Assert.IsNotNull(testingTarget, "should be not null");
53             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
54
55             testingTarget.Dispose();
56             tlog.Debug(tag, $"DefaultGridItem END (OK)");
57         }
58
59         [Test]
60         [Category("P1")]
61         [Description("DefaultLinearItem constructor.")]
62         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem C")]
63         [Property("SPEC_URL", "-")]
64         [Property("CRITERIA", "CONSTR")]
65         [Property("COVPARAM", "")]
66         [Property("AUTHOR", "huayong.xu@samsung.com")]
67         public void DefaultLinearItemConstructorWithStyle()
68         {
69             tlog.Debug(tag, $"DefaultLinearItem START");
70
71             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
72
73             Assert.IsNotNull(testingTarget, "should be not null");
74             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
75
76             testingTarget.Dispose();
77             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
78         }
79
80         [Test]
81         [Category("P1")]
82         [Description("DefaultLinearItem constructor.")]
83         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem C")]
84         [Property("SPEC_URL", "-")]
85         [Property("CRITERIA", "CONSTR")]
86         [Property("COVPARAM", "")]
87         [Property("AUTHOR", "huayong.xu@samsung.com")]
88         public void DefaultLinearItemConstructorWithItemStyle()
89         {
90             tlog.Debug(tag, $"DefaultLinearItem START");
91
92             var style = new DefaultLinearItemStyle()
93             {
94                 SizeHeight = 108,
95                 Padding = new Extents(64, 64, 18, 17),
96                 Margin = new Extents(0, 0, 0, 0),
97                 Icon = new ViewStyle()
98                 {
99                     Margin = new Extents(0, 32, 0, 0)
100                 },
101             };
102             var testingTarget = new DefaultLinearItem(style);
103
104             Assert.IsNotNull(testingTarget, "should be not null");
105             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
106
107             testingTarget.Dispose();
108             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
109         }
110
111         [Test]
112         [Category("P1")]
113         [Description("DefaultLinearItem Icon.")]
114         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Icon A")]
115         [Property("SPEC_URL", "-")]
116         [Property("CRITERIA", "PRW")]
117         [Property("COVPARAM", "")]
118         [Property("AUTHOR", "huayong.xu@samsung.com")]
119         public void DefaultLinearItemIcon()
120         {
121             tlog.Debug(tag, $"DefaultLinearItem START");
122
123             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
124
125             Assert.IsNotNull(testingTarget, "should be not null");
126             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
127
128             testingTarget.Icon = new View()
129             {
130                 Size = new Size(100, 100),
131             };
132             Assert.IsNotNull(testingTarget.Icon, "should be not null");
133
134             testingTarget.Dispose();
135             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
136         }
137
138         [Test]
139         [Category("P1")]
140         [Description("DefaultLinearItem Label.")]
141         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Label A")]
142         [Property("SPEC_URL", "-")]
143         [Property("CRITERIA", "PRW")]
144         [Property("COVPARAM", "")]
145         [Property("AUTHOR", "huayong.xu@samsung.com")]
146         public void DefaultLinearItemLabel()
147         {
148             tlog.Debug(tag, $"DefaultLinearItem START");
149
150             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
151
152             Assert.IsNotNull(testingTarget, "should be not null");
153             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
154
155             testingTarget.Label = new TextLabel()
156             {
157                 Text = "test",
158             };
159             Assert.IsNotNull(testingTarget.Label, "should be not null");
160
161             testingTarget.Dispose();
162             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
163         }
164
165         [Test]
166         [Category("P1")]
167         [Description("DefaultLinearItem Text.")]
168         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Text A")]
169         [Property("SPEC_URL", "-")]
170         [Property("CRITERIA", "PRW")]
171         [Property("COVPARAM", "")]
172         [Property("AUTHOR", "huayong.xu@samsung.com")]
173         public void DefaultLinearItemText()
174         {
175             tlog.Debug(tag, $"DefaultLinearItem START");
176
177             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
178
179             Assert.IsNotNull(testingTarget, "should be not null");
180             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
181
182             testingTarget.Text = "test";
183             Assert.AreEqual(testingTarget.Text, "test", "should be equal.");
184
185             testingTarget.Dispose();
186             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
187         }
188
189         [Test]
190         [Category("P1")]
191         [Description("DefaultLinearItem SubLabel.")]
192         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.SubLabel A")]
193         [Property("SPEC_URL", "-")]
194         [Property("CRITERIA", "PRW")]
195         [Property("COVPARAM", "")]
196         [Property("AUTHOR", "huayong.xu@samsung.com")]
197         public void DefaultLinearItemSubLabel()
198         {
199             tlog.Debug(tag, $"DefaultLinearItem START");
200
201             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
202
203             Assert.IsNotNull(testingTarget, "should be not null");
204             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
205
206             testingTarget.SubLabel = new TextLabel()
207             {
208                 Text = "test",
209             };
210             Assert.IsNotNull(testingTarget.SubLabel, "should be not null");
211
212             testingTarget.Dispose();
213             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
214         }
215
216         [Test]
217         [Category("P1")]
218         [Description("DefaultLinearItem SubText.")]
219         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.SubText A")]
220         [Property("SPEC_URL", "-")]
221         [Property("CRITERIA", "PRW")]
222         [Property("COVPARAM", "")]
223         [Property("AUTHOR", "huayong.xu@samsung.com")]
224         public void DefaultLinearSubText()
225         {
226             tlog.Debug(tag, $"DefaultLinearItem START");
227
228             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
229
230             Assert.IsNotNull(testingTarget, "should be not null");
231             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
232
233             testingTarget.SubText = "test";
234             Assert.AreEqual(testingTarget.SubText, "test", "should be equal.");
235
236             testingTarget.Dispose();
237             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
238         }
239
240         [Test]
241         [Category("P1")]
242         [Description("DefaultLinearItem Extra.")]
243         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Extra A")]
244         [Property("SPEC_URL", "-")]
245         [Property("CRITERIA", "PRW")]
246         [Property("COVPARAM", "")]
247         [Property("AUTHOR", "huayong.xu@samsung.com")]
248         public void DefaultLinearItemExtra()
249         {
250             tlog.Debug(tag, $"DefaultLinearItem START");
251
252             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
253
254             Assert.IsNotNull(testingTarget, "should be not null");
255             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
256
257             testingTarget.Extra = new View()
258             {
259                 Size = new Size(100, 100),
260             };
261             Assert.IsNotNull(testingTarget.Extra, "should be not null");
262
263             testingTarget.Dispose();
264             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
265         }
266
267         //Todo: this causes BLOCK, should be fixed.
268         //[Test]
269         [Category("P1")]
270         [Description("DefaultLinearItem Extra.")]
271         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Extra A")]
272         [Property("SPEC_URL", "-")]
273         [Property("CRITERIA", "PRW")]
274         [Property("COVPARAM", "")]
275         [Property("AUTHOR", "huayong.xu@samsung.com")]
276         public async Task DefaultLinearItemExtraNull()
277         {
278             tlog.Debug(tag, $"DefaultLinearItem START");
279
280             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
281             EventHandler onAddedToWindow = (s, e) => { tcs.TrySetResult(true); };
282
283             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
284
285             Assert.IsNotNull(testingTarget, "should be not null");
286             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
287
288             testingTarget.SubLabel = new TextLabel()
289             {
290                 Text = "test",
291             };
292             Assert.IsNotNull(testingTarget.SubLabel, "should be not null");
293
294             Assert.IsNotNull(testingTarget.Extra, "should be not null");
295             testingTarget.Extra.Size = new Size(100, 100);
296             testingTarget.Extra.AddedToWindow += onAddedToWindow;
297
298             Window.Instance.Add(testingTarget.Extra);
299
300             var result = await tcs.Task;
301             Assert.IsTrue(result, "Relayout event should be invoked");
302
303             testingTarget.Dispose();
304             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
305         }
306
307         [Test]
308         [Category("P1")]
309         [Description("DefaultLinearItem Seperator.")]
310         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.Seperator A")]
311         [Property("SPEC_URL", "-")]
312         [Property("CRITERIA", "PRO")]
313         [Property("COVPARAM", "")]
314         [Property("AUTHOR", "huayong.xu@samsung.com")]
315         public void DefaultLinearItemSeperator()
316         {
317             tlog.Debug(tag, $"DefaultLinearItem START");
318
319             var testingTarget = new DefaultLinearItem("Tizen.NUI.Components.DefaultLinearItem");
320
321             Assert.IsNotNull(testingTarget, "should be not null");
322             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
323
324             Assert.IsNotNull(testingTarget.Seperator, "should not be null");
325
326             testingTarget.Dispose();
327             tlog.Debug(tag, $"DefaultLinearItem END (OK)");
328         }
329
330         [Test]
331         [Category("P1")]
332         [Description("DefaultLinearItem LayoutChild.")]
333         [Property("SPEC", "Tizen.NUI.Components.DefaultLinearItem.LayoutChild M")]
334         [Property("SPEC_URL", "-")]
335         [Property("CRITERIA", "MR")]
336         [Property("COVPARAM", "")]
337         [Property("AUTHOR", "huayong.xu@samsung.com")]
338         public void DefaultLinearItemLayoutChild()
339         {
340             tlog.Debug(tag, $"DefaultGridItem START");
341
342             var testingTarget = new TestDefaultLinearItem();
343
344             Assert.IsNotNull(testingTarget, "should be not null");
345             Assert.IsInstanceOf<DefaultLinearItem>(testingTarget, "should be an instance of testing target class!");
346
347             testingTarget.Extra = new View()
348             {
349                 Size = new Size(100, 100),
350             };
351             Assert.IsNotNull(testingTarget.Extra, "should be not null");
352             testingTarget.Icon = new View()
353             {
354                 Size = new Size(100, 100),
355             };
356             Assert.IsNotNull(testingTarget.Icon, "should be not null");
357             testingTarget.Label = new TextLabel()
358             {
359                 WidthSpecification = 170,
360                 HeightSpecification = 170,
361             };
362             Assert.IsNotNull(testingTarget.Label, "DefaultLinearItem Label should not be null.");
363             testingTarget.SubLabel = new TextLabel()
364             {
365                 Text = "test",
366             };
367             Assert.IsNotNull(testingTarget.SubLabel, "should be not null");
368             testingTarget.LayoutTest();
369
370             testingTarget.Dispose();
371             tlog.Debug(tag, $"DefaultGridItem END (OK)");
372         }
373     }
374 }