Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / GenListTest6.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using ElmSharp;
19
20 namespace ElmSharp.Test
21 {
22     class GenListTest6 : TestCaseBase
23     {
24         public override string TestName => "GenListTest6";
25         public override string TestDescription => "To test deletion of GenListItem";
26         GenListItem selected = null;
27
28
29         public override void Run(Window window)
30         {
31             Conformant conformant = new Conformant(window);
32             conformant.Show();
33             Box box = new Box(window)
34             {
35                 AlignmentX = -1,
36                 AlignmentY = -1,
37                 WeightX = 1,
38                 WeightY = 1,
39             };
40             box.Show();
41             conformant.SetContent(box);
42
43
44             GenList list = new GenList(window)
45             {
46                 Homogeneous = true,
47                 AlignmentX = -1,
48                 AlignmentY = -1,
49                 WeightX = 1,
50                 WeightY = 1
51             };
52
53             GenItemClass defaultClass = new GenItemClass("default")
54             {
55                 GetTextHandler = (obj, part) =>
56                 {
57                     return string.Format("{0} - {1}", (string)obj, part);
58                 },
59                 DeleteHandler = new GenItemClass.DeleteDelegate((obj) =>
60                 {
61                     Console.WriteLine("DeleteHandler was called with... {0}", (string)obj);
62                 }),
63             };
64             GenListItem[] items = new GenListItem[100];
65             for (int i = 0; i < 100; i++)
66             {
67                 items[i] = list.Append(defaultClass, string.Format("{0} Item", i));
68             }
69             list.Show();
70             list.ItemSelected += List_ItemSelected;
71             list.ItemActivated += List_ItemActivated;
72             list.ItemUnselected += List_ItemUnselected;
73             list.ItemPressed += List_ItemPressed;
74             list.ItemRealized += List_ItemRealized;
75             list.ItemReleased += List_ItemReleased;
76             list.ItemUnrealized += List_ItemUnrealized;
77             list.ItemLongPressed += List_ItemLongPressed;
78             list.ItemDoubleClicked += List_ItemDoubleClicked;
79             box.PackEnd(list);
80             Button first = new Button(window)
81             {
82                 Text = "Delete",
83                 AlignmentX = -1,
84                 WeightX = 1,
85             };
86             first.Clicked += (s, e) =>
87             {
88                 selected?.Delete();
89             };
90             first.Show();
91             box.PackEnd(first);
92
93         }
94
95         private void List_ItemSelected(object sender, GenListItemEventArgs e)
96         {
97             selected = e.Item;
98             Console.WriteLine("{0} Item was selected", (string)(e.Item.Data));
99         }
100         private void List_ItemDoubleClicked(object sender, GenListItemEventArgs e)
101         {
102             Console.WriteLine("{0} Item was double clicked", (string)(e.Item.Data));
103         }
104
105         private void List_ItemLongPressed(object sender, GenListItemEventArgs e)
106         {
107             Console.WriteLine("{0} Item was Long pressed", (string)(e.Item.Data));
108         }
109
110         private void List_ItemUnrealized(object sender, GenListItemEventArgs e)
111         {
112             Console.WriteLine("!!!! Item was Unrealized!!!");
113             Console.WriteLine("{0} Item was unrealzed", (string)(e.Item.Data));
114         }
115
116         private void List_ItemReleased(object sender, GenListItemEventArgs e)
117         {
118             Console.WriteLine("{0} Item was released", (string)(e.Item.Data));
119         }
120
121         private void List_ItemRealized(object sender, GenListItemEventArgs e)
122         {
123             Console.WriteLine("{0} Item was Realized", (string)(e.Item.Data));
124         }
125
126         private void List_ItemPressed(object sender, GenListItemEventArgs e)
127         {
128             Console.WriteLine("{0} Item was Pressed", (string)(e.Item.Data));
129         }
130
131         private void List_ItemUnselected(object sender, GenListItemEventArgs e)
132         {
133             Console.WriteLine("{0} Item was unselected", (string)(e.Item.Data));
134         }
135
136         private void List_ItemActivated(object sender, GenListItemEventArgs e)
137         {
138             Console.WriteLine("{0} Item was Activated", (string)(e.Item.Data));
139         }
140     }
141 }