Ejemplo n.º 1
0
        public void UseAutomationPeer()
        {
            Grid         g                         = CreateGrid(2, 2, 100.0, 100.0);
            GridSplitter splitter                  = CreateGridSplitterThroughCode(1, 1, 5.0, HorizontalAlignment.Left, null, false);
            GridSplitterAutomationPeer peer        = ((GridSplitterAutomationPeer)GridSplitterAutomationPeer.CreatePeerForElement(splitter));
            ITransformProvider         transformer = (ITransformProvider)peer.GetPattern(PatternInterface.Transform);

            g.Children.Add(splitter);
            this.CreateAsyncTest(g,
                                 delegate
            {
                Assert.AreEqual(50.0, g.ColumnDefinitions[0].ActualWidth, "Definition1's default width.");
                Assert.AreEqual(50.0, g.ColumnDefinitions[1].ActualWidth, "Definition2's default width.");
            },
                                 () => transformer.Move(10, 0),
                                 delegate
            {
                Assert.AreEqual(AutomationControlType.Thumb, peer.GetAutomationControlType(), "GridSplitter should be a thumb control type.");
                Assert.AreEqual(splitter.GetType().Name, peer.GetClassName(), "AutomationPeer's ClassName should be 'GridSplitter'");
                Assert.AreEqual(transformer.CanMove, true, "GridSplitter can be moved");
                Assert.AreEqual(transformer.CanResize, false, "GridSplitter cannot be resized");
                Assert.AreEqual(transformer.CanRotate, false, "GridSplitter cannot be rotated");
                Assert.AreEqual(60.0, g.ColumnDefinitions[0].ActualWidth, "Definition1's width should have been changed by the peer's move.");
                Assert.AreEqual(40.0, g.ColumnDefinitions[1].ActualWidth, "Definition2's width should have been changed by the peer's move.");
            });
        }