public void VerifyDefaultPropertyValues() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollView not supported pre-RS2"); return; } RunOnUIThread.Execute(() => { ScrollView scrollView = new ScrollView(); Verify.IsNotNull(scrollView); Log.Comment("Verifying ScrollView default property values"); Verify.IsNull(scrollView.Content); Verify.IsNull(ScrollViewTestHooks.GetScrollPresenterPart(scrollView)); Verify.IsNull(scrollView.HorizontalScrollController); Verify.IsNull(scrollView.VerticalScrollController); #if USE_SCROLLMODE_AUTO Verify.AreEqual(scrollView.ComputedHorizontalScrollMode, c_defaultComputedHorizontalScrollMode); Verify.AreEqual(scrollView.ComputedVerticalScrollMode, c_defaultComputedVerticalScrollMode); #endif Verify.AreEqual(scrollView.IgnoredInputKind, c_defaultIgnoredInputKind); Verify.AreEqual(scrollView.ContentOrientation, c_defaultContentOrientation); Verify.AreEqual(scrollView.HorizontalScrollChainingMode, c_defaultHorizontalScrollChainingMode); Verify.AreEqual(scrollView.VerticalScrollChainingMode, c_defaultVerticalScrollChainingMode); Verify.AreEqual(scrollView.HorizontalScrollRailingMode, c_defaultHorizontalScrollRailingMode); Verify.AreEqual(scrollView.VerticalScrollRailingMode, c_defaultVerticalScrollRailingMode); Verify.AreEqual(scrollView.HorizontalScrollMode, c_defaultHorizontalScrollMode); Verify.AreEqual(scrollView.VerticalScrollMode, c_defaultVerticalScrollMode); Verify.AreEqual(scrollView.ZoomMode, c_defaultZoomMode); Verify.AreEqual(scrollView.ZoomChainingMode, c_defaultZoomChainingMode); Verify.IsGreaterThan(scrollView.MinZoomFactor, c_defaultMinZoomFactor - c_epsilon); Verify.IsLessThan(scrollView.MinZoomFactor, c_defaultMinZoomFactor + c_epsilon); Verify.IsGreaterThan(scrollView.MaxZoomFactor, c_defaultMaxZoomFactor - c_epsilon); Verify.IsLessThan(scrollView.MaxZoomFactor, c_defaultMaxZoomFactor + c_epsilon); Verify.AreEqual(scrollView.HorizontalAnchorRatio, c_defaultAnchorRatio); Verify.AreEqual(scrollView.VerticalAnchorRatio, c_defaultAnchorRatio); Verify.AreEqual(scrollView.ExtentWidth, 0.0); Verify.AreEqual(scrollView.ExtentHeight, 0.0); Verify.AreEqual(scrollView.ViewportWidth, 0.0); Verify.AreEqual(scrollView.ViewportHeight, 0.0); Verify.AreEqual(scrollView.ScrollableWidth, 0.0); Verify.AreEqual(scrollView.ScrollableHeight, 0.0); }); }
public void VerifyAnchorCandidateRegistration() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollView not supported pre-RS2"); return; } using (PrivateLoggingHelper privateSVLoggingHelper = new PrivateLoggingHelper("ScrollView", "ScrollPresenter")) { int expectedAnchorCandidatesCount = 0; ScrollPresenter scrollPresenter = null; ScrollView scrollView = null; Rectangle rectangleScrollViewContent = null; AutoResetEvent scrollViewLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollViewAnchorRequestedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollViewContent = new Rectangle(); scrollView = new ScrollView(); scrollView.HorizontalAnchorRatio = 0.1; SetupDefaultUI(scrollView, rectangleScrollViewContent, scrollViewLoadedEvent); scrollView.AnchorRequested += (ScrollView sender, ScrollingAnchorRequestedEventArgs args) => { Log.Comment("ScrollView.AnchorRequested event handler. args.AnchorCandidates.Count: " + args.AnchorCandidates.Count); Verify.IsNull(args.AnchorElement); Verify.AreEqual(expectedAnchorCandidatesCount, args.AnchorCandidates.Count); scrollViewAnchorRequestedEvent.Set(); }; }); WaitForEvent("Waiting for Loaded event", scrollViewLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Accessing inner ScrollPresenter control"); scrollPresenter = ScrollViewTestHooks.GetScrollPresenterPart(scrollView); Log.Comment("Registering Rectangle as anchor candidate"); scrollView.RegisterAnchorCandidate(rectangleScrollViewContent); expectedAnchorCandidatesCount = 1; Log.Comment("Forcing ScrollPresenter layout"); scrollPresenter.InvalidateArrange(); }); WaitForEvent("Waiting for AnchorRequested event", scrollViewAnchorRequestedEvent); RunOnUIThread.Execute(() => { Log.Comment("Unregistering Rectangle as anchor candidate"); scrollView.UnregisterAnchorCandidate(rectangleScrollViewContent); expectedAnchorCandidatesCount = 0; Log.Comment("Forcing ScrollPresenter layout"); scrollPresenter.InvalidateArrange(); }); WaitForEvent("Waiting for AnchorRequested event", scrollViewAnchorRequestedEvent); } }