public void VerifySimpleCollectionScenario() { var objects = new Dictionary <string, WeakReference>(); RunOnUIThread.Execute(() => { var rating = new RatingControl(); objects["Rating"] = new WeakReference(rating); var colorPicker = new ColorPicker(); objects["ColorPicker"] = new WeakReference(colorPicker); var navigationView = new NavigationView(); objects["NavigationView"] = new WeakReference(navigationView); var parallaxView = new ParallaxView(); objects["ParallaxView"] = new WeakReference(parallaxView); var scroller = new Scroller(); objects["Scroller"] = new WeakReference(scroller); if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { var scrollerView = new ScrollerView(); objects["ScrollerView"] = new WeakReference(scrollerView); } }); IdleSynchronizer.Wait(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); RunOnUIThread.Execute(() => CheckLeaks(objects)); }
private void UseScrollerView(ScrollerView sv2) { if (scrollerView == sv2 || sv2 == null) { return; } try { if (scrollerView == null && (chkLogScrollerViewMessages.IsChecked == true || chkLogScrollerMessages.IsChecked == true)) { MUXControlsTestHooks.LoggingMessage += MUXControlsTestHooks_LoggingMessage; if (chkLogScrollerMessages.IsChecked == true) { MUXControlsTestHooks.SetLoggingLevelForType("Scroller", isLoggingInfoLevel: true, isLoggingVerboseLevel: true); } if (chkLogScrollerViewMessages.IsChecked == true) { MUXControlsTestHooks.SetLoggingLevelForType("ScrollerView", isLoggingInfoLevel: true, isLoggingVerboseLevel: true); } } scrollerView = sv2; UpdateIsChildAvailableWidthConstrained(); UpdateIsChildAvailableHeightConstrained(); UpdateHorizontalScrollMode(); UpdateVerticalScrollMode(); UpdateZoomMode(); UpdateWidth(); UpdateHeight(); UpdatePadding(); UpdateHorizontalScrollControllerVisibility(); UpdateVerticalScrollControllerVisibility(); chkIsEnabled.IsChecked = scrollerView.IsEnabled; chkIsTabStop.IsChecked = scrollerView.IsTabStop; UpdateContentWidth(); UpdateContentHeight(); UpdateContentMargin(); Control contentAsC = scrollerView.Content as Control; if (contentAsC != null) { chkIsContentEnabled.IsChecked = contentAsC.IsEnabled; chkIsContentTabStop.IsChecked = contentAsC.IsTabStop; } } catch (Exception ex) { txtExceptionReport.Text = ex.ToString(); lstLogs.Items.Add(ex.ToString()); } }
private void ResetView(ScrollerView scrollerView) { Scroller scroller = ScrollerViewTestHooks.GetScrollerPart(scrollerView); string scrollerId = (VisualTreeHelper.GetParent(scroller) as FrameworkElement).Name + "." + scroller.Name; int viewChangeId = scroller.ChangeOffsets(new ScrollerChangeOffsetsOptions(0.0, 0.0, ScrollerViewKind.Absolute, ScrollerViewChangeKind.DisableAnimation, ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints)); this.fullLogs.Add(scrollerId + " ChangeOffsets requested. Id=" + viewChangeId); viewChangeId = scroller.ChangeZoomFactor(new ScrollerChangeZoomFactorOptions(1.0f, ScrollerViewKind.Absolute, System.Numerics.Vector2.Zero, ScrollerViewChangeKind.DisableAnimation, ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints)); this.fullLogs.Add(scrollerId + " ChangeZoomFactor requested. Id=" + viewChangeId); if (scrollerView == this.scrollerView52) scrollerView52ZoomFactorChangeId = viewChangeId; }
public void VerifyPropertyValuesAfterTemplateApplication() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollerView not supported pre-RS2"); return; } using (PrivateLoggingHelper privateSVLoggingHelper = new PrivateLoggingHelper("ScrollerView", "Scroller")) { ScrollerView scrollerView = null; Rectangle rectangleScrollerViewContent = null; AutoResetEvent scrollerViewLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollerViewUnloadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollerViewContent = new Rectangle(); scrollerView = new ScrollerView(); SetupDefaultUI(scrollerView, rectangleScrollerViewContent, scrollerViewLoadedEvent, scrollerViewUnloadedEvent); }); WaitForEvent("Waiting for Loaded event", scrollerViewLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Verifying ScrollerView property values after Loaded event"); Verify.AreEqual(scrollerView.Content, rectangleScrollerViewContent); Verify.IsNotNull(ScrollerViewTestHooks.GetScrollerPart(scrollerView)); Verify.AreEqual(ScrollerViewTestHooks.GetScrollerPart(scrollerView).Child, rectangleScrollerViewContent); Verify.IsNotNull(scrollerView.HorizontalScrollController); Verify.IsNotNull(scrollerView.VerticalScrollController); Log.Comment("Resetting window content and ScrollerView"); MUXControlsTestApp.App.TestContentRoot = null; scrollerView = null; }); WaitForEvent("Waiting for Unloaded event", scrollerViewUnloadedEvent); 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 ScrollerView not supported pre-RS2"); return; } RunOnUIThread.Execute(() => { ScrollerView scrollerView = new ScrollerView(); Verify.IsNotNull(scrollerView); Log.Comment("Verifying ScrollerView default property values"); Verify.IsNull(scrollerView.Content); Verify.IsNull(ScrollerViewTestHooks.GetScrollerPart(scrollerView)); Verify.IsNull(scrollerView.HorizontalScrollController); Verify.IsNull(scrollerView.VerticalScrollController); Verify.AreEqual(scrollerView.ComputedHorizontalScrollMode, c_defaultComputedHorizontalScrollMode); Verify.AreEqual(scrollerView.ComputedVerticalScrollMode, c_defaultComputedVerticalScrollMode); Verify.AreEqual(scrollerView.InputKind, c_defaultInputKind); Verify.AreEqual(scrollerView.IsChildAvailableWidthConstrained, c_defaultIsChildAvailableWidthConstrained); Verify.AreEqual(scrollerView.IsChildAvailableHeightConstrained, c_defaultIsChildAvailableHeightConstrained); Verify.AreEqual(scrollerView.HorizontalScrollChainingMode, c_defaultHorizontalScrollChainingMode); Verify.AreEqual(scrollerView.VerticalScrollChainingMode, c_defaultVerticalScrollChainingMode); Verify.AreEqual(scrollerView.HorizontalScrollRailingMode, c_defaultHorizontalScrollRailingMode); Verify.AreEqual(scrollerView.VerticalScrollRailingMode, c_defaultVerticalScrollRailingMode); Verify.AreEqual(scrollerView.HorizontalScrollMode, c_defaultHorizontalScrollMode); Verify.AreEqual(scrollerView.VerticalScrollMode, c_defaultVerticalScrollMode); Verify.AreEqual(scrollerView.ZoomMode, c_defaultZoomMode); Verify.AreEqual(scrollerView.ZoomChainingMode, c_defaultZoomChainingMode); Verify.IsGreaterThan(scrollerView.MinZoomFactor, c_defaultMinZoomFactor - c_epsilon); Verify.IsLessThan(scrollerView.MinZoomFactor, c_defaultMinZoomFactor + c_epsilon); Verify.IsGreaterThan(scrollerView.MaxZoomFactor, c_defaultMaxZoomFactor - c_epsilon); Verify.IsLessThan(scrollerView.MaxZoomFactor, c_defaultMaxZoomFactor + c_epsilon); Verify.AreEqual(scrollerView.HorizontalAnchorRatio, c_defaultAnchorRatio); Verify.AreEqual(scrollerView.VerticalAnchorRatio, c_defaultAnchorRatio); Verify.AreEqual(scrollerView.IsAnchoredAtHorizontalExtent, c_defaultIsAnchoredAtExtent); Verify.AreEqual(scrollerView.IsAnchoredAtVerticalExtent, c_defaultIsAnchoredAtExtent); }); }
private void CmbShowScrollerView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.scrollerView11 != null) { if (cmbShowScrollerView.SelectedIndex == 0) { this.scrollerView11.Visibility = Visibility.Visible; this.scrollerView21.Visibility = Visibility.Visible; this.scrollerView31.Visibility = Visibility.Visible; this.scrollerView41.Visibility = Visibility.Visible; this.scrollerView51.Visibility = Visibility.Visible; this.scrollerView12.Visibility = Visibility.Visible; this.scrollerView22.Visibility = Visibility.Visible; this.scrollerView32.Visibility = Visibility.Visible; this.scrollerView42.Visibility = Visibility.Visible; this.scrollerView52.Visibility = Visibility.Visible; this.scrollerView11.Width = double.NaN; this.scrollerView21.Width = double.NaN; this.scrollerView31.Width = double.NaN; this.scrollerView41.Width = double.NaN; this.scrollerView51.Width = double.NaN; this.scrollerView12.Width = double.NaN; this.scrollerView22.Width = double.NaN; this.scrollerView32.Width = double.NaN; this.scrollerView42.Width = double.NaN; this.scrollerView52.Width = double.NaN; this.scrollerView11.Height = double.NaN; this.scrollerView21.Height = double.NaN; this.scrollerView31.Height = double.NaN; this.scrollerView41.Height = double.NaN; this.scrollerView51.Height = double.NaN; this.scrollerView12.Height = double.NaN; this.scrollerView22.Height = double.NaN; this.scrollerView32.Height = double.NaN; this.scrollerView42.Height = double.NaN; this.scrollerView52.Height = double.NaN; for (int rowIndex = 2; rowIndex < 4; rowIndex++) this.rootGrid.RowDefinitions[rowIndex].Height = new GridLength(1, GridUnitType.Star); for (int columnIndex = 0; columnIndex < 5; columnIndex++) this.rootGrid.ColumnDefinitions[columnIndex].Width = new GridLength(1, GridUnitType.Star); } else { this.scrollerView11.Visibility = Visibility.Collapsed; this.scrollerView21.Visibility = Visibility.Collapsed; this.scrollerView31.Visibility = Visibility.Collapsed; this.scrollerView41.Visibility = Visibility.Collapsed; this.scrollerView51.Visibility = Visibility.Collapsed; this.scrollerView12.Visibility = Visibility.Collapsed; this.scrollerView22.Visibility = Visibility.Collapsed; this.scrollerView32.Visibility = Visibility.Collapsed; this.scrollerView42.Visibility = Visibility.Collapsed; this.scrollerView52.Visibility = Visibility.Collapsed; for (int rowIndex = 2; rowIndex < 4; rowIndex++) this.rootGrid.RowDefinitions[rowIndex].Height = GridLength.Auto; for (int columnIndex = 0; columnIndex < 5; columnIndex++) this.rootGrid.ColumnDefinitions[columnIndex].Width = GridLength.Auto; ScrollerView scrollerView = null; switch (cmbShowScrollerView.SelectedIndex) { case 1: scrollerView = this.scrollerView11; break; case 2: scrollerView = this.scrollerView21; break; case 3: scrollerView = this.scrollerView31; break; case 4: scrollerView = this.scrollerView41; break; case 5: scrollerView = this.scrollerView51; break; case 6: scrollerView = this.scrollerView12; break; case 7: scrollerView = this.scrollerView22; break; case 8: scrollerView = this.scrollerView32; break; case 9: scrollerView = this.scrollerView42; break; case 10: scrollerView = this.scrollerView52; break; } scrollerView.Visibility = Visibility.Visible; scrollerView.Width = 300; scrollerView.Height = 400; txtScrollerHorizontalOffset.Text = scrollerView.HorizontalOffset.ToString(); txtScrollerVerticalOffset.Text = scrollerView.VerticalOffset.ToString(); txtScrollerZoomFactor.Text = scrollerView.ZoomFactor.ToString(); } } }
private void SetupDefaultUI( ScrollerView scrollerView, Rectangle rectangleScrollerViewContent = null, AutoResetEvent scrollerViewLoadedEvent = null, AutoResetEvent scrollerViewUnloadedEvent = null, bool setAsContentRoot = true) { Log.Comment("Setting up default UI with ScrollerView" + (rectangleScrollerViewContent == null ? "" : " and Rectangle")); LinearGradientBrush twoColorLGB = new LinearGradientBrush() { StartPoint = new Point(0, 0), EndPoint = new Point(1, 1) }; GradientStop brownGS = new GradientStop() { Color = Colors.Brown, Offset = 0.0 }; twoColorLGB.GradientStops.Add(brownGS); GradientStop orangeGS = new GradientStop() { Color = Colors.Orange, Offset = 1.0 }; twoColorLGB.GradientStops.Add(orangeGS); if (rectangleScrollerViewContent != null) { rectangleScrollerViewContent.Width = c_defaultUIScrollerViewContentWidth; rectangleScrollerViewContent.Height = c_defaultUIScrollerViewContentHeight; rectangleScrollerViewContent.Fill = twoColorLGB; } Verify.IsNotNull(scrollerView); scrollerView.Name = "scrollerView"; scrollerView.Width = c_defaultUIScrollerViewWidth; scrollerView.Height = c_defaultUIScrollerViewHeight; if (rectangleScrollerViewContent != null) { scrollerView.Content = rectangleScrollerViewContent; } if (scrollerViewLoadedEvent != null) { scrollerView.Loaded += (object sender, RoutedEventArgs e) => { Log.Comment("Scroller.Loaded event handler"); scrollerViewLoadedEvent.Set(); }; } if (scrollerViewUnloadedEvent != null) { scrollerView.Unloaded += (object sender, RoutedEventArgs e) => { Log.Comment("Scroller.Unloaded event handler"); scrollerViewUnloadedEvent.Set(); }; } if (setAsContentRoot) { Log.Comment("Setting window content"); MUXControlsTestApp.App.TestContentRoot = scrollerView; } }
public void VerifyScrollerAttachedProperties() { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on pre-RS2 because ScrollerView not supported pre-RS2"); return; } using (PrivateLoggingHelper privateSVLoggingHelper = new PrivateLoggingHelper("ScrollerView", "Scroller")) { ScrollerView scrollerView = null; Rectangle rectangleScrollerViewContent = null; AutoResetEvent scrollerViewLoadedEvent = new AutoResetEvent(false); AutoResetEvent scrollerViewUnloadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollerViewContent = new Rectangle(); scrollerView = new ScrollerView(); SetupDefaultUI(scrollerView, rectangleScrollerViewContent, scrollerViewLoadedEvent, scrollerViewUnloadedEvent); }); WaitForEvent("Waiting for Loaded event", scrollerViewLoadedEvent); RunOnUIThread.Execute(() => { Log.Comment("Setting Scroller-cloned properties to non-default values"); scrollerView.InputKind = ScrollerInputKind.MouseWheel | ScrollerInputKind.Pen; scrollerView.IsChildAvailableWidthConstrained = !c_defaultIsChildAvailableWidthConstrained; scrollerView.IsChildAvailableHeightConstrained = !c_defaultIsChildAvailableHeightConstrained; scrollerView.HorizontalScrollChainingMode = ScrollerChainingMode.Always; scrollerView.VerticalScrollChainingMode = ScrollerChainingMode.Never; scrollerView.HorizontalScrollRailingMode = ScrollerRailingMode.Disabled; scrollerView.VerticalScrollRailingMode = ScrollerRailingMode.Disabled; scrollerView.HorizontalScrollMode = ScrollerScrollMode.Enabled; scrollerView.VerticalScrollMode = ScrollerScrollMode.Disabled; scrollerView.ZoomMode = ScrollerZoomMode.Enabled; scrollerView.ZoomChainingMode = ScrollerChainingMode.Never; scrollerView.MinZoomFactor = 2.0; scrollerView.MaxZoomFactor = 8.0; Log.Comment("Verifying Scroller-cloned non-default properties"); Verify.AreEqual(scrollerView.InputKind, ScrollerInputKind.MouseWheel | ScrollerInputKind.Pen); Verify.AreEqual(scrollerView.IsChildAvailableWidthConstrained, !c_defaultIsChildAvailableWidthConstrained); Verify.AreEqual(scrollerView.IsChildAvailableHeightConstrained, !c_defaultIsChildAvailableHeightConstrained); Verify.AreEqual(scrollerView.HorizontalScrollChainingMode, ScrollerChainingMode.Always); Verify.AreEqual(scrollerView.VerticalScrollChainingMode, ScrollerChainingMode.Never); Verify.AreEqual(scrollerView.HorizontalScrollRailingMode, ScrollerRailingMode.Disabled); Verify.AreEqual(scrollerView.VerticalScrollRailingMode, ScrollerRailingMode.Disabled); Verify.AreEqual(scrollerView.HorizontalScrollMode, ScrollerScrollMode.Enabled); Verify.AreEqual(scrollerView.VerticalScrollMode, ScrollerScrollMode.Disabled); Verify.AreEqual(scrollerView.ComputedHorizontalScrollMode, ScrollerScrollMode.Enabled); Verify.AreEqual(scrollerView.ComputedVerticalScrollMode, ScrollerScrollMode.Disabled); Verify.AreEqual(scrollerView.ZoomMode, ScrollerZoomMode.Enabled); Verify.AreEqual(scrollerView.ZoomChainingMode, ScrollerChainingMode.Never); Verify.IsGreaterThan(scrollerView.MinZoomFactor, 2.0 - c_epsilon); Verify.IsLessThan(scrollerView.MinZoomFactor, 2.0 + c_epsilon); Verify.IsGreaterThan(scrollerView.MaxZoomFactor, 8.0 - c_epsilon); Verify.IsLessThan(scrollerView.MaxZoomFactor, 8.0 + c_epsilon); Log.Comment("Resetting window content and ScrollerView"); MUXControlsTestApp.App.TestContentRoot = null; scrollerView = null; }); WaitForEvent("Waiting for Unloaded event", scrollerViewUnloadedEvent); IdleSynchronizer.Wait(); Log.Comment("Garbage collecting..."); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Log.Comment("Done"); } }