Exemplo n.º 1
0
        public void KeyboardTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Set focus inside the TabView");
                UIObject tabContent = FindElement.ByName("FirstTabContent");
                tabContent.SetFocus();

                TabItem firstTab  = FindElement.ByName <TabItem>("FirstTab");
                TabItem secondTab = FindElement.ByName <TabItem>("SecondTab");
                TabItem lastTab   = FindElement.ByName <TabItem>("LastTab");

                Button addButton = FindElement.ById <Button>("AddButton");

                Verify.IsTrue(firstTab.IsSelected, "First Tab should be selected initially");
                Button firstTabButton = FindElement.ByName <Button>("FirstTabButton");
                Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should start in the First Tab");

                // Ctrl+Tab to the second tab:
                KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control);
                Verify.IsTrue(secondTab.IsSelected, "Ctrl+Tab should move selection to Second Tab");
                Button secondTabButton = FindElement.ByName <Button>("SecondTabButton");
                Verify.IsTrue(secondTabButton.HasKeyboardFocus, "Focus should move to the content of the Second Tab");

                // Ctrl+Shift+Tab to the first tab:
                KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift);
                Verify.IsTrue(firstTab.IsSelected, "Ctrl+Shift+Tab should move selection to First Tab");
                Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should move to the content of the First Tab");

                // Ctrl+Shift+Tab to the last tab:
                KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift);
                Verify.IsTrue(lastTab.IsSelected, "Ctrl+Shift+Tab should move selection to Last Tab");
                Verify.IsTrue(lastTab.HasKeyboardFocus, "Focus should move to the last tab (since it has no focusable content)");

                // Ctrl+Tab to the first tab:
                KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control);
                Verify.IsTrue(firstTab.IsSelected, "Ctrl+Tab should move selection to First Tab");
                Verify.IsTrue(firstTab.HasKeyboardFocus, "Focus should move to the first tab");

                KeyboardHelper.PressKey(Key.Up);
                Verify.IsTrue(firstTab.HasKeyboardFocus, "Up key should not move focus");

                KeyboardHelper.PressKey(Key.Down);
                Verify.IsTrue(firstTab.HasKeyboardFocus, "Down key should not move focus");

                KeyboardHelper.PressKey(Key.Right);
                Verify.IsTrue(secondTab.HasKeyboardFocus, "Right Key should move focus to the second tab");

                KeyboardHelper.PressKey(Key.Left);
                Verify.IsTrue(firstTab.HasKeyboardFocus, "Left Key should move focus to the first tab");

                addButton.SetFocus();
                Verify.IsTrue(addButton.HasKeyboardFocus, "AddButton should have keyboard focus");

                KeyboardHelper.PressKey(Key.Left);
                Verify.IsTrue(lastTab.HasKeyboardFocus, "Left Key from AddButton should move focus to last tab");

                KeyboardHelper.PressKey(Key.Right);
                Verify.IsTrue(addButton.HasKeyboardFocus, "Right Key from Last Tab should move focus to Add Button");

                firstTab.SetFocus();

                // Ctrl+f4 to close the tab:
                Log.Comment("Verify that pressing ctrl-f4 closes the tab");
                KeyboardHelper.PressKey(Key.F4, ModifierKey.Control);
                Wait.ForIdle();

                VerifyElement.NotFound("FirstTab", FindBy.Name);

                // Move focus to the second tab content
                secondTabButton.SetFocus();
                Wait.ForIdle();
            }
        }
Exemplo n.º 2
0
        public void BasicCalculationTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that calculations don't work if AcceptsCalculations is false");
                EnterText(numBox, "5 + 3");
                Verify.AreEqual(0, numBox.Value);

                Check("CalculationCheckBox");

                int          numErrors  = 0;
                const double resetValue = 1234;

                Dictionary <string, double> expressions = new Dictionary <string, double>
                {
                    // Valid expressions. None of these should evaluate to the reset value.
                    { "5", 5 },
                    { "-358", -358 },
                    { "12.34", 12.34 },
                    { "5 + 3", 8 },
                    { "12345 + 67 + 890", 13302 },
                    { "000 + 0011", 11 },
                    { "5 - 3 + 2", 4 },
                    { "3 + 2 - 5", 0 },
                    { "9 - 2 * 6 / 4", 6 },
                    { "9 - -7", 16 },
                    { "9-3*2", 3 },         // no spaces
                    { " 10  *   6  ", 60 }, // extra spaces
                    { "10 /( 2 + 3 )", 2 },
                    { "5 * -40", -200 },
                    { "(1 - 4) / (2 + 1)", -1 },
                    { "3 * ((4 + 8) / 2)", 18 },
                    { "23 * ((0 - 48) / 8)", -138 },
                    { "((74-71)*2)^3", 216 },
                    { "2 - 2 ^ 3", -6 },
                    { "2 ^ 2 ^ 2 / 2 + 9", 17 },
                    { "5 ^ -2", 0.04 },
                    { "5.09 + 14.333", 19.423 },
                    { "2.5 * 0.35", 0.875 },
                    { "-2 - 5", -7 },       // begins with negative number
                    { "(10)", 10 },         // number in parens
                    { "(-9)", -9 },         // negative number in parens
                    { "0^0", 1 },           // who knew?

                    // These should not parse, which means they will reset back to the previous value.
                    { "5x + 3y", resetValue },        // invalid chars
                    { "5 + (3", resetValue },         // mismatched parens
                    { "9 + (2 + 3))", resetValue },
                    { "(2 + 3)(1 + 5)", resetValue }, // missing operator
                    { "9 + + 7", resetValue },        // extra operators
                    { "9 - * 7", resetValue },
                    { "9 - - 7", resetValue },
                    { "+9", resetValue },
                    { "1 / 0", resetValue },          // divide by zero

                    // These don't currently work, but maybe should.
                    { "-(3 + 5)", resetValue }, // negative sign in front of parens -- should be -8
                };
                foreach (KeyValuePair <string, double> pair in expressions)
                {
                    numBox.SetValue(resetValue);
                    Wait.ForIdle();

                    EnterText(numBox, pair.Key);
                    string output = "Expression '" + pair.Key + "' - expected: " + pair.Value + ", actual: " + numBox.Value;
                    if (Math.Abs(pair.Value - numBox.Value) > 0.00001)
                    {
                        numErrors++;
                        Log.Warning(output);
                    }
                    else
                    {
                        Log.Comment(output);
                    }
                }

                Verify.AreEqual(0, numErrors);
            }
        }
 static Edit Edit(string name) => FindElement.ByName <Edit>(name);
        public void BasicInteractionTest()
        {
            using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page.
            {
                Log.Comment("Retrieve rating control as generic UIElement");
                UIObject ratingUIObject = FindElement.ByName("TestRatingControl");
                Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl");

                Log.Comment("Retrieve the text block as a TextBlock");
                TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl"));

                Log.Comment("Verify a tap on the third star sets Rating to 3");
                InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("3", textBlock.DocumentText);

                Log.Comment("Verify a tap on the third star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);

                Button phButton = new Button(FindElement.ByName("PHButton"));
                InputHelper.Tap(phButton);

                Log.Comment("Verify a tap on the first star sets Rating to 1");
                InputHelper.Tap(ratingUIObject, 12, RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("1", textBlock.DocumentText);

                Log.Comment("Verify a swipe off the left sets Rating to NOTHING");
                InputHelper.Pan(ratingUIObject, 200, Direction.West);
                Verify.AreEqual("!", textBlock.DocumentText);

                Log.Comment("Verify a right key on an unset Rating, sets rating to 1");
                KeyboardHelper.PressKey(ratingUIObject, Key.Right);

                Verify.AreEqual("1", textBlock.DocumentText);

                Log.Comment("Verify a left key on an RTL rating increases the rating.");
                TestSetupHelper.SetInnerFrameFlowDirection(FlowDirection.RightToLeft);
                Wait.ForIdle();

                KeyboardHelper.PressKey(ratingUIObject, Key.Left);
                Verify.AreEqual("2", textBlock.DocumentText);

                Log.Comment("Verify home/end keys in RTL");
                KeyboardHelper.PressKey(ratingUIObject, Key.Home);
                Verify.AreEqual("!", textBlock.DocumentText);

                KeyboardHelper.PressKey(ratingUIObject, Key.End);
                Verify.AreEqual("5", textBlock.DocumentText);

                Log.Comment("Verify up down keys in RTL");
                KeyboardHelper.PressKey(ratingUIObject, Key.Down);
                Verify.AreEqual("4", textBlock.DocumentText);

                KeyboardHelper.PressKey(ratingUIObject, Key.Up);
                Verify.AreEqual("5", textBlock.DocumentText);

                TestSetupHelper.SetInnerFrameFlowDirection(FlowDirection.LeftToRight);
                Wait.ForIdle();

                Log.Comment("Verify home/end keys in LTR");
                KeyboardHelper.PressKey(ratingUIObject, Key.Home);
                Verify.AreEqual("!", textBlock.DocumentText);

                KeyboardHelper.PressKey(ratingUIObject, Key.End);
                Verify.AreEqual("5", textBlock.DocumentText);

                Log.Comment("Verify up down keys in LTR");
                KeyboardHelper.PressKey(ratingUIObject, Key.Down);
                Verify.AreEqual("4", textBlock.DocumentText);

                KeyboardHelper.PressKey(ratingUIObject, Key.Up);
                Verify.AreEqual("5", textBlock.DocumentText);
            }
        }
Exemplo n.º 5
0
        public void ScrollThenPanScrollViewer()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                Log.Warning("This test relies on touch input, the injection of which is only supported in RS5 and up. Test is disabled.");
                return;
            }

            Log.Comment("Selecting ScrollViewer tests");

            using (IDisposable setup = new TestSetupHelper("ScrollViewer Tests"),
                   setup2 = new TestSetupHelper("navigateToSimpleContents"))
            {
                const double minVerticalScrollPercentAfterScroll = 15.0;
                const double minHorizontalScrollPercentAfterPan  = 35.0;
                const double minVerticalScrollPercentAfterPan    = 50.0;

                double verticalScrollPercentAfterScroll = 0.0;

                Log.Comment("Retrieving cmbShowScrollViewer");
                ComboBox cmbShowScrollViewer = new ComboBox(FindElement.ByName("cmbShowScrollViewer"));
                Verify.IsNotNull(cmbShowScrollViewer, "Verifying that cmbShowScrollViewer was found");

                Log.Comment("Changing ScrollViewer selection to scrollViewer51");
                cmbShowScrollViewer.SelectItemByName("scrollViewer_51");
                Log.Comment("Selection is now {0}", cmbShowScrollViewer.Selection[0].Name);

                if (PlatformConfiguration.IsOsVersion(OSVersion.Redstone1))
                {
                    Log.Comment("On RS1 the Scroller's content is centered in an animated way when it's smaller than the viewport. Waiting for those animations to complete.");
                    WaitForScrollViewerManipulationEnd("scrollViewer21");
                }

                Log.Comment("Retrieving img51");
                UIObject img51UIObject = FindElement.ByName("img51");
                Verify.IsNotNull(img51UIObject, "Verifying that img51 was found");

                Log.Comment("Retrieving scroller51");
                Scroller scroller51 = new Scroller(img51UIObject.Parent);
                Verify.IsNotNull(scroller51, "Verifying that scroller51 was found");

                WaitForScrollViewerFinalSize(scroller51, 300.0 /*expectedWidth*/, 400.0 /*expectedHeight*/);

                // Tapping button before attempting pan operation to guarantee effective touch input
                TapResetViewsButton();

                Log.Comment("Left mouse buttom down over ScrollBar2 thumb");
                InputHelper.LeftMouseButtonDown(scroller51, 140 /*offsetX*/, -100 /*offsetY*/);

                Log.Comment("Mouse drag and left mouse buttom up over ScrollBar2 thumb");
                InputHelper.LeftMouseButtonUp(scroller51, 140 /*offsetX*/, -50 /*offsetY*/);

                Log.Comment("scroller51.HorizontalScrollPercent={0}", scroller51.HorizontalScrollPercent);
                Log.Comment("scroller51.VerticalScrollPercent={0}", scroller51.VerticalScrollPercent);

                verticalScrollPercentAfterScroll = scroller51.VerticalScrollPercent;

                if (scroller51.HorizontalScrollPercent != 0.0 || scroller51.VerticalScrollPercent <= minVerticalScrollPercentAfterScroll)
                {
                    LogAndClearTraces();
                }

                Verify.AreEqual(scroller51.HorizontalScrollPercent, 0.0, "Verifying scroller51 HorizontalScrollPercent is still 0%");
                Verify.IsTrue(verticalScrollPercentAfterScroll > minVerticalScrollPercentAfterScroll, "Verifying scroller51 VerticalScrollPercent is greater than " + minVerticalScrollPercentAfterScroll + "%");

                Log.Comment("Panning ScrollViewer in diagonal");
                PrepareForScrollViewerManipulationStart();

                // Using a large enough span and duration for this diagonal pan so that it is not erroneously recognized as a horizontal pan.
                InputHelper.Pan(
                    scroller51,
                    new Point(scroller51.BoundingRectangle.Left + 30, scroller51.BoundingRectangle.Top + 30),
                    new Point(scroller51.BoundingRectangle.Left - 30, scroller51.BoundingRectangle.Top - 30),
                    InputHelper.DefaultPanHoldDuration,
                    InputHelper.DefaultPanAcceleration / 2.4f);

                Log.Comment("Waiting for scrollViewer51 pan completion");
                WaitForScrollViewerManipulationEnd("scrollViewer51");

                Log.Comment("scroller51.HorizontalScrollPercent={0}", scroller51.HorizontalScrollPercent);
                Log.Comment("scroller51.VerticalScrollPercent={0}", scroller51.VerticalScrollPercent);

                if (scroller51.HorizontalScrollPercent <= minHorizontalScrollPercentAfterPan ||
                    scroller51.VerticalScrollPercent <= minVerticalScrollPercentAfterPan ||
                    scroller51.VerticalScrollPercent <= verticalScrollPercentAfterScroll)
                {
                    LogAndClearTraces();
                }

                Verify.IsTrue(scroller51.HorizontalScrollPercent > minHorizontalScrollPercentAfterPan, "Verifying scroller51 HorizontalScrollPercent is greater than " + minHorizontalScrollPercentAfterPan + "%");
                Verify.IsTrue(scroller51.VerticalScrollPercent > minVerticalScrollPercentAfterPan, "Verifying scroller51 VerticalScrollPercent is greater than " + minVerticalScrollPercentAfterPan + "%");
                Verify.IsTrue(scroller51.VerticalScrollPercent > verticalScrollPercentAfterScroll, "Verifying scroller51 VerticalScrollPercent is greater than " + verticalScrollPercentAfterScroll + "%");

                // scroller51's Content size is 800x800px.
                double horizontalOffset;
                double verticalOffset;
                double minHorizontalOffset = 800.0 * (1.0 - scroller51.HorizontalViewSize / 100.0) * minHorizontalScrollPercentAfterPan / 100.0;
                double minVerticalOffset   = 800.0 * (1.0 - scroller51.VerticalViewSize / 100.0) * minVerticalScrollPercentAfterPan / 100.0;
                float  zoomFactor;

                GetScrollerView(out horizontalOffset, out verticalOffset, out zoomFactor);
                Log.Comment("horizontalOffset={0}", horizontalOffset);
                Log.Comment("verticalOffset={0}", verticalOffset);
                Log.Comment("zoomFactor={0}", zoomFactor);
                Verify.IsTrue(horizontalOffset > minHorizontalOffset, "Verifying horizontalOffset is greater than " + minHorizontalOffset);
                Verify.IsTrue(verticalOffset > minVerticalOffset, "Verifying verticalOffset is greater than " + minVerticalOffset);
                Verify.AreEqual(zoomFactor, 1.0f, "Verifying zoomFactor is 1.0f");
            }
        }
        private string GetLastClickedItem()
        {
            var lastItemTextBlock = FindElement.ByName <TextBlock>("LastClickedItem");

            return(lastItemTextBlock.DocumentText);
        }
        public void GamepadTest()
        {
            using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page.
            {
                if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2))
                {
                    Log.Warning("Test is disabled on RS2 or older because Rating's engagement model relies on OnPreviewKey* virtuals");
                    return;
                }

                UIObject ratingUIObject = FindElement.ByName("TestRatingControl");
                Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl");
                TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl"));

                Log.Comment("Verify gamepad engagement");
                ratingUIObject.SetFocus();
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("1", textBlock.DocumentText);

                Log.Comment("Verify gamepad one change and cancel");
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.B);
                Wait.ForIdle();
                Verify.AreEqual("1", textBlock.DocumentText);

                Log.Comment("Verify gamepad one change and accept");
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("2", textBlock.DocumentText);

                Log.Comment("Verify gamepad multiple changes");
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("3", textBlock.DocumentText);

                Log.Comment("Verify gamepad left stick and dpad work");
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.LeftThumbstickRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.LeftThumbstickRight);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("4", textBlock.DocumentText);

                Log.Comment("Verify gamepad dpad up down do nothing");
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadUp);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("4", textBlock.DocumentText);

                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadDown);
                GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual("4", textBlock.DocumentText);
            }
        }
Exemplo n.º 8
0
        public void MenuItemInvokedTest()
        {
            var testScenarios = RegressionTestScenario.BuildTopNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    Log.Comment("Click games item");
                    UIObject menuItem = FindElement.ByName("Games");
                    InputHelper.LeftClick(menuItem);
                    Wait.ForIdle();
                    TextBlock header = new TextBlock(FindElement.ByName("Games as header"));
                    Verify.AreEqual("Games as header", header.DocumentText);

                    Log.Comment("Click music item");
                    menuItem = FindElement.ByName("Music");
                    InputHelper.LeftClick(menuItem);
                    Wait.ForIdle();
                    header = new TextBlock(FindElement.ByName("Music as header"));
                    Verify.AreEqual("Music as header", header.DocumentText);

                    Log.Comment("Click settings item");
                    menuItem = testScenario.IsLeftNavTest ? FindElement.ByName("Settings") : FindElement.ByName("SettingsTopNavPaneItem");
                    InputHelper.LeftClick(menuItem);
                    Wait.ForIdle();
                    header = new TextBlock(FindElement.ByName("Settings as header"));
                    Verify.AreEqual("Settings as header", header.DocumentText);

                    Log.Comment("Move mouse to upper left to ensure that tooltip on settings closes.");
                    TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                    Wait.ForIdle();
                }
            }
        }
Exemplo n.º 9
0
        public void SettingsItemClickTest()
        {
            var testScenarios = RegressionTestScenario.BuildAllRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    UIObject settingsItem = testScenario.IsLeftNavTest ? FindElement.ByName("Settings") : FindElement.ByName("SettingsTopNavPaneItem");

                    settingsItem.SetFocus();
                    Wait.ForIdle();

                    Log.Comment("Click settings");
                    settingsItem.Click();
                    Wait.ForIdle();

                    Log.Comment("Verify settings is selected");
                    TextBlock header = new TextBlock(FindElement.ByName("Settings as header"));
                    Verify.AreEqual("Settings as header", header.DocumentText);
                }
            }
        }
Exemplo n.º 10
0
        public void VerifyCorrectVisualStateWhenChangingPaneDisplayMode()
        {
            // We expect this mapping:
            //  Top, and LeftMinimal -> VisualState Minimal
            //  LeftCompact -> VisualState Compact
            //  Left -> VisualState Expanded

            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                var panelDisplayModeComboBox   = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));
                var getActiveVisualStateButton = new Button(FindElement.ByName("GetActiveVisualState"));
                var invokeResult       = new Edit(FindElement.ById("TestResult"));
                var isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox"));

                Log.Comment("Set PaneDisplayMode to Top");
                panelDisplayModeComboBox.SelectItemByName("Top");
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Minimal"));

                Log.Comment("Set PaneDisplayMode to Left");
                panelDisplayModeComboBox.SelectItemByName("Left");
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Expanded"));

                Log.Comment("Set PaneDisplayMode to Top");
                panelDisplayModeComboBox.SelectItemByName("Top");
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Minimal"));

                Log.Comment("Set PaneDisplayMode to LeftCompact");
                panelDisplayModeComboBox.SelectItemByName("LeftCompact");
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Compact"));

                Log.Comment("Set PaneDisplayMode to LeftMinimal");
                panelDisplayModeComboBox.SelectItemByName("LeftMinimal");

                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Minimal"));
                Log.Comment("Verify Pane is closed automatically when PaneDisplayMode is Minimal");
                Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False when PaneDisplayMode is Minimal");

                Log.Comment("Set DisplayMode to Left");
                panelDisplayModeComboBox.SelectItemByName("Left");
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    getActiveVisualStateButton.Click();
                    waiter.Wait();
                }
                Verify.IsTrue(invokeResult.Value.Contains("Expanded"));
                Log.Comment("Verify Pane is opened automatically when PaneDisplayMode is changed from Minimal to Left");
                Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True when PaneDisplayMode is changed from Minimal to Left");
            }
        }
Exemplo n.º 11
0
        public void VerifyLightDismissDoesntSendDuplicateEvents()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3))
                    {
                        Log.Warning("Test is disabled on RS2 and older due to lack of SplitView events");
                        return;
                    }

                    CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox"));
                    Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True");

                    SetNavViewWidth(ControlWidth.Medium);
                    WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

                    PaneOpenCloseTestCaseRetry(3, () =>
                    {
                        // recover from the exception if needed
                        if (isPaneOpenCheckBox.ToggleState != ToggleState.Off)
                        {
                            using (var waiter = isPaneOpenCheckBox.GetToggledWaiter())
                            {
                                isPaneOpenCheckBox.Toggle();
                                waiter.Wait();
                            }
                            WaitAndAssertPaneStatus(PaneOpenStatus.Closed);
                        }

                        Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False");

                        Log.Comment("Reset the event count");
                        new Button(FindElement.ById("ClosingEventCountResetButton")).Invoke();
                        Wait.ForIdle();

                        Log.Comment("Open the pane");
                        using (var waiter = isPaneOpenCheckBox.GetToggledWaiter())
                        {
                            isPaneOpenCheckBox.Toggle();
                            waiter.Wait();
                        }
                        WaitAndAssertPaneStatus(PaneOpenStatus.Opened);

                        Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True");

                        var closingCounts  = new Edit(FindElement.ByName("ClosingEventCountTextBlock"));
                        var expectedString = "1-1";

                        //  trigger a light dismiss
                        KeyboardHelper.PressKey(Key.Left, ModifierKey.Alt);
                        Wait.ForIdle();

                        WaitAndAssertPaneStatus(PaneOpenStatus.Closed);
                        Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False");
                        Verify.AreEqual(expectedString, closingCounts.GetText());
                    });
                }
            }
        }
Exemplo n.º 12
0
        public void VerifyCorrectVisualStateWhenClosingPaneInLeftDisplayMode()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
            {
                // Test for explicit pane close

                // make sure the NavigationView is in left mode with pane expanded
                Log.Comment("Change display mode to left expanded");
                var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));
                panelDisplayModeComboBox.SelectItemByName("Left");
                Wait.ForIdle();

                TextBlock displayModeTextBox = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
                Verify.AreEqual(expanded, displayModeTextBox.DocumentText);

                Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));

                // manually close pane
                Log.Comment("Close NavView pane explicitly");
                togglePaneButton.Invoke();
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

                Log.Comment("Get NavView Active VisualStates");
                var getNavViewActiveVisualStatesButton = new Button(FindElement.ByName("GetNavViewActiveVisualStates"));
                getNavViewActiveVisualStatesButton.Invoke();
                Wait.ForIdle();

                // check visual state
                var visualStateName = "ListSizeCompact";
                var result          = new TextBlock(FindElement.ByName("NavViewActiveVisualStatesResult"));

                Verify.IsTrue(result.GetText().Contains(visualStateName), "active VisualStates doesn't include " + visualStateName);

                // Test for light dismiss pane close

                Log.Comment("Change display mode to left compact");
                panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));
                panelDisplayModeComboBox.SelectItemByName("LeftCompact");
                Wait.ForIdle();

                displayModeTextBox = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
                Verify.AreEqual(compact, displayModeTextBox.DocumentText);

                // expand pane
                Log.Comment("Expand NavView pane");
                togglePaneButton.Invoke();
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Opened);

                // light dismiss pane
                Log.Comment("Light dismiss NavView pane");
                getNavViewActiveVisualStatesButton.Click(); // NOTE: Must be Click because this is verifying that the mouse light dismiss behavior closes the nav view
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

                Log.Comment("Get NavView Active VisualStates");
                getNavViewActiveVisualStatesButton.Invoke();
                Wait.ForIdle();

                // check visual state
                result = new TextBlock(FindElement.ByName("NavViewActiveVisualStatesResult"));
                Verify.IsTrue(result.GetText().Contains(visualStateName), "active VisualStates doesn't include " + visualStateName);
            }
        }
Exemplo n.º 13
0
        public void PaneDisplayModeLeftLeftCompactLeftMinimalTest()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
            {
                var displayModeTextBox       = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
                var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));

                // Tests with PaneDisplayMode=Left/LeftCompact/LeftMinimal.
                // This disables all adaptive layout behavior.

                Log.Comment("Test PaneDisplayMode=Left");
                panelDisplayModeComboBox.SelectItemByName("Left");
                Wait.ForIdle();

                Log.Comment("DisplayMode should be 'Expanded' regardless of size");
                SetNavViewWidth(ControlWidth.Narrow);
                Wait.ForIdle();
                Verify.AreEqual(expanded, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Medium);
                Wait.ForIdle();
                Verify.AreEqual(expanded, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Wide);
                Wait.ForIdle();
                Verify.AreEqual(expanded, displayModeTextBox.DocumentText);


                Log.Comment("Test PaneDisplayMode=LeftCompact");
                panelDisplayModeComboBox.SelectItemByName("LeftCompact");
                Wait.ForIdle();

                Log.Comment("DisplayMode should be 'Compact' regardless of size");
                SetNavViewWidth(ControlWidth.Narrow);
                Wait.ForIdle();
                Verify.AreEqual(compact, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Medium);
                Wait.ForIdle();
                Verify.AreEqual(compact, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Wide);
                Wait.ForIdle();
                Verify.AreEqual(compact, displayModeTextBox.DocumentText);


                Log.Comment("Test PaneDisplayMode=LeftMinimal");
                panelDisplayModeComboBox.SelectItemByName("LeftMinimal");
                Wait.ForIdle();

                Log.Comment("DisplayMode should be 'Minimal' regardless of size");
                SetNavViewWidth(ControlWidth.Narrow);
                Wait.ForIdle();
                Verify.AreEqual(minimal, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Medium);
                Wait.ForIdle();
                Verify.AreEqual(minimal, displayModeTextBox.DocumentText);

                SetNavViewWidth(ControlWidth.Wide);
                Wait.ForIdle();
                Verify.AreEqual(minimal, displayModeTextBox.DocumentText);
            }
        }
Exemplo n.º 14
0
        public void PaneTabNavigationTest()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
                    {
                        Log.Warning("Skipping: Correct pane tab navigation only works in RS2 and above");
                        return;
                    }

                    SetNavViewWidth(ControlWidth.Wide);

                    Button   togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));
                    UIObject firstItem        = FindElement.ByName("Home");
                    UIObject settingsItem     = FindElement.ByName("Settings");
                    UIObject nextTabTarget    = FindElement.ByName("WidthComboBox");

                    CheckBox autoSuggestCheckBox = new CheckBox(FindElement.ByName("AutoSuggestCheckbox"));
                    autoSuggestCheckBox.Uncheck();
                    Wait.ForIdle();

                    Log.Comment("Verify that in Expanded mode, tab navigation can leave the pane");
                    firstItem.SetFocus();
                    Wait.ForIdle();
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                    Wait.ForIdle();

                    Wait.RetryUntilEvalFuncSuccessOrTimeout(
                        () => { return(togglePaneButton.HasKeyboardFocus); },
                        retryTimoutByMilliseconds: 3000
                        );

                    Log.Comment("Verify pressing shift-tab from the first menu item goes to the toggle button");
                    Verify.IsTrue(togglePaneButton.HasKeyboardFocus);

                    settingsItem.SetFocus();
                    Wait.ForIdle();
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Log.Comment("Verify pressing tab from settings goes to the first tab stop in the content area");
                    Verify.IsTrue(nextTabTarget.HasKeyboardFocus);

                    SetNavViewWidth(ControlWidth.Medium);

                    CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox"));
                    isPaneOpenCheckBox.Check();
                    Wait.ForIdle();

                    Log.Comment("Verify that in an overlay mode, tab navigation cannot leave the pane while the pane is open");
                    firstItem.SetFocus();
                    Wait.ForIdle();
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                    Wait.ForIdle();
                    Log.Comment("Verify pressing shift-tab from the first menu item goes to settings");
                    Verify.IsTrue(settingsItem.HasKeyboardFocus);

                    settingsItem.SetFocus();
                    Wait.ForIdle();
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Log.Comment("Verify pressing tab from settings goes to the first menu item");
                    Verify.IsTrue(firstItem.HasKeyboardFocus);
                }
            }
        }
        public void ArrowKeyHierarchicalNavigationTest()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "HierarchicalNavigationView Markup Test" }))
            {
                //TODO: Re-enable for RS2 once arrow key behavior is matched with above versions
                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
                {
                    Log.Warning("Test is disabled because the repeater arrow behavior is currently different for rs2.");
                    return;
                }

                // Set up tree and get references to all required elements
                UIObject item1 = FindElement.ByName("Menu Item 1");

                Log.Comment("Expand Menu Item 1");
                InputHelper.LeftClick(item1);
                Wait.ForIdle();

                UIObject item2 = FindElement.ByName("Menu Item 2");
                UIObject item3 = FindElement.ByName("Menu Item 3");

                Log.Comment("Expand Menu Item 2");
                InputHelper.LeftClick(item2);
                Wait.ForIdle();

                UIObject item4 = FindElement.ByName("Menu Item 4");
                UIObject item5 = FindElement.ByName("Menu Item 5");

                // Set up initial focus
                Log.Comment("Set focus on the pane toggle button");
                Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));
                togglePaneButton.SetFocus();
                Wait.ForIdle();

                // Start down arrow key navigation test

                Log.Comment("Verify that down arrow navigates to Menu Item 1");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.IsTrue(item1.HasKeyboardFocus);

                Log.Comment("Verify that down arrow navigates to Menu Item 2");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.IsTrue(item2.HasKeyboardFocus);

                Log.Comment("Verify that down arrow navigates to Menu Item 4");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.IsTrue(item4.HasKeyboardFocus);

                Log.Comment("Verify that down arrow navigates to Menu Item 5");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.IsTrue(item5.HasKeyboardFocus);

                Log.Comment("Verify that down arrow navigates to Menu Item 3");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.IsTrue(item3.HasKeyboardFocus);

                // Start up arrow key navigation test

                Log.Comment("Verify that up arrow navigates to Menu Item 5");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.IsTrue(item5.HasKeyboardFocus);

                Log.Comment("Verify that up arrow navigates to Menu Item 4");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.IsTrue(item4.HasKeyboardFocus);

                Log.Comment("Verify that up arrow navigates to Menu Item 2");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.IsTrue(item2.HasKeyboardFocus);

                Log.Comment("Verify that up arrow navigates to Menu Item 1");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.IsTrue(item1.HasKeyboardFocus);

                Log.Comment("Verify that up arrow navigates to the pane toggle button");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.IsTrue(togglePaneButton.HasKeyboardFocus);
            }
        }
        protected void VerifyBackAndCloseButtonsVisibility(bool inLeftMinimalPanelDisplayMode)
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
            {
                var displayModeTextBox       = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
                var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));
                var isPaneOpenCheckBox       = new CheckBox(FindElement.ById("IsPaneOpenCheckBox"));

                Verify.AreEqual(expanded, displayModeTextBox.DocumentText, "Original DisplayMode expected to be Expanded");

                if (inLeftMinimalPanelDisplayMode)
                {
                    Log.Comment("Set PaneDisplayMode to LeftMinimal");
                    panelDisplayModeComboBox.SelectItemByName("LeftMinimal");
                    Wait.ForIdle();

                    Log.Comment("Verify Pane is closed automatically when PaneDisplayMode becomes LeftMinimal");
                    Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False when PaneDisplayMode becomes LeftMinimal");
                }
                else
                {
                    Log.Comment("Set PaneDisplayMode to Auto");
                    panelDisplayModeComboBox.SelectItemByName("Auto");
                    Wait.ForIdle();

                    Log.Comment("Verify Pane remains open when PaneDisplayMode becomes Auto");
                    Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to remain True when PaneDisplayMode becomes Auto");

                    Log.Comment("Verify back button is visible when pane is open in Expanded DisplayMode");
                    VerifyElement.Found("NavigationViewBackButton", FindBy.Id);

                    Log.Comment("Verify close button is not visible when pane is open in Expanded DisplayMode");
                    VerifyElement.NotFound("NavigationViewCloseButton", FindBy.Id);

                    Log.Comment("Decrease the width of the control from Wide to Narrow and force pane closure");
                    SetNavViewWidth(ControlWidth.Narrow);
                    Wait.ForIdle();
                    Verify.AreEqual(ToggleState.Off, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be False after decreasing width");
                    Verify.AreEqual(minimal, displayModeTextBox.DocumentText);
                }

                Log.Comment("Verify toggle-pane button is visible when pane is closed");
                VerifyElement.Found("TogglePaneButton", FindBy.Id);

                Log.Comment("Verify back button is visible when pane is closed");
                VerifyElement.Found("NavigationViewBackButton", FindBy.Id);

                Log.Comment("Verify close button is not visible when pane is closed");
                VerifyElement.NotFound("NavigationViewCloseButton", FindBy.Id);

                Log.Comment("Open the pane");
                isPaneOpenCheckBox.Check();
                Wait.ForIdle();

                Verify.AreEqual(ToggleState.On, isPaneOpenCheckBox.ToggleState, "IsPaneOpen expected to be True");

                Log.Comment("Verify toggle-pane button is visible when pane is open");
                VerifyElement.Found("TogglePaneButton", FindBy.Id);

                Log.Comment("Verify back button is not visible when pane is open");
                VerifyElement.NotFound("NavigationViewBackButton", FindBy.Id);

                Log.Comment("Verify close button is visible when pane is open");
                VerifyElement.Found("NavigationViewCloseButton", FindBy.Id);

                Button closeButton = new Button(FindElement.ById("NavigationViewCloseButton"));
                Verify.IsNotNull(closeButton);
                Verify.IsTrue(closeButton.IsEnabled, "Close button is expected to be enabled");

                CheckBox backButtonVisibilityCheckbox = new CheckBox(FindElement.ByName("BackButtonVisibilityCheckbox"));

                backButtonVisibilityCheckbox.Uncheck();
                Wait.ForIdle();

                Log.Comment("Verify back button is not visible when pane is open");
                VerifyElement.NotFound("NavigationViewBackButton", FindBy.Id);

                Log.Comment("Verify close button is no longer visible when pane is open");
                VerifyElement.NotFound("NavigationViewCloseButton", FindBy.Id);
            }
        }
        private void CanStyleTextInARichEditBox(string styleName, string styleStart, string styleEnd)
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because TextCommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new TextCommandBarFlyoutTestSetupHelper())
            {
                Log.Comment("Getting initial RichEditBox RTF content.");
                FindElement.ById <Button>(string.Format("GetRichEditBoxRtfContentButton")).InvokeAndWait();
                string textControlContents = FindElement.ById("StatusReportingTextBox").GetText();
                Log.Comment("Content is '{0}'", textControlContents.Replace(Environment.NewLine, " "));

                Log.Comment("Ensuring RichEditBox initially has no {0} content.", styleName.ToLower());
                Verify.IsFalse(textControlContents.Contains(styleStart));
                Verify.IsFalse(textControlContents.Contains(styleEnd));

                var richedit = FindElement.ById <Edit>("RichEditBox");

                FocusAndSelectText(richedit, "ergo");
                OpenFlyoutOn("RichEditBox", asTransient: true);

                var toggleFormatButton = FindElement.ByName <ToggleButton>(styleName);
                Verify.AreEqual(ToggleState.Off, toggleFormatButton.ToggleState);

                Log.Comment("Making text {0}.", styleName.ToLower());
                toggleFormatButton.ToggleAndWait();
                VerifyRichEditBoxHasContent(string.Format("Lorem ipsum {0}ergo{1} sum", styleStart, styleEnd));

                DismissFlyout();

                Log.Comment("Select mixed format text");
                // Note, in this case the selection starts in unstyled text ("sum") and includes styled text ("ergo"). The next case covers
                // starting in styled text and including unstyled text
                FocusAndSelectText(richedit, "sum ergo");

                Log.Comment("Showing flyout should not change bold status");
                OpenFlyoutOn("RichEditBox", asTransient: true);
                Verify.AreEqual(ToggleState.Off, toggleFormatButton.ToggleState);
                VerifyRichEditBoxHasContent(string.Format("Lorem ipsum {0}ergo{1} sum", styleStart, styleEnd));

                Log.Comment("Apply formatting to new selection");
                toggleFormatButton.ToggleAndWait();
                VerifyRichEditBoxHasContent(string.Format("Lorem ip{0}sum ergo{1} sum", styleStart, styleEnd));

                DismissFlyout();

                Log.Comment("Select mixed format text");
                FocusAndSelectText(richedit, "ergo su");
                OpenFlyoutOn("RichEditBox", asTransient: true);
                Verify.AreEqual(ToggleState.Off, toggleFormatButton.ToggleState);
                VerifyRichEditBoxHasContent(string.Format("Lorem ip{0}sum ergo{1} sum", styleStart, styleEnd));

                toggleFormatButton.ToggleAndWait();
                VerifyRichEditBoxHasContent(string.Format("Lorem ip{0}sum ergo su{1}m", styleStart, styleEnd));

                DismissFlyout();
                FocusAndSelectText(richedit, "ergo");
                OpenFlyoutOn("RichEditBox", asTransient: true);
                Verify.AreEqual(ToggleState.On, toggleFormatButton.ToggleState);
                VerifyRichEditBoxHasContent(string.Format("Lorem ip{0}sum ergo su{1}m", styleStart, styleEnd));

                toggleFormatButton.ToggleAndWait();
                VerifyRichEditBoxHasContent(string.Format("Lorem ip{0}sum {1}ergo{0} su{1}m", styleStart, styleEnd));
            }
        }
        public void UpdateMinMaxTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Updating Minimum and Maximum value of ProgressBar");

                UIObject testProgressBar = FindElement.ByName("TestProgressBar");

                TextBlock valueText        = FindElement.ByName <TextBlock>("ValueText");
                TextBlock minimumInputText = FindElement.ByName <TextBlock>("MinimumInputText");
                TextBlock maximumInputText = FindElement.ByName <TextBlock>("MaximumInputText");

                double oldMinimumInputText = Convert.ToDouble(minimumInputText.DocumentText);
                double oldMaximumInputText = Convert.ToDouble(maximumInputText.DocumentText);

                Edit minimumInput = FindElement.ByName <Edit>("MinimumInput");
                Edit maximumInput = FindElement.ByName <Edit>("MaximumInput");

                minimumInput.SetValue("10");
                maximumInput.SetValue("15");

                Button updateMinMaxButton = FindElement.ByName <Button>("UpdateMinMaxButton");
                updateMinMaxButton.InvokeAndWait();

                double newMinimumInputText = Convert.ToDouble(minimumInputText.DocumentText);
                double newMaximumInputText = Convert.ToDouble(maximumInputText.DocumentText);

                Verify.AreNotSame(oldMinimumInputText, newMinimumInputText, "Minimum updated");
                Verify.AreNotSame(oldMaximumInputText, newMaximumInputText, "Maximum updated");

                // Below edge cases are handled by Rangebase

                Log.Comment("Updating Minimum and Maximum when Maximum < Minimum");

                maximumInput.SetValue("5");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(minimumInputText.DocumentText, maximumInputText.DocumentText, "Maximum updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum when Minimum > Value");

                minimumInput.SetValue("15");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(valueText.DocumentText, minimumInputText.DocumentText, "Value updates to equal Minimum");
                Verify.AreEqual(maximumInputText.DocumentText, minimumInputText.DocumentText, "Maximum also updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum to be a decimal number");

                minimumInput.SetValue("0.1");
                maximumInput.SetValue("1.1");

                updateMinMaxButton.InvokeAndWait();

                double oldValue = Convert.ToDouble(valueText.DocumentText);

                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                changeValueButton.InvokeAndWait();

                double newValue = Convert.ToDouble(valueText.DocumentText);
                double diff     = Math.Abs(oldValue - newValue);

                Verify.IsGreaterThan(diff, Convert.ToDouble(0), "Value of ProgressBar increments properly within range with decimal Minimum and Maximum");
            }
        }
        private int GetLastClickedItemIndex()
        {
            var lastItemTextBlock = FindElement.ByName <TextBlock>("LastClickedItemIndex");

            return(Int32.Parse(lastItemTextBlock.DocumentText));
        }
        public void UpdateIndicatorWidthTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Set ProgressBar settings to default for testing");

                UIObject testProgressBar = FindElement.ByName("TestProgressBar");

                Edit minimumInput = FindElement.ByName <Edit>("MinimumInput");
                Edit maximumInput = FindElement.ByName <Edit>("MaximumInput");
                Edit widthInput   = FindElement.ByName <Edit>("WidthInput");

                TextBlock minimumInputText   = FindElement.ByName <TextBlock>("MinimumInputText");
                TextBlock maximumInputText   = FindElement.ByName <TextBlock>("MaximumInputText");
                TextBlock widthInputText     = FindElement.ByName <TextBlock>("WidthInputText");
                TextBlock valueText          = FindElement.ByName <TextBlock>("ValueText");
                TextBlock indicatorWidthText = FindElement.ByName <TextBlock>("IndicatorWidthText");

                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                Button updateWidthButton = FindElement.ByName <Button>("UpdateWidthButton");

                minimumInput.SetValue("0");
                maximumInput.SetValue("100");
                widthInput.SetValue("100");

                Verify.AreEqual(Convert.ToDouble(minimumInputText.DocumentText), 0);
                Verify.AreEqual(Convert.ToDouble(maximumInputText.DocumentText), 100);
                Verify.AreEqual(Convert.ToDouble(widthInputText.DocumentText), 100);

                Log.Comment("Changing value of ProgressBar updates Indicator Width");

                changeValueButton.Invoke();

                Verify.AreEqual(Convert.ToDouble(valueText.DocumentText), Convert.ToDouble(indicatorWidthText.DocumentText));

                Log.Comment("Updating width of ProgressBar also updates Indicator Width");
                widthInput.SetValue("150");

                updateWidthButton.InvokeAndWait();

                Verify.AreEqual(Math.Ceiling(Convert.ToDouble(valueText.DocumentText) * 1.5), Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator width is adjusted to ProgressBar width");

                Log.Comment("Changing value of ProgressBar of different width updates Indicator width");

                changeValueButton.InvokeAndWait();

                Verify.AreEqual(Math.Ceiling(Convert.ToDouble(valueText.DocumentText) * 1.5), Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator width is adjusted to ProgressBar width");

                Log.Comment("Updating Maximum and Minimum also updates Indicator Width");

                minimumInput.SetValue("10");
                maximumInput.SetValue("15");

                changeValueButton.InvokeAndWait();

                double range = Convert.ToDouble(maximumInputText.DocumentText) - Convert.ToDouble(minimumInputText.DocumentText);
                double adjustedValueFromRange = Convert.ToDouble(valueText.DocumentText) - Convert.ToDouble(minimumInputText.DocumentText);
                double calculatedValue        = Math.Ceiling((adjustedValueFromRange / range) * Convert.ToDouble(widthInputText.DocumentText));

                Verify.AreEqual(calculatedValue, Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator Width is adjusted based on range and ProgressBar width");
            }
        }
        public void UIAValuePatternTest()
        {
            using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page.
            {
                Log.Comment("Retrieve rating control as generic UIElement");
                UIObject ratingUIObject = FindElement.ByName("TestRatingControl");

                TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl"));
                Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl");

                Log.Comment("Verify the UIA Value before user clicks the control.");
                ratingUIObject.SetFocus(); // Setting focus just so we can use AE.FE below
                Wait.ForIdle();
                AutomationElement ratingPeer = AutomationElement.FocusedElement;

                VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5");

                if (PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) // engagement doesn't work pre RS3
                {
                    Log.Comment("Verify moving right 2 times with the gamepad sets the control to 3");
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                    Wait.ForIdle();
                    Verify.AreEqual("3", textBlock.DocumentText);

                    Log.Comment("Verify rating of 3 sets UIA text to 3");

                    VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 3 of 5");

                    // revert:
                    Log.Comment("Resetting control to community rating");
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft);
                    GamepadHelper.PressButton(ratingUIObject, GamepadButton.A);

                    VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5");
                }

                Log.Comment("Verify more complex navigation");
                KeyboardHelper.PressKey(ratingUIObject, Key.Right);
                KeyboardHelper.PressKey(ratingUIObject, Key.Right);
                KeyboardHelper.PressKey(ratingUIObject, Key.Right);
                KeyboardHelper.PressKey(ratingUIObject, Key.Left);
                VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 2 of 5");

                // Verify read an unset rating
                ratingUIObject = FindElement.ByName("RatingBindingSample");
                Log.Comment("Verify the UIA Value of an unset Rating without a placeholder value");
                ratingUIObject.SetFocus();
                InputHelper.ScrollToElement(ratingUIObject);
                ratingPeer = AutomationElement.FocusedElement;

                VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating Unset");

                // Verify rounding:
                Log.Comment("Verifying Value_Value rounding");
                UIObject round1 = FindElement.ById("ValuePatternRoundTest1");
                round1.SetFocus();
                AutomationElement roundAE1 = AutomationElement.FocusedElement;
                UIObject          round2   = FindElement.ById("ValuePatternRoundTest2");
                round2.SetFocus();
                AutomationElement roundAE2 = AutomationElement.FocusedElement;
                UIObject          round3   = FindElement.ById("ValuePatternRoundTest3");
                round3.SetFocus();
                AutomationElement roundAE3 = AutomationElement.FocusedElement;

                VerifyValue_ValueEqualsOnAutomationElement(roundAE1, "Rating, 1.5 of 5");
                VerifyValue_ValueEqualsOnAutomationElement(roundAE2, "Rating, 1.55 of 5");
                VerifyValue_ValueEqualsOnAutomationElement(roundAE3, "Rating, 1.5 of 5");
            }
        }
        public void VerifyAppCanLaunch()
        {
            var uiobj = FindElement.ByName("MuxColorPicker");

            Verify.IsNotNull(uiobj, "Expected to find ColorPicker");
        }
Exemplo n.º 23
0
        public void RevealHoverLightPosition_Values()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Comment("RevealHoverLightPosition_Values needs to be running on RS2 or greater");
                return;
            }

            using (IDisposable page1 = new TestSetupHelper("Reveal Tests"),
                   page2 = new TestSetupHelper("navigateToRevealStates"))
            {
                var result = new Edit(FindElement.ById("TestResult"));
                var target = FindElement.ById("LargeButton2");

                using (var waiter = new ValueChangedEventWaiter(result))
                {
                    // Note for this test case we specifically attach the hover light via hover, not press.
                    // This provides regression coverage for Bug 14079741: Reveal hover light doesn't follow pointer until first interaction/click
                    Log.Comment("Move pointer over LargeButton2 (which will attach RevealHoverLight).");
                    target.MovePointer(50, 50);
                    Wait.ForIdle();

                    ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidatePosition_Offset1_Values");
                    FindElement.ByName <Button>("StartLoggingValues").InvokeAndWait();

                    TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                    Wait.ForIdle();

                    Log.Comment("Move pointer to Offset1 [10, 90] on LargeButton2. Wait for light to position to reach expected values.");
                    target.MovePointer(10, 90);
                    Wait.ForIdle();

                    waiter.Wait();
                }
                LogResult(result, "Offset1_Values");

                using (var waiter = new ValueChangedEventWaiter(result))
                {
                    ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidatePosition_Offset2_Values");
                    FindElement.ByName <Button>("StartLoggingValues").InvokeAndWait();

                    // Move mouse pointer away so it does not create BorderLight on the item
                    TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                    Wait.ForIdle();

                    Log.Comment("Move pointer to Offset2 [50, 50]. Wait for light to position to reach expected values.");
                    target.MovePointer(50, 50);
                    Wait.ForIdle();

                    waiter.Wait();
                }
                LogResult(result, "Offset2_Values");

                target = FindElement.ById("NarrowButton2");
                using (var waiter = new ValueChangedEventWaiter(result))
                {
                    Log.Comment("Tap and hold NarrowButton2 (which will attach RevealHoverLight).");
                    InputHelper.TapAndHold(target, 3000);
                    Wait.ForIdle();

                    ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidatePosition_Offset3_Values");
                    FindElement.ByName <Button>("StartLoggingValues").InvokeAndWait();

                    TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                    Wait.ForIdle();

                    Log.Comment("Tap on NarrowButton2 at [10, 40]. Wait for light position to reach expected values.");
                    InputHelper.Tap(target, 10, 40);
                    Wait.ForIdle();

                    waiter.Wait();
                }
                LogResult(result, "Offset3_Values");
            }
        }
Exemplo n.º 24
0
        public void TopNavigationSelectionTest()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
                {
                    Log.Warning("Skipping: only works in RS2 and above");
                    return;
                }


                Button   resetResultButton = new Button(FindElement.ById("ResetResult"));
                UIObject home = FindElement.ByName("Home");
                UIObject apps = FindElement.ById("AppsItem");
                UIObject suppressSelection = FindElement.ByName("SuppressSelection");

                var invokeResult = new Edit(FindElement.ById("ItemInvokedResult"));
                var selectResult = new Edit(FindElement.ById("SelectionChangedResult"));
                var invokeRecommendedTransition          = new Edit(FindElement.ById("InvokeRecommendedTransition"));
                var selectionChangeRecommendedTransition = new Edit(FindElement.ById("SelectionChangeRecommendedTransition"));
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    apps.Click();
                    waiter.Wait();
                }

                // First time selection raise ItemInvoke and SelectionChange events
                Verify.AreEqual(invokeResult.Value, "Apps");
                Verify.AreEqual(selectResult.Value, "Apps");
                Verify.AreEqual(invokeRecommendedTransition.Value, "Default");
                Verify.AreEqual(selectionChangeRecommendedTransition.Value, "Default");

                resetResultButton.Click();
                Wait.ForIdle();

                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    apps.Click();
                    waiter.Wait();
                }

                // Click it again, only raise ItemInvoke event
                Verify.AreEqual(invokeResult.Value, "Apps");
                Verify.AreEqual(selectResult.Value, "");
                Verify.AreEqual(invokeRecommendedTransition.Value, "Default");
                Verify.AreEqual(selectionChangeRecommendedTransition.Value, "");

                resetResultButton.Click();
                Wait.ForIdle();

                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    suppressSelection.Click();
                    waiter.Wait();
                }

                // Only click for suppress items
                Verify.AreEqual(invokeResult.Value, "SuppressSelection");
                Verify.AreEqual(selectResult.Value, "");
                Verify.AreEqual(invokeRecommendedTransition.Value, "Default");
                Verify.AreEqual(selectionChangeRecommendedTransition.Value, "");

                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    home.Click();
                    waiter.Wait();
                }

                // Click home again, it raise two events. transition from right to left
                Verify.AreEqual(invokeResult.Value, "Home");
                Verify.AreEqual(selectResult.Value, "Home");

                // Only RS5 or above supports SlideNavigationTransitionInfo
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Verify.AreEqual(invokeRecommendedTransition.Value, "FromLeft");
                    Verify.AreEqual(selectionChangeRecommendedTransition.Value, "FromLeft");
                }

                resetResultButton.Click();
                Wait.ForIdle();

                // click apps again. transition from left to right
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    apps.Click();
                    waiter.Wait();
                }

                Verify.AreEqual(invokeResult.Value, "Apps");
                Verify.AreEqual(selectResult.Value, "Apps");

                // Only RS5 or above supports SlideNavigationTransitionInfo
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Verify.AreEqual(invokeRecommendedTransition.Value, "FromRight");
                    Verify.AreEqual(selectionChangeRecommendedTransition.Value, "FromRight");
                }
            }
        }
Exemplo n.º 25
0
        public void PanScrollViewer()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                Log.Warning("This test relies on touch input, the injection of which is only supported in RS5 and up. Test is disabled.");
                return;
            }

            const double minHorizontalScrollPercent = 35.0;
            const double minVerticalScrollPercent   = 35.0;

            Log.Comment("Selecting ScrollViewer tests");

            using (IDisposable setup = new TestSetupHelper("ScrollViewer Tests"),
                   setup2 = new TestSetupHelper("navigateToSimpleContents"))
            {
                Log.Comment("Retrieving cmbShowScrollViewer");
                ComboBox cmbShowScrollViewer = new ComboBox(FindElement.ByName("cmbShowScrollViewer"));
                Verify.IsNotNull(cmbShowScrollViewer, "Verifying that cmbShowScrollViewer was found");

                Log.Comment("Changing ScrollViewer selection to scrollViewer51");
                cmbShowScrollViewer.SelectItemByName("scrollViewer_51");
                Log.Comment("Selection is now {0}", cmbShowScrollViewer.Selection[0].Name);

                if (PlatformConfiguration.IsOsVersion(OSVersion.Redstone1))
                {
                    Log.Comment("On RS1 the Scroller's content is centered in an animated way when it's smaller than the viewport. Waiting for those animations to complete.");
                    WaitForScrollViewerManipulationEnd("scrollViewer21");
                }

                Log.Comment("Retrieving img51");
                UIObject img51UIObject = FindElement.ByName("img51");
                Verify.IsNotNull(img51UIObject, "Verifying that img51 was found");

                Log.Comment("Retrieving scroller51");
                Scroller scroller51 = new Scroller(img51UIObject.Parent);
                Verify.IsNotNull(scroller51, "Verifying that scroller51 was found");

                WaitForScrollViewerFinalSize(scroller51, 300.0 /*expectedWidth*/, 400.0 /*expectedHeight*/);

                // Tapping button before attempting pan operation to guarantee effective touch input
                TapResetViewsButton();

                Log.Comment("Panning ScrollViewer in diagonal");
                PrepareForScrollViewerManipulationStart();

                InputHelper.Pan(
                    scroller51,
                    new Point(scroller51.BoundingRectangle.Left + 25, scroller51.BoundingRectangle.Top + 25),
                    new Point(scroller51.BoundingRectangle.Left - 25, scroller51.BoundingRectangle.Top - 25));

                Log.Comment("Waiting for scrollViewer51 pan completion");
                WaitForScrollViewerManipulationEnd("scrollViewer51");

                Log.Comment("scroller51.HorizontalScrollPercent={0}", scroller51.HorizontalScrollPercent);
                Log.Comment("scroller51.VerticalScrollPercent={0}", scroller51.VerticalScrollPercent);

                if (scroller51.HorizontalScrollPercent <= minHorizontalScrollPercent || scroller51.VerticalScrollPercent <= minVerticalScrollPercent)
                {
                    LogAndClearTraces();
                }

                Verify.IsTrue(scroller51.HorizontalScrollPercent > minHorizontalScrollPercent, "Verifying scroller51 HorizontalScrollPercent is greater than " + minHorizontalScrollPercent + "%");
                Verify.IsTrue(scroller51.VerticalScrollPercent > minVerticalScrollPercent, "Verifying scroller51 VerticalScrollPercent is greater than " + minVerticalScrollPercent + "%");

                // scroller51's Content size is 800x800px.
                double horizontalOffset;
                double verticalOffset;
                double minHorizontalOffset = 800.0 * (1.0 - scroller51.HorizontalViewSize / 100.0) * minHorizontalScrollPercent / 100.0;
                double minVerticalOffset   = 800.0 * (1.0 - scroller51.VerticalViewSize / 100.0) * minVerticalScrollPercent / 100.0;
                float  zoomFactor;

                GetScrollerView(out horizontalOffset, out verticalOffset, out zoomFactor);
                Log.Comment("horizontalOffset={0}", horizontalOffset);
                Log.Comment("verticalOffset={0}", verticalOffset);
                Log.Comment("zoomFactor={0}", zoomFactor);
                Verify.IsTrue(horizontalOffset > minHorizontalOffset, "Verifying horizontalOffset is greater than " + minHorizontalOffset);
                Verify.IsTrue(verticalOffset > minVerticalOffset, "Verifying verticalOffset is greater than " + minVerticalOffset);
                Verify.AreEqual(zoomFactor, 1.0f, "Verifying zoomFactor is 1.0f");

                // Output-debug-string-level "None" is automatically restored when landing back on the ScrollViewer test page.
            }
        }
        public void TabNavigationTest()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    //TODO: Update RS3 and below tab behavior to match RS4+
                    if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                    {
                        Log.Warning("Test is disabled because the repeater tab behavior is current different rs3 and below.");
                        return;
                    }

                    SetNavViewWidth(ControlWidth.Wide);

                    Button   togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));
                    UIObject searchBox        = FindElement.ByNameAndClassName("PaneAutoSuggestBox", "TextBox");
                    UIObject firstItem        = FindElement.ByName("Home");
                    UIObject settingsItem     = FindElement.ByName("Settings");
                    togglePaneButton.SetFocus();
                    Wait.ForIdle();

                    Log.Comment("Verify that pressing tab while TogglePaneButton has focus moves to the search box");
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Verify.IsTrue(searchBox.HasKeyboardFocus);

                    Log.Comment("Verify that pressing tab while the search box has focus moves to the first menu item");
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Verify.IsTrue(firstItem.HasKeyboardFocus);

                    Log.Comment("Verify that pressing tab twice more will move focus to the settings item");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 2);
                    Wait.ForIdle();
                    Verify.IsTrue(settingsItem.HasKeyboardFocus);

                    // TODO: Re-enable test part and remove workaround once saving tab state is fixed

                    Log.Comment("Move Focus to first item");
                    firstItem.SetFocus();
                    Wait.ForIdle();

                    //Log.Comment("Verify that pressing SHIFT+tab twice will move focus to the first menu item");
                    //KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 2);
                    //Wait.ForIdle();
                    //Verify.IsTrue(firstItem.HasKeyboardFocus);

                    Log.Comment("Verify that pressing SHIFT+tab will move focus to the search box");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                    Wait.ForIdle();
                    Verify.IsTrue(searchBox.HasKeyboardFocus);

                    Log.Comment("Verify that pressing SHIFT+tab will move focus to the TogglePaneButton");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                    Wait.ForIdle();
                    Verify.IsTrue(togglePaneButton.HasKeyboardFocus);
                }
            }
        }
 static Button Button(string name) => FindElement.ByName <Button>(name);
        public void ArrowKeyNavigationTest()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    //TODO: Update RS3 and below tab behavior to match RS4+
                    if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                    {
                        Log.Warning("Test is disabled because the repeater tab behavior is current different rs3 and below.");
                        return;
                    }

                    SetNavViewWidth(ControlWidth.Wide);

                    Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));
                    togglePaneButton.SetFocus();
                    Wait.ForIdle();

                    // Grab references to all the menu items in the test UI
                    UIObject searchBox    = FindElement.ByNameAndClassName("PaneAutoSuggestBox", "TextBox");
                    UIObject item1        = FindElement.ByName("Home");
                    UIObject item2        = FindElement.ByName("Apps");
                    UIObject item3        = FindElement.ByName("Games");
                    UIObject item4        = FindElement.ByName("Music");
                    UIObject item5        = FindElement.ByName("Movies");
                    UIObject item6        = FindElement.ByName("TV");
                    UIObject settingsItem = FindElement.ByName("Settings");

                    Log.Comment("Verify that tab from the TogglePaneButton goes to the search box");
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Verify.IsTrue(searchBox.HasKeyboardFocus);

                    Log.Comment("Verify that tab from search box goes to the first item");
                    KeyboardHelper.PressKey(Key.Tab);
                    Wait.ForIdle();
                    Verify.IsTrue(item1.HasKeyboardFocus);

                    Log.Comment("Verify that down arrow can navigate through all items");
                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                    Verify.IsTrue(item2.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                    Verify.IsTrue(item3.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                    Verify.IsTrue(item4.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                    Verify.IsTrue(item5.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                    Verify.IsTrue(item6.HasKeyboardFocus);

                    Log.Comment("Verify that tab twice from the last menu item goes to the settings item");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 2);
                    Wait.ForIdle();
                    Verify.IsTrue(settingsItem.HasKeyboardFocus);

                    // TODO: Re-enable test part and remove workaround once saving tab state is fixed

                    Log.Comment("Move Focus to TV item");
                    item6.SetFocus();
                    Wait.ForIdle();

                    //Log.Comment("Verify that shift+tab twice from the settings item goes to the last menu item");
                    //KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 2);
                    //Wait.ForIdle();
                    //Verify.IsTrue(item6.HasKeyboardFocus);

                    Log.Comment("Verify that up arrow can navigate through all items");
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                    Verify.IsTrue(item5.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                    Verify.IsTrue(item4.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                    Verify.IsTrue(item3.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                    Verify.IsTrue(item2.HasKeyboardFocus);

                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                    Verify.IsTrue(item1.HasKeyboardFocus);

                    Log.Comment("Verify that shift+tab from the first menu item goes to the search box");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift);
                    Wait.ForIdle();
                    Verify.IsTrue(searchBox.HasKeyboardFocus);

                    Log.Comment("Verify that shift+tab from the search box goes to the TogglePaneButton");
                    KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift);
                    Wait.ForIdle();
                    Verify.IsTrue(togglePaneButton.HasKeyboardFocus);
                }
            }
        }
        public void CanClearEveryValueTest()
        {
            using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page.
            {
                if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
                {
                    // For some reason this test sometimes fails on RS1 when the "bounding box" of the
                    // RatingControl has negative values, but it's not worth the investigation to fix:
                    Log.Comment("Test is disabled on RS1 due to reliability issues");
                    return;
                }

                TextBlock tb = new TextBlock(FindElement.ById("FrameDetails"));
                Log.Comment("FrameDetails: " + tb.DocumentText);

                Log.Comment("Retrieve rating control as generic UIElement");
                UIObject ratingUIObject = FindElement.ByName("TestRatingControl");
                Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl");

                Log.Comment("Retrieve the text block as a TextBlock");
                TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl"));

                Wait.ForIdle();

                Log.Comment("Verify a tap on the first star sets Rating to 1");
                InputHelper.Tap(ratingUIObject, (0 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("1", textBlock.DocumentText);

                Log.Comment("Verify a tap on the first star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, (0 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);

                Log.Comment("Verify a tap on the second star sets Rating to 2");
                InputHelper.Tap(ratingUIObject, (1 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("2", textBlock.DocumentText);

                Log.Comment("Verify a tap on the second star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, (1 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);

                Log.Comment("Verify a tap on the third star sets Rating to 3");
                InputHelper.Tap(ratingUIObject, (2 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("3", textBlock.DocumentText);

                Log.Comment("Verify a tap on the third star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, (2 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);

                Log.Comment("Verify a tap on the fourth star sets Rating to 4");
                InputHelper.Tap(ratingUIObject, (3 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("4", textBlock.DocumentText);

                Log.Comment("Verify a tap on the fourth star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, (3 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);

                Log.Comment("Verify a tap on the fifth star sets Rating to 5");
                InputHelper.Tap(ratingUIObject, (4 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("5", textBlock.DocumentText);

                Log.Comment("Verify a tap on the second star sets Rating to 2.5 (placeholder value)");
                InputHelper.Tap(ratingUIObject, (4 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2);
                Verify.AreEqual("!2.5", textBlock.DocumentText);
            }
        }
Exemplo n.º 30
0
        public void TabSizeAndScrollButtonsTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject smallerTab = FindElement.ByName("SecondTab");
                UIObject largerTab  = FindElement.ByName("LongHeaderTab");

                FindElement.ByName <Button>("SetTabViewWidth").InvokeAndWait();

                Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible");

                Log.Comment("Equal size tabs should all be the same size.");
                int diff = Math.Abs(largerTab.BoundingRectangle.Width - smallerTab.BoundingRectangle.Width);
                Verify.IsLessThanOrEqual(diff, 1);

                Log.Comment("Changing tab width mode to SizeToContent.");
                ComboBox tabWidthComboBox = FindElement.ByName <ComboBox>("TabWidthComboBox");
                tabWidthComboBox.SelectItemByName("SizeToContent");
                Wait.ForIdle();

                Log.Comment("Tab with larger content should be wider.");
                Verify.IsGreaterThan(largerTab.BoundingRectangle.Width, smallerTab.BoundingRectangle.Width);

                // With largerTab now rendering wider, the scroll buttons should appear:
                Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear");

                // Scroll all the way to the left and verify decrease/increase button visual state
                FindElement.ByName <Button>("ScrollTabViewToTheLeft").InvokeAndWait();
                Wait.ForIdle();
                Verify.IsFalse(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be disabled");
                Verify.IsTrue(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be enabled");

                // Scroll to the middle position and verify decrease/increase button visual state
                FindElement.ByName <Button>("ScrollTabViewToTheMiddle").InvokeAndWait();
                Wait.ForIdle();
                Verify.IsTrue(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be enabled");
                Verify.IsTrue(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be enabled");

                // Scroll all the way to the right and verify decrease/increase button visual state
                FindElement.ByName <Button>("ScrollTabViewToTheRight").InvokeAndWait();
                Wait.ForIdle();
                Verify.IsTrue(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be enabled");
                Verify.IsFalse(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be disabled");

                // Close a tab to make room. The scroll buttons should disappear:
                Log.Comment("Closing a tab:");
                Button closeButton = FindCloseButton(FindElement.ByName("LongHeaderTab"));
                closeButton.MovePointer(0, 0);
                closeButton.InvokeAndWait();
                VerifyElement.NotFound("LongHeaderTab", FindBy.Name);

                Log.Comment("Scroll buttons should disappear");
                // Leaving tabstrip with this so the tabs update their width
                FindElement.ByName <Button>("IsClosableCheckBox").MovePointer(0, 0);
                Wait.ForIdle();
                Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should disappear");

                // Make sure the scroll buttons can show up in 'Equal' sizing mode.
                Log.Comment("Changing tab width mode to Equal");
                tabWidthComboBox.SelectItemByName("Equal");
                Wait.ForIdle();
                Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible");

                var addButton = FindElement.ByName <Button>("Add New Tab");
                Verify.IsNotNull(addButton, "addButton should be available");
                Log.Comment("Adding a tab");
                addButton.InvokeAndWait();
                Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible");
                Log.Comment("Adding another tab");
                addButton.InvokeAndWait();

                Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear");
            }
        }