summaryrefslogtreecommitdiff
path: root/ElmSharp.Test/TC/ToolbarTest4.cs
blob: 268aadf3cdc17a7f71b5ed2b4f9ad45eb2f68628 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using ElmSharp;
using System.Collections.Generic;

namespace ElmSharp.Test
{
    public class ToolbarTest4 : TestCaseBase
    {
        public override string TestName => "ToolbarTest4";
        public override string TestDescription => "To test basic operation of Toolbar";

        public override void Run(Window window)
        {
            Conformant conformant = new Conformant(window);
            conformant.Show();
            Box outterBox = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX = 1,
                WeightY = 1,
                IsHorizontal = false,
                BackgroundColor = Color.Aqua,
            };
            outterBox.Show();

            Toolbar toolbar = new Toolbar(window)
            {
                AlignmentX = -1,
                WeightX = 1,
                ShrinkMode = ToolbarShrinkMode.Scroll,
                IconLookupOrder = ToolbarIconLookupOrder.ThemeFreedesktop,
            };
            toolbar.Show();
            outterBox.PackEnd(toolbar);

            toolbar.Append("FirstItem", "home");
            toolbar.Append("LastItem", "home");
            ToolbarItem result = toolbar.InsertAfter(toolbar.FirstItem, "Result", "");

            Button bt1 = new Button(window)
            {
                Text = "Change IconSize",
                MinimumWidth = 400
            };
            bt1.Clicked += (s, e) =>
            {
                if (toolbar.IconSize < 50)
                    toolbar.IconSize = 100;
                else
                    toolbar.IconSize = 32;
                result.Text = string.Format("IconSize{0}", toolbar.IconSize.ToString());
            };
            bt1.Show();
            outterBox.PackEnd(bt1);

            Button bt2 = new Button(window)
            {
                Text = "Find FirstItem",
                MinimumWidth = 400
            };
            bt2.Clicked += (s, e) =>
            {
                ToolbarItem item1 = toolbar.FirstItem;
                ToolbarItem item2 = toolbar.FindItemByLabel("FirstItem");
                if (item1 == null || item2 == null || item1 != item2)
                    result.Text = "FAIL";
                else
                    result.Text = "PASS";
            };
            bt2.Show();
            outterBox.PackEnd(bt2);

            Button bt3 = new Button(window)
            {
                Text = "Find LastItem",
                MinimumWidth = 400
            };
            bt3.Clicked += (s, e) =>
            {
                ToolbarItem item1 = toolbar.LastItem;
                ToolbarItem item2 = toolbar.FindItemByLabel("LastItem");
                if (item1 == null || item2 == null || item1 != item2)
                    result.Text = "FAIL";
                else
                    result.Text = "PASS";
            };
            bt3.Show();
            outterBox.PackEnd(bt3);

            Button bt4 = new Button(window)
            {
                Text = "Get ItemsCount",
                MinimumWidth = 400
            };
            bt4.Clicked += (s, e) =>
            {
                result.Text = toolbar.ItemsCount.ToString();
            };
            bt4.Show();
            outterBox.PackEnd(bt4);

            Button bt5 = new Button(window)
            {
                Text = "Change IconLookupOrder",
                MinimumWidth = 400
            };
            bt5.Clicked += (s, e) =>
            {
                toolbar.IconLookupOrder = (ToolbarIconLookupOrder)(((int)toolbar.IconLookupOrder + 1) % 4);
                result.Text = toolbar.IconLookupOrder.ToString();
            };
            bt5.Show();
            outterBox.PackEnd(bt5);

            conformant.SetContent(outterBox);
        }
    }
}