Enhance Toolbar Widget
[platform/core/csapi/elm-sharp.git] / ElmSharp.Test / TC / ToolbarTest4.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 ToolbarTest3 : TestCaseBase
24     {
25         public override string TestName => "ToolbarTest3";
26         public override string TestDescription => "To test basic operation of Toolbar";
27
28         public override void Run(Window window)
29         {
30             Conformant conformant = new Conformant(window);
31             conformant.Show();
32             Box outterBox = new Box(window)
33             {
34                 AlignmentX = -1,
35                 AlignmentY = -1,
36                 WeightX = 1,
37                 WeightY = 1,
38                 IsHorizontal = false,
39                 BackgroundColor = Color.Aqua,
40             };
41             outterBox.Show();
42
43             Toolbar toolbar = new Toolbar(window)
44             {
45                 AlignmentX = -1,
46                 WeightX = 1,
47                 ShrinkMode = ToolbarShrinkMode.Scroll,
48                 IconLookupOrder = ToolbarIconLookupOrder.ThemeFreedesktop,
49             };
50             toolbar.Show();
51             outterBox.PackEnd(toolbar);
52
53             toolbar.Append("FirstItem", "home");
54             toolbar.Append("LastItem", "home");
55             ToolbarItem result = toolbar.InsertAfter(toolbar.FirstItem, "Result", "");
56
57             Button bt1 = new Button(window)
58             {
59                 Text = "Change IconSize",
60                 MinimumWidth = 400
61             };
62             bt1.Clicked += (s, e) =>
63             {
64                 if (toolbar.IconSize < 50)
65                     toolbar.IconSize = 100;
66                 else
67                     toolbar.IconSize = 32;
68                 result.Text = string.Format("IconSize{0}", toolbar.IconSize.ToString());
69             };
70             bt1.Show();
71             outterBox.PackEnd(bt1);
72
73             Button bt2 = new Button(window)
74             {
75                 Text = "Find FirstItem",
76                 MinimumWidth = 400
77             };
78             bt2.Clicked += (s, e) =>
79             {
80                 ToolbarItem item1 = toolbar.FirstItem;
81                 ToolbarItem item2 = toolbar.FindItemByLabel("FirstItem");
82                 if (item1 == null || item2 == null || item1 != item2)
83                     result.Text = "FAIL";
84                 else
85                     result.Text = "PASS";
86             };
87             bt2.Show();
88             outterBox.PackEnd(bt2);
89
90             Button bt3 = new Button(window)
91             {
92                 Text = "Find LastItem",
93                 MinimumWidth = 400
94             };
95             bt3.Clicked += (s, e) =>
96             {
97                 ToolbarItem item1 = toolbar.LastItem;
98                 ToolbarItem item2 = toolbar.FindItemByLabel("LastItem");
99                 if (item1 == null || item2 == null || item1 != item2)
100                     result.Text = "FAIL";
101                 else
102                     result.Text = "PASS";
103             };
104             bt3.Show();
105             outterBox.PackEnd(bt3);
106
107             Button bt4 = new Button(window)
108             {
109                 Text = "Get ItemsCount",
110                 MinimumWidth = 400
111             };
112             bt4.Clicked += (s, e) =>
113             {
114                 result.Text = toolbar.ItemsCount.ToString();
115             };
116             bt4.Show();
117             outterBox.PackEnd(bt4);
118
119             Button bt5 = new Button(window)
120             {
121                 Text = "Change IconLookupOrder",
122                 MinimumWidth = 400
123             };
124             bt5.Clicked += (s, e) =>
125             {
126                 toolbar.IconLookupOrder = (ToolbarIconLookupOrder)(((int)toolbar.IconLookupOrder + 1) % 4);
127                 result.Text = toolbar.IconLookupOrder.ToString();
128             };
129             bt5.Show();
130             outterBox.PackEnd(bt5);
131
132             conformant.SetContent(outterBox);
133         }
134     }
135 }