Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / ToolbarTest3.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         Dictionary<ToolbarItem, int> _itemTable = new Dictionary<ToolbarItem, int>();
26         Dictionary<int, ToolbarItem> _reverseItemTable = new Dictionary<int, ToolbarItem>();
27         public override string TestName => "ToolbarTest3";
28         public override string TestDescription => "To test basic operation of Toolbar for changing bg color";
29         public override void Run(Window window)
30         {
31             Conformant conformant = new Conformant(window);
32             conformant.Show();
33             Box outterBox = 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             outterBox.Show();
43
44             Toolbar toolbar = new Toolbar(window)
45             {
46                 AlignmentX = -1,
47                 WeightX = 1,
48             };
49
50             var rnd = new Random();
51             toolbar.BackgroundColor = Color.FromRgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
52             toolbar.Show();
53             outterBox.PackEnd(toolbar);
54
55             toolbar.Selected += (s, e) =>
56             {
57                 e.Item.DeletePartColor("bg");
58             };
59
60             Label lb = new Label(window)
61             {
62                 Text = "Please, click an item for delete part color",
63             };
64             lb.Show();
65             outterBox.PackEnd(lb);
66
67             for (int i = 0; i < 5; i++)
68             {
69                 ToolbarItem item = toolbar.Append(string.Format("{0} home", i), "home");
70                 Color bgColor = Color.FromRgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
71                 item.SetPartColor("bg", bgColor);
72
73                 item.Clicked += (s, e) =>
74                 {
75                     lb.Text = (s as ToolbarItem).Text+" clicked";
76                 };
77             }
78
79
80             conformant.SetContent(outterBox);
81         }
82     }
83 }