90d7015fc149d09cafa32365913aa9946b8ebdfd
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / ScrollerTest3.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 ScrollerTest3 : TestCaseBase
23     {
24         public override string TestName => "ScrollerTest3";
25         public override string TestDescription => "To test ScrollTo 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             Scroller scroller = new Scroller(window)
41             {
42                 AlignmentX = -1,
43                 AlignmentY = -1,
44                 WeightX = 1,
45                 WeightY = 1,
46                 ScrollBlock = ScrollBlock.Vertical,
47                 HorizontalPageScrollLimit = 1,
48             };
49             scroller.SetPageSize(1.0, 1.0);
50             scroller.Show();
51
52             Box box = new Box(window)
53             {
54                 AlignmentX = -1,
55                 AlignmentY = -1,
56                 WeightX = 1,
57                 WeightY = 1
58             };
59             box.Show();
60             scroller.SetContent(box);
61
62             for (int i = 0; i < 30; i++)
63             {
64                 Label addlabel = new Label(window)
65                 {
66                     Text = i + " Label Test",
67                     AlignmentX = -1,
68                     AlignmentY = -1,
69                     WeightX = 1,
70                     WeightY = 1,
71                 };
72                 addlabel.Show();
73                 box.PackEnd(addlabel);
74             }
75
76             conformant.SetContent(outterBox);
77             outterBox.PackEnd(scroller);
78
79             Button prev = new Button(window)
80             {
81                 AlignmentX = -1,
82                 WeightX = 1,
83                 Text = "Prev"
84             };
85             Button next = new Button(window)
86             {
87                 AlignmentX = -1,
88                 WeightX = 1,
89                 Text = "next"
90             };
91             prev.Clicked += (s, e) =>
92             {
93                 Rect region = new Rect(0, 0, scroller.Geometry.Width, scroller.Geometry.Width);
94                 Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width);
95                 scroller.ScrollTo(region, true);
96             };
97             next.Clicked += (s, e) =>
98             {
99                 Rect region = new Rect(0, scroller.Geometry.Height, scroller.Geometry.Width, scroller.Geometry.Height);
100                 Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width);
101                 scroller.ScrollTo(region, true);
102             };
103             prev.Show();
104             next.Show();
105             outterBox.PackEnd(prev);
106             outterBox.PackEnd(next);
107
108             scroller.DragStart += Scroller_DragStart;
109             scroller.DragStop += Scroller_DragStop;
110         }
111
112         private void Scroller_DragStop(object sender, EventArgs e)
113         {
114             Console.WriteLine("Drag stop");
115         }
116
117         private void Scroller_DragStart(object sender, EventArgs e)
118         {
119             Console.WriteLine("Drag start");
120         }
121     }
122 }