public async Task When_Nested_In_Native_View() { var page = new Native_View_Page(); WindowHelper.WindowContent = page; await WindowHelper.WaitForLoaded(page); var pageBounds = page.GetOnScreenBounds(); var statusBarHeight = pageBounds.Y; // Non-zero on Android var sut = page.SUT; var bounds = sut.GetOnScreenBounds(); bounds.Y -= statusBarHeight; // Status bar height is included in TransformToVisual on Android, but shouldn't be included in VisualTreeHelper.HitTest call var expected = new Rect(25, 205, 80, 40); RectAssert.AreEqual(expected, bounds); GetHitTestability getHitTestability = null; getHitTestability = element => (element as FrameworkElement)?.Background != null ? (element.GetHitTestVisibility(), getHitTestability) : (HitTestability.Invisible, getHitTestability); foreach (var point in GetPointsInside(bounds, perimeterOffset: 5)) { var hitTest = VisualTreeHelper.HitTest(point, getHitTestability); Assert.AreEqual(sut, hitTest.element); } foreach (var point in GetPointsOutside(bounds, perimeterOffset: 5)) { var hitTest = VisualTreeHelper.HitTest(point); Assert.IsNotNull(hitTest.element); Assert.AreNotEqual(sut, hitTest.element); } }
public async Task When_Mask_All() { using (ScreenHelper.OverrideVisibleBounds(new Thickness(0, 34, 0, 65))) { var inner = new Border { Background = new SolidColorBrush(Colors.AliceBlue), Child = new Ellipse { Fill = new SolidColorBrush(Colors.DarkOrange) } }; var container = new Grid { Children = { inner } }; VisibleBoundsPadding.SetPaddingMask(container, VisibleBoundsPadding.PaddingMask.All); WindowHelper.WindowContent = container; await WindowHelper.WaitForLoaded(inner); var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds; var windowBounds = Window.Current.Bounds; RectAssert.AreNotEqual(windowBounds, visibleBounds); var containerBounds = container.GetOnScreenBounds(); var childBounds = inner.GetOnScreenBounds(); RectAssert.AreEqual(windowBounds, containerBounds); RectAssert.AreEqual(visibleBounds, childBounds); } }
public async Task When_GridViewItems_LayoutSlots() { var gridView = new GridView { ItemContainerStyle = TestsResourceHelper.GetResource <Style>("MyGridViewItemStyle") }; var gvi = new GridViewItem(); var gvi2 = new GridViewItem(); gridView.ItemsSource = new[] { gvi, gvi2 }; WindowHelper.WindowContent = gridView; await WindowHelper.WaitForLoaded(gridView); await WindowHelper.WaitForIdle(); RectAssert.AreEqual(new Rect { X = 0d, Y = 0d, Width = 104d, Height = 104d, }, gvi.LayoutSlot); RectAssert.AreEqual(new Rect { X = 0d, Y = 0d, Width = 100d, Height = 100d, }, gvi.LayoutSlotWithMarginsAndAlignments); RectAssert.AreEqual(new Rect { X = 104d, Y = 0d, Width = 104d, Height = 104d, }, gvi2.LayoutSlot); RectAssert.AreEqual(new Rect { X = 104d, Y = 0d, Width = 100d, Height = 100d, }, gvi2.LayoutSlotWithMarginsAndAlignments); }