public void VerifyPropertyValuesAfterTemplateApplication() { 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")) { ScrollView scrollView = null; Rectangle rectangleScrollViewContent = null; AutoResetEvent scrollViewLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollViewUnloadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollViewContent = new Rectangle(); scrollView = new ScrollView(); SetupDefaultUI(scrollView, rectangleScrollViewContent, scrollViewLoadedEvent, scrollViewUnloadedEvent); }); WaitForEvent("Waiting for Loaded event", scrollViewLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Verifying ScrollView property values after Loaded event"); Verify.AreEqual(scrollView.Content, rectangleScrollViewContent); Verify.IsNotNull(ScrollViewTestHooks.GetScrollPresenterPart(scrollView)); Verify.AreEqual(ScrollViewTestHooks.GetScrollPresenterPart(scrollView).Content, rectangleScrollViewContent); Verify.IsNotNull(scrollView.HorizontalScrollController); Verify.IsNotNull(scrollView.VerticalScrollController); Verify.AreEqual(scrollView.ExtentWidth, c_defaultUIScrollViewContentWidth); Verify.AreEqual(scrollView.ExtentHeight, c_defaultUIScrollViewContentHeight); Verify.AreEqual(scrollView.ViewportWidth, c_defaultUIScrollViewWidth); Verify.AreEqual(scrollView.ViewportHeight, c_defaultUIScrollViewHeight); Verify.AreEqual(scrollView.ScrollableWidth, c_defaultUIScrollViewContentWidth - c_defaultUIScrollViewWidth); Verify.AreEqual(scrollView.ScrollableHeight, c_defaultUIScrollViewContentHeight - c_defaultUIScrollViewHeight); Log.Comment("Resetting window content and ScrollView"); Content = null; scrollView = null; }); WaitForEvent("Waiting for Unloaded event", scrollViewUnloadedEvent); IdleSynchronizer.Wait(); Log.Comment("Garbage collecting..."); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Log.Comment("Done"); } }
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); } }