Пример #1
0
        private void VerifyViewMode(ViewMode mode)
        {
            // Verify configuration is correct for mode
            TwoPaneViewMode expectedConfiguration = TwoPaneViewMode.SinglePane;

            switch (mode)
            {
            case ViewMode.LeftRight:
            case ViewMode.RightLeft:
                expectedConfiguration = TwoPaneViewMode.Wide;
                break;

            case ViewMode.TopBottom:
            case ViewMode.BottomTop:
                expectedConfiguration = TwoPaneViewMode.Tall;
                break;
            }

            TextBlock configurationTextBlock = new TextBlock(FindElement.ByName("ConfigurationTextBlock"));

            Verify.AreEqual(expectedConfiguration.ToString(), configurationTextBlock.DocumentText);

            // Verify panes are actually being shown correctly
            ElementCache.Clear();
            UIObject paneContent1 = TryFindElement.ByName("Content1");
            UIObject paneContent2 = TryFindElement.ByName("Content2");

            if (mode != ViewMode.Pane2Only)
            {
                Verify.IsNotNull(paneContent1, "Expected to find pane1");
                Log.Comment("Content 1 dimensions: " + paneContent1.BoundingRectangle.ToString());
            }

            if (mode != ViewMode.Pane1Only)
            {
                Verify.IsNotNull(paneContent2, "Expected to find pane2");
                Log.Comment("Content 2 dimensions: " + paneContent2.BoundingRectangle.ToString());
            }

            if (mode == ViewMode.Pane2Only)
            {
                Verify.IsNull(paneContent1, "Expected not to find pane1");
            }

            if (mode == ViewMode.Pane1Only)
            {
                Verify.IsNull(paneContent2, "Expected not to find pane2");
            }

            switch (mode)
            {
            case ViewMode.LeftRight:
            case ViewMode.RightLeft:
                Verify.AreEqual(paneContent1.BoundingRectangle.Top, paneContent2.BoundingRectangle.Top, "Verify panes are horizontally aligned");
                if (mode == ViewMode.LeftRight)
                {
                    Verify.IsGreaterThanOrEqual(paneContent2.BoundingRectangle.Left, paneContent1.BoundingRectangle.Right, "Verify left/right pane placement");
                }
                else
                {
                    Verify.IsGreaterThanOrEqual(paneContent1.BoundingRectangle.Left, paneContent2.BoundingRectangle.Right, "Verify right/left pane placement");
                }
                break;

            case ViewMode.TopBottom:
            case ViewMode.BottomTop:
                Verify.AreEqual(paneContent1.BoundingRectangle.Left, paneContent2.BoundingRectangle.Left, "Verify panes are vertically aligned");
                if (mode == ViewMode.TopBottom)
                {
                    Verify.IsGreaterThanOrEqual(paneContent2.BoundingRectangle.Top, paneContent1.BoundingRectangle.Bottom, "Verify top/bottom pane placement");
                }
                else
                {
                    Verify.IsGreaterThanOrEqual(paneContent1.BoundingRectangle.Top, paneContent2.BoundingRectangle.Bottom, "Verify bottom/top pane placement");
                }
                break;
            }
        }
Пример #2
0
        private void AssertViewMode(ViewMode mode)
        {
            // Assert configuration is correct for mode
            TwoPaneViewMode expectedConfiguration = TwoPaneViewMode.SinglePane;

            switch (mode)
            {
            case ViewMode.LeftRight:
            case ViewMode.RightLeft:
                expectedConfiguration = TwoPaneViewMode.Wide;
                break;

            case ViewMode.TopBottom:
            case ViewMode.BottomTop:
                expectedConfiguration = TwoPaneViewMode.Tall;
                break;
            }

            Query configurationTextBlock = q => q.All().Marked("ConfigurationTextBlock");

            Assert.AreEqual(expectedConfiguration.ToString(), new QueryEx(configurationTextBlock).GetText());

            // Assert panes are actually being shown correctly
            QueryEx paneContent1Query = new QueryEx(q => q.All().Marked("TwoPaneView").Descendant().Marked("PART_Pane1ScrollViewer"));
            QueryEx paneContent2Query = new QueryEx(q => q.All().Marked("TwoPaneView").Descendant().Marked("PART_Pane2ScrollViewer"));

            var paneContent1 = _app.Query(paneContent1Query).FirstOrDefault();
            var paneContent2 = _app.Query(paneContent2Query).FirstOrDefault();

            var paneContent1BoundingRectangle = _app.Query(paneContent1Query).First().Rect;
            var paneContent2BoundingRectangle = _app.Query(paneContent2Query).First().Rect;

            var pane1Visibility = paneContent1Query.GetDependencyPropertyValue <string>("Visibility");
            var pane2Visibility = paneContent2Query.GetDependencyPropertyValue <string>("Visibility");

            if (mode != ViewMode.Pane2Only)
            {
                Assert.AreEqual("Visible", paneContent1Query.GetDependencyPropertyValue <string>("Visibility"), "Expected to find pane1");
                Console.WriteLine("Content 1 dimensions: " + paneContent1BoundingRectangle.ToString());
            }

            if (mode != ViewMode.Pane1Only)
            {
                Assert.AreEqual("Visible", paneContent2Query.GetDependencyPropertyValue <string>("Visibility"), "Expected to find pane2");
                Console.WriteLine("Content 2 dimensions: " + paneContent2BoundingRectangle.ToString());
            }

            if (mode == ViewMode.Pane2Only)
            {
                Assert.AreEqual("Collapsed", paneContent1Query.GetDependencyPropertyValue <string>("Visibility"), "Expected not to find pane1");
            }

            if (mode == ViewMode.Pane1Only)
            {
                Assert.AreEqual("Collapsed", paneContent2Query.GetDependencyPropertyValue <string>("Visibility"), "Expected not to find pane2");
            }

            switch (mode)
            {
            case ViewMode.LeftRight:
            case ViewMode.RightLeft:
                Assert.AreEqual(paneContent1BoundingRectangle.Y, paneContent2BoundingRectangle.Y, "Assert panes are horizontally aligned");
                if (mode == ViewMode.LeftRight)
                {
                    Assert.IsTrue(paneContent2BoundingRectangle.X >= paneContent1BoundingRectangle.Right, "Assert left/right pane placement");
                }
                else
                {
                    Assert.IsTrue(paneContent1BoundingRectangle.X >= -paneContent2BoundingRectangle.Right, "Assert right/left pane placement");
                }
                break;

            case ViewMode.TopBottom:
            case ViewMode.BottomTop:
                Assert.AreEqual(paneContent1BoundingRectangle.X, paneContent2BoundingRectangle.X, "Assert panes are vertically aligned");
                if (mode == ViewMode.TopBottom)
                {
                    Assert.IsTrue(paneContent2BoundingRectangle.Y >= paneContent1BoundingRectangle.Bottom, "Assert top/bottom pane placement");
                }
                else
                {
                    Assert.IsTrue(paneContent1BoundingRectangle.Y >= paneContent2BoundingRectangle.Bottom, "Assert bottom/top pane placement");
                }
                break;
            }
        }