[NUI] Add TCs for NUI.Components.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / RecyclerView / Layouter / TSItemSource.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     internal sealed class CustomGroupItemSource : IGroupableItemSource
11     {
12         public CustomGroupItemSource(object parent)
13         {
14             this.parent = parent as CollectionView;
15         }
16
17         public int Count => 0;
18
19         public bool HasHeader { get; set; } = true;
20         public bool HasFooter { get; set; } = true;
21
22         public void Dispose()
23         {
24
25         }
26
27         public bool IsHeader(int index)
28         {
29             return HasHeader && index == 0;
30         }
31
32         public bool IsFooter(int index)
33         {
34             if (!HasFooter)
35             {
36                 return false;
37             }
38
39             if (HasHeader)
40             {
41                 return index == 1;
42             }
43
44             return index == 0;
45         }
46
47         public int GetPosition(object item)
48         {
49             return Position;
50         }
51
52         internal int Position
53         {
54             set;
55             get;
56         }
57
58         public object GetItem(int position)
59         {
60             throw new IndexOutOfRangeException("IItemSource is empty");
61         }
62
63         public bool IsGroupHeader(int position)
64         {
65             return null != parent.Header;
66         }
67
68         public bool IsGroupFooter(int position)
69         {
70             return position == FooterIndex;
71         }
72
73         internal int FooterIndex
74         {
75             get;
76             set;
77         } = -1;
78
79         public object GetGroupParent(int position)
80         {
81             return parent;
82         }
83
84         private CollectionView parent;
85     }
86
87     internal sealed class CustomEmptySource : IItemSource
88     {
89         public int Count => 0;
90
91         public bool HasHeader { get; set; }
92         public bool HasFooter { get; set; }
93
94         public void Dispose()
95         {
96
97         }
98
99         public bool IsHeader(int index)
100         {
101             return HasHeader && index == 0;
102         }
103
104         public bool IsFooter(int index)
105         {
106             if (!HasFooter)
107             {
108                 return false;
109             }
110
111             if (HasHeader)
112             {
113                 return index == 1;
114             }
115
116             return index == 0;
117         }
118
119         public int GetPosition(object item)
120         {
121             return -1;
122         }
123
124         public object GetItem(int position)
125         {
126             throw new IndexOutOfRangeException("IItemSource is empty");
127         }
128     }
129 }