public void GetVisualsAt_Should_Not_Find_Invisible_Controls_At_Point() { using (var application = UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { var container = new Decorator { Width = 200, Height = 200, Child = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, IsVisible = false, Child = new Border { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, } } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.GetVisualsAt(new Point(100, 100)); Assert.Equal(new[] { container }, result); } }
public void Should_Track_Bounds() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var target = new BoundsTracker(); var control = default(Rectangle); var tree = new Decorator { Padding = new Thickness(10), Child = new Decorator { Padding = new Thickness(5), Child = control = new Rectangle { Width = 15, Height = 15, }, } }; var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); tree.Measure(Size.Infinity); tree.Arrange(new Rect(0, 0, 100, 100)); context.Render(tree); var track = target.Track(control); var results = new List<TransformedBounds?>(); track.Subscribe(results.Add); Assert.Equal(new Rect(0, 0, 15, 15), results[0].Value.Bounds); Assert.Equal(Matrix.CreateTranslation(42, 42), results[0].Value.Transform); } }
public void InputHitTest_Should_Not_Find_Control_Outside_Point() { using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) { var container = new Decorator { Width = 200, Height = 200, Child = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center } }; container.Measure(Size.Infinity); container.Arrange(new Rect(container.DesiredSize)); var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); context.Render(container); var result = container.InputHitTest(new Point(10, 10)); Assert.Equal(container, result); } }
public void Margin_Should_Be_Included_In_DesiredSize() { var decorator = new Decorator { Width = 100, Height = 100, Margin = new Thickness(8), }; decorator.Measure(Size.Infinity); Assert.Equal(new Size(116, 116), decorator.DesiredSize); }
public void Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0() { Control target; var outer = new Decorator { Width = 100, Height = 100, Child = target = new Control { Margin = new Thickness(0, -100, 0, 0), } }; outer.Measure(Size.Infinity); Assert.Equal(0, target.DesiredSize.Height); }