public void ValidateOneScrollerScenario() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport feature is not available below RS5"); return; } var realizationRects = new List <Rect>(); Scroller scroller = null; var scrollCompletedEvent = new AutoResetEvent(false); var zoomCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { var repeater = new ItemsRepeater() { Layout = GetMonitoringLayout(new Size(500, 600), realizationRects), HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; scroller = new Scroller { Content = repeater, Width = 200, Height = 300 }; Content = scroller; Content.UpdateLayout(); Verify.AreEqual(2, realizationRects.Count); Verify.AreEqual(new Rect(0, 0, 0, 0), realizationRects[0]); Verify.AreEqual(new Rect(0, 0, 200, 300), realizationRects[1]); realizationRects.Clear(); scroller.ScrollCompleted += (Scroller sender, ScrollCompletedEventArgs args) => { scrollCompletedEvent.Set(); }; scroller.ZoomCompleted += (Scroller sender, ZoomCompletedEventArgs args) => { zoomCompletedEvent.Set(); }; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { scroller.ScrollTo(0.0, 100.0, new ScrollOptions(AnimationMode.Disabled, SnapPointsMode.Ignore)); }); Verify.IsTrue(scrollCompletedEvent.WaitOne(DefaultWaitTimeInMS)); CompositionPropertySpy.SynchronouslyTickUIThread(1); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(0, 100, 200, 300), realizationRects.Last()); realizationRects.Clear(); scroller.ZoomTo(2.0f, Vector2.Zero, new ZoomOptions(AnimationMode.Disabled, SnapPointsMode.Ignore)); }); Verify.IsTrue(zoomCompletedEvent.WaitOne(DefaultWaitTimeInMS)); CompositionPropertySpy.SynchronouslyTickUIThread(1); RunOnUIThread.Execute(() => { Verify.AreEqual( new Rect(0, 100, 100, 150), realizationRects.Last()); realizationRects.Clear(); }); }
public void ValidateTwoScrollersScenario() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5)) { Log.Warning("Skipping since version is less than RS5 and effective viewport feature is not available below RS5"); return; } var realizationRects = new List <Rect>(); Scroller horizontalScroller = null; Scroller verticalScroller = null; var horizontalScrollCompletedEvent = new AutoResetEvent(false); var verticalScrollCompletedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { var repeater = new ItemsRepeater() { Layout = GetMonitoringLayout(new Size(500, 500), realizationRects), HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; horizontalScroller = new Scroller { Content = repeater, ContentOrientation = ContentOrientation.Horizontal }; // Placing a Grid in between two Scroller controls to avoid // unsupported combined use of facades and ElementCompositionPreview. var grid = new Grid(); grid.Children.Add(horizontalScroller); verticalScroller = new Scroller { Content = grid, Width = 200, Height = 200, ContentOrientation = ContentOrientation.Vertical }; Content = verticalScroller; Content.UpdateLayout(); Verify.AreEqual(2, realizationRects.Count); Verify.AreEqual(new Rect(0, 0, 0, 0), realizationRects[0]); Verify.AreEqual(new Rect(0, 0, 200, 200), realizationRects[1]); realizationRects.Clear(); horizontalScroller.ScrollCompleted += (Scroller sender, ScrollCompletedEventArgs args) => { horizontalScrollCompletedEvent.Set(); }; verticalScroller.ScrollCompleted += (Scroller sender, ScrollCompletedEventArgs args) => { verticalScrollCompletedEvent.Set(); }; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { verticalScroller.ScrollTo(0.0, 100.0, new ScrollOptions(AnimationMode.Disabled, SnapPointsMode.Ignore)); }); Verify.IsTrue(verticalScrollCompletedEvent.WaitOne(DefaultWaitTimeInMS)); CompositionPropertySpy.SynchronouslyTickUIThread(1); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(0, 100, 200, 200), realizationRects.Last()); realizationRects.Clear(); // Max viewport offset is (300, 300). Horizontal viewport offset // is expected to get coerced from 400 to 300. horizontalScroller.ScrollTo(400.0, 100.0, new ScrollOptions(AnimationMode.Disabled, SnapPointsMode.Ignore)); }); Verify.IsTrue(horizontalScrollCompletedEvent.WaitOne(DefaultWaitTimeInMS)); CompositionPropertySpy.SynchronouslyTickUIThread(1); RunOnUIThread.Execute(() => { Verify.AreEqual(new Rect(300, 100, 200, 200), realizationRects.Last()); realizationRects.Clear(); }); }