Beispiel #1
0
        public static void Main()
        {
            var uiElementTest = new UIElementLayeringTests();
            uiElementTest.TestAll();

            var panelTest = new PanelTests();
            panelTest.TestAll();

            var controlTest = new ControlTests();
            controlTest.TestAll();

            var stackPanelTest = new StackPanelTests();
            stackPanelTest.TestAll();

            var canvasTest = new CanvasTests();
            canvasTest.TestAll();

            var contentControlTest = new ContentControlTest();
            contentControlTest.TestAll();

            var eventManagerTest = new EventManagerTests();
            eventManagerTest.TestAll();

            var routedEventArgTest = new RoutedEventArgsTest();
            routedEventArgTest.TestAll();

            var uiElementEventTest = new UIElementEventTests();
            uiElementEventTest.TestAll();

            var gridTest = new GridTests();
            gridTest.TestAll();
        }
Beispiel #2
0
        public void TestMeasureOverrideAbsolute()
        {
            ResetState();

            // check that desired size is null if no children
            Measure(1000 * rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, DesiredSize);

            var child = new MeasureValidator();

            Children.Add(child);
            child.Margin = Thickness.UniformCuboid(10);

            // check canvas desired size and child provided size with one child out of the available zone
            var availableSize    = new Vector3(100, 200, 300);
            var childDesiredSize = new Vector3(30, 80, 130);

            var pinOrigin = Vector3.Zero;

            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(49, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(151, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(100, 99, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(100, 301, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(100, 200, 149));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(100, 200, 451));

            pinOrigin = Vector3.One;
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(0, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(101, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(50, 0, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(50, 201, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(50, 100, 0));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(50, 100, 301));

            pinOrigin = 0.5f * Vector3.One;
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 180, 280), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(24, 150, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 180, 280), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(126, 150, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 0, 280), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(75, 49, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 0, 280), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(75, 251, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180, 0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(75, 150, 74));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180, 0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(75, 150, 376));

            // check canvas desired size and child provided size with one child in the available zone
            var position = availableSize / 2;

            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 130), position, Vector3.Zero, availableSize, new Vector3(100, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 130), position, Vector3.One, availableSize, new Vector3(50, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180, 280), position, 0.5f * Vector3.One, availableSize, new Vector3(75, 150, 225));

            // check that canvas desired size with several children
            ResetState();
            var child1 = new CanvasTests();
            var child2 = new CanvasTests();
            var child3 = new CanvasTests();

            Children.Add(child1);
            Children.Add(child2);
            Children.Add(child3);
            child1.Margin = new Thickness(10, 20, 30, 40, 50, 60);
            child2.Margin = new Thickness(60, 50, 40, 30, 20, 10);
            child3.Margin = new Thickness(1, 2, 3, 4, 5, 6);
            child1.Width  = 100;
            child1.Height = 200;
            child1.Depth  = 300;
            child2.Width  = 10;
            child2.Height = 20;
            child2.Depth  = 30;
            child3.Width  = 300;
            child3.Height = 200;
            child3.Depth  = 100;
            child1.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(1000, 1100, 1200));
            child1.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(0, 0, 1));
            child2.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(1050, 1150, 1200));
            child2.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(1, 1, 0));
            child3.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(500, 600, 700));
            child3.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(0.5f, 0.5f, 0.5f));
            Measure(Vector3.Zero);
            Assert.AreEqual(new Vector3(1150, 1370, 1280), DesiredSize);
        }
Beispiel #3
0
        public void TestMeasureOverrideAbsolute()
        {
            ResetState();

            // check that desired size is null if no children
            Measure(1000 * rand.NextVector3());
            Assert.AreEqual(Vector3.Zero, DesiredSize);

            var child = new MeasureValidator();
            Children.Add(child);
            child.Margin = Thickness.UniformCuboid(10);

            // check canvas desired size and child provided size with one child out of the available zone
            var availableSize = new Vector3(100, 200, 300);
            var childDesiredSize = new Vector3(30, 80, 130);

            var pinOrigin = Vector3.Zero;
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(49, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(151, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(100, 99, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(100, 301, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80,  0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(100, 200, 149));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80,  0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(100, 200, 451));

            pinOrigin = Vector3.One;
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(0, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 80, 130), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(101, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(50, 0, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 0, 130), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(50, 201, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80,  0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(50, 100, 0));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80,  0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(50, 100, 301));

            pinOrigin = 0.5f * Vector3.One;
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 180, 280), new Vector3(-1, 100, 150), pinOrigin, availableSize, new Vector3(24, 150, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(0, 180, 280), new Vector3(101, 100, 150), pinOrigin, availableSize, new Vector3(126, 150, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 0, 280), new Vector3(50, -1, 150), pinOrigin, availableSize, new Vector3(75, 49, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 0, 280), new Vector3(50, 201, 150), pinOrigin, availableSize, new Vector3(75, 251, 225));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180,  0), new Vector3(50, 100, -1), pinOrigin, availableSize, new Vector3(75, 150, 74));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180,  0), new Vector3(50, 100, 301), pinOrigin, availableSize, new Vector3(75, 150, 376));

            // check canvas desired size and child provided size with one child in the available zone
            var position = availableSize / 2;
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 130), position, Vector3.Zero, availableSize, new Vector3(100, 200, 300));
            TestOutOfBounds(child, childDesiredSize, new Vector3(30, 80, 130), position, Vector3.One, availableSize, new Vector3(50, 100, 150));
            TestOutOfBounds(child, childDesiredSize, new Vector3(80, 180, 280), position, 0.5f * Vector3.One, availableSize, new Vector3(75, 150, 225));

            // check that canvas desired size with several children
            ResetState();
            var child1 = new CanvasTests();
            var child2 = new CanvasTests();
            var child3 = new CanvasTests();
            Children.Add(child1);
            Children.Add(child2);
            Children.Add(child3);
            child1.Margin = new Thickness(10, 20, 30, 40, 50, 60);
            child2.Margin = new Thickness(60, 50, 40, 30, 20, 10);
            child3.Margin = new Thickness(1, 2, 3, 4, 5, 6);
            child1.Width = 100;
            child1.Height = 200;
            child1.Depth = 300;
            child2.Width = 10;
            child2.Height = 20;
            child2.Depth = 30;
            child3.Width = 300;
            child3.Height = 200;
            child3.Depth = 100;
            child1.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(1000, 1100, 1200));
            child1.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(0, 0, 1));
            child2.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(1050, 1150, 1200));
            child2.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(1, 1, 0));
            child3.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(500, 600, 700));
            child3.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(0.5f, 0.5f, 0.5f));
            Measure(Vector3.Zero);
            Assert.AreEqual(new Vector3(1150, 1370, 1280), DesiredSize);
        }