Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / FloatingButtonTest.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 FloatingButtonTest : TestCaseBase
23     {
24         public override string TestName => "FloatingButtonTest";
25         public override string TestDescription => "To test FloatingButton";
26
27         Button _RedButton = null;
28         Button _GreenButton = null;
29
30         public Button CreateButton(Window window, string text)
31         {
32             return new Button(window)
33             {
34                 Text = text,
35                 AlignmentY = -1,
36                 AlignmentX = -1,
37             };
38         }
39
40         public override void Run(Window window)
41         {
42             Conformant conformant = new Conformant(window);
43             conformant.Show();
44             Box box = new Box(window)
45             {
46                 AlignmentY = -1,
47                 AlignmentX = -1,
48                 WeightX = 1,
49                 WeightY = 1,
50             };
51             box.Show();
52             conformant.SetContent(box);
53
54             FloatingButton floatingButton = new FloatingButton(window)
55             {
56                 Mode = FloatingButtonMode.All,
57                 AlignmentY = -1,
58                 AlignmentX = -1,
59                 WeightX = 1,
60                 WeightY = 1,
61             };
62             floatingButton.Show();
63             floatingButton.Resize(700, 700);
64             floatingButton.Move(0, 400);
65
66             Box backGround = new Box(window)
67             {
68                 AlignmentY = -1,
69                 AlignmentX = -1,
70                 WeightX = 1,
71                 WeightY = 1,
72             };
73             backGround.Show();
74
75             Button button1 = CreateButton(window, "Mode change to LeftRightOnly");
76             button1.Clicked += (s, e) => {
77                 if (floatingButton.Mode == FloatingButtonMode.All)
78                 {
79                     floatingButton.Mode = FloatingButtonMode.LeftRightOnly;
80                     button1.Text = "Mode change to All";
81                 }
82                 else
83                 {
84                     floatingButton.Mode = FloatingButtonMode.All;
85                     button1.Text = "Mode change to LeftRightOnly";
86                 }
87             };
88             button1.Show();
89
90             Button button2 = CreateButton(window, "MovementBlock Set");
91             button2.Clicked += (s, e) => {
92                 floatingButton.MovementBlock = !floatingButton.MovementBlock;
93                 if (floatingButton.MovementBlock) button2.Text = "MovementBlock Unset";
94                 else button2.Text = "MovementBlock Set";
95             };
96             button2.Show();
97
98             Button button3 = CreateButton(window, "RedButton Set");
99             button3.Clicked += (s, e) => {
100                 if (_RedButton == null)
101                 {
102                     _RedButton = CreateButton(window, "RedButton");
103                     _RedButton.BackgroundColor = Color.Red;
104                     floatingButton.SetPartContent("button1", _RedButton, true);
105                     button3.Text = "RedButton Unset";
106                 }
107                 else
108                 {
109                     _RedButton.Unrealize();
110                     _RedButton = null;
111                     floatingButton.SetPartContent("button1", _RedButton, true);
112                     button3.Text = "RedButton Set";
113                 }
114             };
115             button3.Show();
116
117             Button button4 = CreateButton(window, "GreenButton Set");
118             button4.Clicked += (s, e) => {
119                 if (_GreenButton == null)
120                 {
121                     _GreenButton = CreateButton(window, "GreenButton");
122                     _GreenButton.BackgroundColor = Color.Green;
123                     floatingButton.SetPartContent("button2", _GreenButton, true);
124                     button4.Text = "GreenButton Unset";
125                 }
126                 else
127                 {
128                     _GreenButton.Unrealize();
129                     _GreenButton = null;
130                     floatingButton.SetPartContent("button2", _GreenButton, true);
131                     button4.Text = "GreenButton Unset";
132                 }
133             };
134             button4.Show();
135
136             box.PackEnd(backGround);
137             box.PackEnd(button1);
138             box.PackEnd(button2);
139             box.PackEnd(button3);
140             box.PackEnd(button4);
141         }
142     }
143 }