sync ElmSharp source code latest
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / ScrollerTest4.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     public class ScrollerTest4 : TestCaseBase
23     {
24         public override string TestName => "ScrollerTest4";
25         public override string TestDescription => "To test basic operation of Scroller";
26
27         public override void Run(Window window)
28         {
29             //Conformant conformant = new Conformant(window);
30             //conformant.Show();
31             Box outterBox = new Box(window)
32             {
33                 AlignmentX = -1,
34                 AlignmentY = -1,
35                 WeightX = 1,
36                 WeightY = 1,
37                 IsHorizontal = false,
38             };
39             outterBox.Show();
40
41             var button = new Button(window)
42             {
43                 Text = "Button1",
44                 Color = Color.White,
45             };
46             button.Show();
47             button.Resize(200, 100);
48             button.Move(300, 100);
49
50             var button2 = new Button(window)
51             {
52                 Text = "Button2",
53                 Color = Color.White,
54             };
55             button2.Show();
56             button2.Resize(200, 100);
57             button2.Move(300, 300);
58
59             var button3 = new Button(window)
60             {
61                 Text = "Button3",
62                 Color = Color.White,
63             };
64             button3.Show();
65             button3.Resize(200, 100);
66             button3.Move(300, 500);
67
68             Scroller scroller = new Scroller(window);
69             scroller.Show();
70             scroller.Resize(200, 400);
71             scroller.Move(100, 600);
72
73             Box box = new Box(window)
74             {
75                 AlignmentX = -1,
76                 AlignmentY = -1,
77                 WeightX = 1,
78                 WeightY = 1
79             };
80             box.Show();
81             scroller.SetContent(box);
82
83             var rnd = new Random();
84             for (int i = 0; i < 20; i++)
85             {
86                 int r = rnd.Next(255);
87                 int g = rnd.Next(255);
88                 int b = rnd.Next(255);
89                 Color color = Color.FromRgb(r, g, b);
90                 var colorBox1 = new Label(window)
91                 {
92                     Text = "Label" + i.ToString(),
93                     BackgroundColor = color,
94                     MinimumHeight = 40,
95                 };
96                 colorBox1.Show();
97                 box.PackEnd(colorBox1);
98             }
99
100             Scroller scroller2 = new Scroller(window);
101             scroller2.Show();
102             scroller2.Resize(200, 400);
103             scroller2.Move(700, 600);
104
105             Box box2 = new Box(window)
106             {
107                 MinimumWidth = 400,
108                 MinimumHeight = 200,
109             };
110             box2.BackgroundColor = Color.White;
111             box2.Show();
112             scroller2.SetContent(box2);
113
114             rnd = new Random();
115             for (int i = 0; i < 20; i++)
116             {
117                 int r = rnd.Next(255);
118                 int g = rnd.Next(255);
119                 int b = rnd.Next(255);
120                 Color color = Color.FromRgb(r, g, b);
121                 var colorBox2 = new Label(scroller2)
122                 {
123                     BackgroundColor = color,
124                     MinimumHeight = 40,
125                     Text = "GOGOGO"
126                 };
127                 colorBox2.Show();
128                 box2.PackEnd(colorBox2);
129             }
130
131             //conformant.SetContent(outterBox);
132             //outterBox.PackEnd(button);
133             //outterBox.PackEnd(button2);
134             //outterBox.PackEnd(button3);
135             //outterBox.PackEnd(scroller);
136             //outterBox.PackEnd(scroller2);
137
138             //outterBox.SetLayoutCallback(() =>
139             //{
140             //    scroller.Move(100, 800);
141             //    button.Move(300, 100);
142             //    button2.Move(300, 300);
143             //    button3.Move(300, 500);
144             //    scroller2.Move(700, 800);
145             //});
146         }
147     }
148 }