2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 namespace ElmSharp.Test
22 public class ScrollerTest5 : TestCaseBase
24 public override string TestName => "ScrollerTest5";
25 public override string TestDescription => "To test basic operation of Scroller";
27 int _currentIndex = 0;
29 public override void Run(Window window)
31 Conformant conformant = new Conformant(window);
33 Box outterBox = new Box(window)
42 conformant.SetContent(outterBox);
44 Scroller scroller = new Scroller(window)
50 ScrollBlock = ScrollBlock.Vertical
55 Box innerBox = new Box(window)
64 scroller.SetContent(innerBox);
66 Rectangle[] rects = new Rectangle[5];
67 Random rnd = new Random();
68 for(int i = 0; i < 5; i++)
70 rects[i] = new Rectangle(window)
76 Color = Color.FromRgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
79 rects[i].MinimumWidth = 300;
80 innerBox.PackEnd(rects[i]);
82 innerBox.MinimumWidth = 300 * 5;
86 Button btn = new Button(window)
92 btn.Clicked += (s, e) =>
94 System.Console.WriteLine("current index {0}", _currentIndex);
95 System.Console.WriteLine("Before Current Region : {0}", scroller.CurrentRegion);
96 innerBox.UnPack(rects[_currentIndex]);
97 innerBox.MinimumWidth = 300 * _currentIndex;
98 rects[_currentIndex].Hide();
100 System.Console.WriteLine("After Current Region : {0}", scroller.CurrentRegion);
102 EcoreMainloop.Post(() =>
104 System.Console.WriteLine("On idler Current Region : {0}", scroller.CurrentRegion);
107 EcoreMainloop.AddTimer(0, () =>
109 System.Console.WriteLine("After 0 sec Current Region : {0}", scroller.CurrentRegion);
113 scroller.Scrolled += (s, e) =>
115 System.Console.WriteLine("Scrolled to {0}", scroller.CurrentRegion);
120 outterBox.PackEnd(btn);
121 outterBox.PackEnd(scroller);