b968e530ea38788406a05cdd9b30a0662a8d31fa
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Wearable.Test / TC / CircleScrollerTest2.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.Wearable;
19
20 namespace ElmSharp.Test.TC
21 {
22     public class CircleScrollerTest2 : TestCaseBase
23     {
24         public override string TestName => "CircleScrollerTest2";
25         public override string TestDescription => "To test basic operation of CircleScroller";
26
27         public override void Run(Window window)
28         {
29             Layout layout = new Layout(window);
30             layout.Show();
31             layout.Move(0, 0);
32             layout.Resize(360, 360);
33
34             CircleScroller circleScroller = new CircleScroller(layout)
35             {
36                 AlignmentX = -1,
37                 AlignmentY = -1,
38                 WeightX = 1,
39                 WeightY = 1,
40                 VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
41                 HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto,
42             };
43             circleScroller.Show();
44             circleScroller.Move(0, 0);
45             circleScroller.Resize(360, 360);
46             circleScroller.Lower();
47
48             Box box = new Box(window)
49             {
50                 AlignmentX = -1,
51                 AlignmentY = -1,
52                 WeightX = 1,
53                 WeightY = 1,
54                 IsHorizontal = true,
55             };
56             box.Show();
57             circleScroller.SetContent(box);
58
59             var rnd = new Random();
60             for (int i = 0; i < 10; i++)
61             {
62                 int r = rnd.Next(255);
63                 int g = rnd.Next(255);
64                 int b = rnd.Next(255);
65                 Color color = Color.FromRgb(r, g, b);
66                 Rectangle colorBox = new Rectangle(window)
67                 {
68                     AlignmentX = -1,
69                     AlignmentY = -1,
70                     WeightX = 1,
71                     WeightY = 1,
72                     Color = color,
73                     MinimumWidth = window.ScreenSize.Width,
74                 };
75                 colorBox.Show();
76                 box.PackEnd(colorBox);
77             }
78             circleScroller.Scrolled += (s, e) => Log.Debug(TestName, "Horizental Circle Scroll Scrolled");
79         }
80     }
81 }