[NUI][TEST] Update TCs of NUI.Components.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / FlexibleView / TSFlexibleViewAdapter.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Tizen.NUI.Components.Devel.Tests
6 {
7     using tlog = Tizen.Log;
8
9     [TestFixture]
10     [Description("Controls/FlexibleView/FlexibleViewAdapter")]
11     public class FlexibleViewAdapterTest
12     {
13         private const string tag = "NUITEST";
14
15         private Vector2 scrnSize;
16         private ListBridge adapter;
17         private FlexibleView horizontalFlexibleView;
18         private LinearLayoutManager horizontalLayoutManager;
19     }
20
21     [TearDown]
22     public void Destroy()
23     {
24         scrnSize?.Dispose();
25         tlog.Info(tag, "Destroy() is called!");
26     }
27
28     private FlexibleView GetHorizontalFlexibleView()
29     {
30         horizontalFlexibleView = new FlexibleView();
31         Assert.IsNotNull(horizontalFlexibleView, "should be not null");
32         Assert.IsInstanceOf<FlexibleView>(horizontalFlexibleView, "should be an instance of testing target class!");
33
34         horizontalFlexibleView.Name = "FlexibleView";
35         horizontalFlexibleView.WidthSpecification = 400;
36         horizontalFlexibleView.HeightSpecification = 450;
37         horizontalFlexibleView.Padding = new Extents(10, 10, 10, 10);
38         horizontalFlexibleView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f);
39
40         List<ListItemData> dataList = new List<ListItemData>();
41         for (int i = 0; i < 4; ++i)
42         {
43             dataList.Add(new ListItemData(i));
44         }
45         adapter = new ListBridge(dataList);
46         horizontalFlexibleView.SetAdapter(adapter);
47         horizontalFlexibleView.OnRelayout(scrnSize, null);
48
49         horizontalLayoutManager = new LinearLayoutManager(LinearLayoutManager.HORIZONTAL);
50         horizontalFlexibleView.SetLayoutManager(horizontalLayoutManager);
51         horizontalFlexibleView.OnRelayout(scrnSize, null);
52
53         return horizontalFlexibleView;
54     }
55
56     [Test]
57     [Category("P1")]
58     [Description("FlexibleViewAdapter NotifyItemChanged.")]
59     [Property("SPEC", "Tizen.NUI.Components.FlexibleView.FlexibleViewAdapter.NotifyItemChanged M")]
60     [Property("SPEC_URL", "-")]
61     [Property("CRITERIA", "MR")]
62     [Property("COVPARAM", "")]
63     [Property("AUTHOR", "guowei.wang@samsung.com")]
64     public void FlexibleViewAdapterNotifyItemChanged()
65     {
66         tlog.Debug(tag, $"FlexibleViewAdapterNotifyItemChanged START");
67
68         var testingTarget = GetHorizontalFlexibleView();
69         Assert.IsNotNull(testingTarget, "should be not null");
70         Assert.IsInstanceOf<FlexibleView>(testingTarget, "should be an instance of testing target class!");
71
72         try
73         {
74             testingTarget.GetAdapter().NotifyItemChanged(2);
75         }
76         catch (Exception e)
77         {
78             tlog.Debug(tag, e.Message.ToString());
79             Assert.Fail("Caught Exception : Failed!");
80         }
81
82         testingTarget.Dispose();
83         tlog.Debug(tag, $"FlexibleViewAdapterNotifyItemChanged END (OK)");
84     }
85
86     [Test]
87     [Category("P1")]
88     [Description("FlexibleViewAdapter NotifyItemRangeChanged.")]
89     [Property("SPEC", "Tizen.NUI.Components.FlexibleView.FlexibleViewAdapter.NotifyItemRangeChanged M")]
90     [Property("SPEC_URL", "-")]
91     [Property("CRITERIA", "MR")]
92     [Property("COVPARAM", "")]
93     [Property("AUTHOR", "guowei.wang@samsung.com")]
94     public void FlexibleViewAdapterNotifyItemRangeChanged()
95     {
96         tlog.Debug(tag, $"FlexibleViewAdapterNotifyItemRangeChanged START");
97
98         var testingTarget = GetHorizontalFlexibleView();
99         Assert.IsNotNull(testingTarget, "should be not null");
100         Assert.IsInstanceOf<FlexibleView>(testingTarget, "should be an instance of testing target class!");
101
102         try
103         {
104             testingTarget.GetAdapter().NotifyItemRangeChanged(2, 2);
105         }
106         catch (Exception e)
107         {
108             tlog.Debug(tag, e.Message.ToString());
109             Assert.Fail("Caught Exception : Failed!");
110         }
111
112         testingTarget.Dispose();
113         tlog.Debug(tag, $"FlexibleViewAdapterNotifyItemRangeChanged END (OK)");
114     }
115 }