Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / ToolbarTest2.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 using System.Collections.Generic;
20
21 namespace ElmSharp.Test
22 {
23     public class ToolbarTest2 : TestCaseBase
24     {
25         Dictionary<ToolbarItem, int> _itemTable = new Dictionary<ToolbarItem, int>();
26         Dictionary<int, ToolbarItem> _reverseItemTable = new Dictionary<int, ToolbarItem>();
27         public override string TestName => "ToolbarTest2";
28         public override string TestDescription => "To test basic operation of Toolbar";
29         public override void Run(Window window)
30         {
31             Conformant conformant = new Conformant(window);
32             conformant.Show();
33             Box outerBox = new Box(window)
34             {
35                 AlignmentX = -1,
36                 AlignmentY = -1,
37                 WeightX = 1,
38                 WeightY = 1,
39                 IsHorizontal = false,
40                 BackgroundColor = Color.Aqua,
41             };
42             outerBox.Show();
43
44             Toolbar toolbar = new Toolbar(window)
45             {
46                 AlignmentX = -1,
47                 WeightX = 1,
48             };
49             toolbar.Show();
50             outerBox.PackEnd(toolbar);
51
52             List<ToolbarItem> items = new List<ToolbarItem>();
53             items.Add(toolbar.Append(string.Format("{0} home", items.Count), "home"));
54
55             Button bt = new Button(window)
56             {
57                 Text = "Add ToolbarItem",
58                 MinimumWidth = 400
59             };
60             bt.Clicked += (s, e) =>
61             {
62                 items.Add(toolbar.Append(string.Format("{0} home", items.Count), "home"));
63             };
64
65             Button removebt = new Button(window)
66             {
67                 Text = "Remove first ToolbarItem",
68                 MinimumWidth = 400
69             };
70             removebt.Clicked += (s, e) =>
71             {
72                 foreach (var cur in items)
73                 {
74                     items.Remove(cur);
75                     cur.Delete();
76                     return;
77                 }
78             };
79
80             bt.Show();
81             removebt.Show();
82             outerBox.PackEnd(bt);
83             outerBox.PackEnd(removebt);
84             conformant.SetContent(outerBox);
85         }
86     }
87 }