Exemplo n.º 1
0
        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 currently different on RS3 and below.");
                        return;
                    }

                    SetNavViewWidth(ControlWidth.Wide);

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

                    VerifyTabNavigationWithoutMenuItemSelected();
                    VerifyTabNavigationWithMenuItemSelected();

                    void VerifyTabNavigationWithoutMenuItemSelected()
                    {
                        Log.Comment("Verify Tab navigation without a selected menu item");

                        // Clear any item selection
                        var clearSelectedItemButton = new Button(FindElement.ByName("ClearSelectedItemButton"));

                        clearSelectedItemButton.Click();
                        Wait.ForIdle();

                        Verify.AreEqual("null", GetSelectedItem());

                        UIObject firstMenuItem = FindElement.ByName("Home");
                        UIObject lastMenuItem  = FindElement.ByName("HasChildItem");

                        // Set focus on the pane's toggle button.
                        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(firstMenuItem.HasKeyboardFocus);

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

                        Log.Comment("Verify that pressing SHIFT+tab thrice will move focus to the last menu item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(lastMenuItem.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);
                    }

                    void VerifyTabNavigationWithMenuItemSelected()
                    {
                        Log.Comment("Verify Tab navigation with a selected menu item");

                        // Select a menu item (preferably not the first or last menu item)
                        UIObject thirdMenuItem = FindElement.ByName("Games");

                        var selectedItemComboBox = new ComboBox(FindElement.ById("SelectedItemCombobox"));

                        selectedItemComboBox.SelectItemByName("Games");
                        Wait.ForIdle();

                        Verify.IsTrue(Convert.ToBoolean(thirdMenuItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                        // Set focus on the pane's toggle button.
                        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 selected menu item");
                        KeyboardHelper.PressKey(Key.Tab);
                        Wait.ForIdle();
                        Verify.IsTrue(thirdMenuItem.HasKeyboardFocus);

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

                        Log.Comment("Verify that pressing SHIFT+tab thrice will move focus to the selected menu item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(thirdMenuItem.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);
                    }
                }

                string GetSelectedItem()
                {
                    return(FindElement.ByName("SelectionChangedItemType").GetText());
                }
            }
        }
        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");
            }
        }
        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 OpenFlyoutOn(string textControlName, bool asTransient)
 {
     Log.Comment("Opening text control flyout on the {0} in {1} mode.", textControlName, asTransient ? "transient" : "standard");
     FindElement.ById <Button>(string.Format("Show{1}TextControlFlyoutOn{0}Button", textControlName, asTransient ? string.Empty : "Standard")).InvokeAndWait();
 }
        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);
                }
            }
        }
Exemplo n.º 6
0
        public void TopPaddingTest()
        {
            // We cannot restrict the inner framesize for this test because it interacts with the titlebar area.
            using (var setup = new TestSetupHelper(testNames: new[] { "NavigationView Tests", "Top NavigationView Store Test" }, shouldRestrictInnerFrameSize: false))
            {
                var      moveContentUnderTitleBarButton         = new Button(FindElement.ById("MoveContentUnderTopnavTitleBar"));
                var      flipIsTitleBarAutoPaddingEnabledButton = new Button(FindElement.ById("FlipIsTitleBarAutoPaddingEnabledButton"));
                var      getTopPaddingHeightButton             = new Button(FindElement.ById("GetTopPaddingHeightButton"));
                var      fullScreenButton                      = new Button(FindElement.ById("FullScreenInvokerButton"));
                var      navViewIsTitleBarAutoPaddingEnabledId = "NavViewIsTitleBarAutoPaddingEnabled";
                var      topPaddingRenderedValueId             = "TopPaddingRenderedValue";
                UIObject navViewIsTitleBarAutoPaddingEnabled   = null;
                UIObject topNavTopPadding                      = null;

                // Checking top padding is added for regular Desktop
                Log.Comment("Setting TitleBar.ExtendViewIntoTitleBar to True");
                moveContentUnderTitleBarButton.Click();
                Wait.ForIdle();

                Log.Comment("Accessing TopPadding Height");
                getTopPaddingHeightButton.Click();
                Wait.ForIdle();

                navViewIsTitleBarAutoPaddingEnabled = TryFindElement.ById(navViewIsTitleBarAutoPaddingEnabledId);
                Verify.IsNotNull(navViewIsTitleBarAutoPaddingEnabled);
                Log.Comment($"NavView.IsTitleBarAutoPaddingEnabled: {navViewIsTitleBarAutoPaddingEnabled.GetText()}");
                Verify.AreEqual("True", navViewIsTitleBarAutoPaddingEnabled.GetText());

                topNavTopPadding = TryFindElement.ById(topPaddingRenderedValueId);
                Verify.IsNotNull(topNavTopPadding);
                Log.Comment($"TopPadding Height: {topNavTopPadding.GetText()}");

                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Verify.AreEqual("32", topNavTopPadding.GetText());
                }
                else
                {
                    // To detect if it's in tabbed sets, CoreApplicationViewTitleBar.IsVisible can be used to check in MUXControlsTestApp
                    // Not all branches enabled tabbed shell, also not all default setting with tabbed shell enabled
                    // We skip the test if tabbedshell is disabled.
                    if (TryFindElement.ById("TitleBarIsVisible").GetText().Equals("True"))
                    {
                        Log.Comment("Tabbed Shell is disabled or not enabled for this application, skip Verify");
                    }
                    else
                    {
                        Verify.AreEqual("0", topNavTopPadding.GetText());
                    }
                }

                Log.Comment("Setting IsTitleBarAutoPaddingEnabled to False");
                flipIsTitleBarAutoPaddingEnabledButton.Click();
                Wait.ForIdle();

                Log.Comment($"NavView.IsTitleBarAutoPaddingEnabled: {navViewIsTitleBarAutoPaddingEnabled.GetText()}");
                Verify.AreEqual("False", navViewIsTitleBarAutoPaddingEnabled.GetText());

                Log.Comment("Accessing TopPadding Height");
                getTopPaddingHeightButton.Click();
                Wait.ForIdle();
                Log.Comment($"TopPadding Height: {topNavTopPadding.GetText()}");
                Verify.AreEqual("0", topNavTopPadding.GetText());

                Log.Comment("Setting IsTitleBarAutoPaddingEnabled to True");
                flipIsTitleBarAutoPaddingEnabledButton.Click();
                Wait.ForIdle();

                Log.Comment($"NavView.IsTitleBarAutoPaddingEnabled: {navViewIsTitleBarAutoPaddingEnabled.GetText()}");
                Verify.AreEqual("True", navViewIsTitleBarAutoPaddingEnabled.GetText());

                // Checking top padding is NOT added for fullscreen Desktop
                Log.Comment("Setting TitleBar.ExtendViewIntoTitleBar to False");
                moveContentUnderTitleBarButton.Click();
                Wait.ForIdle();
                fullScreenButton.Click();
                Wait.ForIdle();

                Log.Comment("Setting TitleBar.ExtendViewIntoTitleBar to True");
                moveContentUnderTitleBarButton.Click();
                Wait.ForIdle();

                Log.Comment("Accessing TopPadding Height");
                getTopPaddingHeightButton.Click();
                Wait.ForIdle();
                Log.Comment($"TopPadding Height: {topNavTopPadding.GetText()}");
                Verify.AreEqual("0", topNavTopPadding.GetText());

                // Reverting changes to leave app in original state
                Log.Comment("Setting TitleBar.ExtendViewIntoTitleBar to False");
                moveContentUnderTitleBarButton.Click();
                Wait.ForIdle();
                fullScreenButton.Click();
                Wait.ForIdle();
            }
        }
        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 VerifyDynamicSecondaryCommandLabel()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Log.Comment("Retrieving FlyoutTarget6");
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout with no primary commands");

                Log.Comment("Retrieving IsFlyoutOpenCheckBox");
                ToggleButton isFlyoutOpenCheckBox = FindElement.ById <ToggleButton>("IsFlyoutOpenCheckBox");

                Log.Comment("Retrieving UseSecondaryCommandDynamicLabelCheckBox");
                ToggleButton useSecondaryCommandDynamicLabelCheckBox = FindElement.ById <ToggleButton>("UseSecondaryCommandDynamicLabelCheckBox");

                Log.Comment("SecondaryCommandDynamicLabelChangedCheckBox");
                ToggleButton secondaryCommandDynamicLabelChangedCheckBox = FindElement.ById <ToggleButton>("SecondaryCommandDynamicLabelChangedCheckBox");

                Log.Comment("Retrieving DynamicLabelTimerIntervalTextBox");
                Edit dynamicLabelTimerIntervalTextBox = new Edit(FindElement.ById("DynamicLabelTimerIntervalTextBox"));

                Log.Comment("Retrieving DynamicLabelChangeCountTextBox");
                Edit dynamicLabelChangeCountTextBox = new Edit(FindElement.ById("DynamicLabelChangeCountTextBox"));

                Verify.AreEqual(ToggleState.Off, isFlyoutOpenCheckBox.ToggleState);

                Log.Comment("Change the first command bar element's Label property asynchronously after the command bar is opened");
                useSecondaryCommandDynamicLabelCheckBox.Check();

                Log.Comment("Setting DynamicLabelTimerIntervalTextBox to 1s");
                dynamicLabelTimerIntervalTextBox.SetValue("1000");

                Log.Comment("Setting DynamicLabelChangeCountTextBox to 1 single change");
                dynamicLabelChangeCountTextBox.SetValue("1");
                Wait.ForIdle();

                Verify.AreEqual(ToggleState.Off, secondaryCommandDynamicLabelChangedCheckBox.ToggleState);

                Log.Comment("Invoking button 'Show CommandBarFlyout with no primary commands' to show the Flyout6 command bar.");
                showCommandBarFlyoutButton.Invoke();
                Wait.ForIdle();
                Verify.AreEqual(ToggleState.On, isFlyoutOpenCheckBox.ToggleState);

                Button undoButton6 = FindElement.ById <Button>("UndoButton6");
                Verify.IsNotNull(undoButton6);

                UIObject commandBarElementsContainer = undoButton6.Parent;
                Verify.IsNotNull(commandBarElementsContainer);

                Rectangle initialBoundingRectangle = commandBarElementsContainer.BoundingRectangle;

                Log.Comment("Initial commandBarElementsContainer.BoundingRectangle.Width=" + initialBoundingRectangle.Width);
                Log.Comment("Initial commandBarElementsContainer.BoundingRectangle.Height=" + initialBoundingRectangle.Height);

                Verify.AreEqual(ToggleState.Off, secondaryCommandDynamicLabelChangedCheckBox.ToggleState);

                Log.Comment("Waiting for SecondaryCommandDynamicLabelChangedCheckBox becoming checked indicating the asynchronous Label property change occurred");
                secondaryCommandDynamicLabelChangedCheckBox.GetToggledWaiter().Wait();
                Wait.ForIdle();

                Rectangle finalBoundingRectangle = commandBarElementsContainer.BoundingRectangle;

                Log.Comment("Final commandBarElementsContainer.BoundingRectangle.Width=" + finalBoundingRectangle.Width);
                Log.Comment("Final commandBarElementsContainer.BoundingRectangle.Height=" + finalBoundingRectangle.Height);

                Log.Comment("Hitting Escape key to close the command bar.");
                KeyboardHelper.PressKey(Key.Escape);
                Wait.ForIdle();

                Verify.AreEqual(ToggleState.Off, isFlyoutOpenCheckBox.ToggleState);

                Log.Comment("Verifying the command bar flyout width was increased to accommodate the longer label.");
                Verify.IsGreaterThan(finalBoundingRectangle.Width, initialBoundingRectangle.Width);
                Verify.AreEqual(finalBoundingRectangle.Height, initialBoundingRectangle.Height);
            }
        }
        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);
                }
            }
        }
        public void VerifyUpAndDownNavigationBetweenPrimaryAndSecondaryCommands()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout");

                Log.Comment("Tap on a button to show the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);

                Log.Comment("Press Down key to move focus to second primary command: Copy.");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();

                Button copyButton1       = FindElement.ById <Button>("CopyButton1");
                var    copyButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(copyButtonElement.Current.AutomationId, copyButton1.AutomationId);

                Log.Comment("Press Up key to move focus back to first primary command: Cut.");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();

                Button cutButton1       = FindElement.ById <Button>("CutButton1");
                var    cutButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(cutButtonElement.Current.AutomationId, cutButton1.AutomationId);

                Log.Comment("Press Down key to move focus to last primary command: Underline.");
                for (int i = 0; i <= 4; i++)
                {
                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                }

                Button underlineButton1       = FindElement.ById <Button>("UnderlineButton1");
                var    underlineButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(underlineButtonElement.Current.AutomationId, underlineButton1.AutomationId);

                Log.Comment("Press Down key to move focus to MoreButton.");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();

                Button moreButton        = FindElement.ById <Button>("MoreButton");
                var    moreButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(moreButtonElement.Current.AutomationId, moreButton.AutomationId);

                Log.Comment("Press Up key to move focus to first primary command: Cut.");
                for (int i = 0; i <= 5; i++)
                {
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                }

                cutButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(cutButtonElement.Current.AutomationId, cutButton1.AutomationId);

                Log.Comment("Press Up key to move focus to last secondary command: Favorite.");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();

                Button favoriteToggleButton1       = FindElement.ById <Button>("FavoriteToggleButton1");
                var    favoriteToggleButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(favoriteToggleButtonElement.Current.AutomationId, favoriteToggleButton1.AutomationId);

                Log.Comment("Press Up key to move focus to first secondary command: Undo.");
                for (int i = 0; i <= 2; i++)
                {
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                }

                Button undoButton1       = FindElement.ById <Button>("UndoButton1");
                var    undoButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(undoButtonElement.Current.AutomationId, undoButton1.AutomationId);

                if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3))
                {
                    Log.Comment("Press Up key and remain on first secondary command: Undo.");
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();

                    undoButtonElement = AutomationElement.FocusedElement;
                    Verify.AreEqual(undoButtonElement.Current.AutomationId, undoButton1.AutomationId);
                }
                else
                {
                    Log.Comment("Press Up key to move focus to MoreButton.");
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();

                    moreButtonElement = AutomationElement.FocusedElement;
                    Verify.AreEqual(moreButtonElement.Current.AutomationId, moreButton.AutomationId);

                    Log.Comment("Press Down key to move focus to first primary command through all secondary commands: Cut.");
                    for (int i = 0; i <= 4; i++)
                    {
                        KeyboardHelper.PressKey(Key.Down);
                        Wait.ForIdle();
                    }

                    cutButtonElement = AutomationElement.FocusedElement;
                    Verify.AreEqual(cutButtonElement.Current.AutomationId, cutButton1.AutomationId);
                }
            }
        }
        public void VerifyUpAndDownNavigationBetweenPrimaryAndSecondaryCommandsWithAlwaysExpanded()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout with AlwaysExpanded");

                Log.Comment("Tap on a button to show the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);

                Log.Comment("Press Down key to move focus to last primary command: Underline.");
                for (int i = 0; i < 5; i++)
                {
                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();
                }

                Button underlineButton9 = FindElement.ById <Button>("UnderlineButton9");
                Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, underlineButton9.AutomationId);

                Button undoButton9 = FindElement.ById <Button>("UndoButton9");

                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
                {
                    Log.Comment("Press Down key to move focus to first secondary command: Undo.");
                    KeyboardHelper.PressKey(Key.Down);
                    Wait.ForIdle();

                    Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, undoButton9.AutomationId);

                    Log.Comment("Press Up key to move focus to first primary command: Cut.");
                    for (int i = 0; i < 6; i++)
                    {
                        KeyboardHelper.PressKey(Key.Up);
                        Wait.ForIdle();
                    }
                }
                else
                {
                    Log.Comment("Press Up key to move focus to first primary command: Cut.");
                    for (int i = 0; i < 5; i++)
                    {
                        KeyboardHelper.PressKey(Key.Up);
                        Wait.ForIdle();
                    }
                }

                Button cutButton9 = FindElement.ById <Button>("CutButton9");
                Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, cutButton9.AutomationId);

                Log.Comment("Press Up key to move focus to last secondary command: Favorite.");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();

                Button favoriteToggleButton9 = FindElement.ById <Button>("FavoriteToggleButton9");
                Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, favoriteToggleButton9.AutomationId);

                Log.Comment("Press Up key to move focus to first secondary command: Undo.");
                for (int i = 0; i < 3; i++)
                {
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();
                }

                Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, undoButton9.AutomationId);

                if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone3))
                {
                    Log.Comment("Press Up key and remain on first secondary command: Undo.");
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();

                    Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, undoButton9.AutomationId);
                }
                else
                {
                    Log.Comment("Press Up key to move focus to last primary command: Underline.");
                    KeyboardHelper.PressKey(Key.Up);
                    Wait.ForIdle();

                    Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, underlineButton9.AutomationId);

                    Log.Comment("Press Down key to move focus to first primary command through all secondary commands: Cut.");
                    for (int i = 0; i < 5; i++)
                    {
                        KeyboardHelper.PressKey(Key.Down);
                        Wait.ForIdle();
                    }

                    Verify.AreEqual(AutomationElement.FocusedElement.Current.AutomationId, cutButton9.AutomationId);

                    Log.Comment("Tapping on a button to hide the CommandBarFlyout.");
                    InputHelper.Tap(showCommandBarFlyoutButton);
                }
            }
        }
        private void VerifyLeftAndRightNavigationBetweenPrimaryCommands(bool inRTL, bool useUpDownKeys)
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout");

                if (inRTL)
                {
                    ToggleButton isRTLCheckBox = FindElement.ById <ToggleButton>("IsRTLCheckBox");

                    Log.Comment("Switch to RightToLeft FlowDirection.");
                    isRTLCheckBox.Toggle();
                    Wait.ForIdle();
                }

                string rightStr;
                string leftStr;
                Key    rightKey;
                Key    leftKey;

                if (useUpDownKeys)
                {
                    // Down and Up keys are used to move logically within the primary commands: Up to move to the previous command and Down to move to the next command.
                    rightStr = "Down";
                    leftStr  = "Up";
                    rightKey = Key.Down;
                    leftKey  = Key.Up;
                }
                else
                {
                    // Left and Right keys are used to move physically within the primary commands: Left to move to the left command and Right to move to the right command.
                    rightStr = inRTL ? "Left" : "Right";
                    leftStr  = inRTL ? "Right" : "Left";
                    rightKey = inRTL ? Key.Left : Key.Right;
                    leftKey  = inRTL ? Key.Right : Key.Left;
                }

                Log.Comment("Tap on a button to show the CommandBarFlyout.");
                InputHelper.Tap(showCommandBarFlyoutButton);

                Log.Comment($"Press {rightStr} key to move focus to second primary command: Copy.");
                KeyboardHelper.PressKey(rightKey);
                Wait.ForIdle();

                Button copyButton1       = FindElement.ById <Button>("CopyButton1");
                var    copyButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(copyButtonElement.Current.AutomationId, copyButton1.AutomationId);

                Log.Comment($"Press {leftStr} key to move focus back to first primary command: Cut.");
                KeyboardHelper.PressKey(leftKey);
                Wait.ForIdle();

                Button cutButton1       = FindElement.ById <Button>("CutButton1");
                var    cutButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(cutButtonElement.Current.AutomationId, cutButton1.AutomationId);

                if (!useUpDownKeys)
                {
                    Log.Comment($"Press {leftStr} key and remain on first primary command: Cut.");
                    KeyboardHelper.PressKey(leftKey);
                    Wait.ForIdle();

                    cutButtonElement = AutomationElement.FocusedElement;
                    Verify.AreEqual(cutButtonElement.Current.AutomationId, cutButton1.AutomationId);
                }

                Log.Comment($"Press {rightStr} key to move focus to MoreButton.");
                for (int i = 0; i <= 5; i++)
                {
                    KeyboardHelper.PressKey(rightKey);
                    Wait.ForIdle();
                }

                Button moreButton        = FindElement.ById <Button>("MoreButton");
                var    moreButtonElement = AutomationElement.FocusedElement;
                Verify.AreEqual(moreButtonElement.Current.AutomationId, moreButton.AutomationId);

                if (!useUpDownKeys)
                {
                    Log.Comment($"Press {rightStr} key and remain on MoreButton.");
                    KeyboardHelper.PressKey(rightKey);
                    Wait.ForIdle();

                    moreButtonElement = AutomationElement.FocusedElement;
                    Verify.AreEqual(moreButtonElement.Current.AutomationId, moreButton.AutomationId);
                }
            }
        }
        public void CanTapOnSecondaryItems()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button       showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout");
                ToggleButton isFlyoutOpenCheckBox       = FindElement.ById <ToggleButton>("IsFlyoutOpenCheckBox");

                Action openCommandBarAction = () =>
                {
                    Log.Comment("Tapping on a button to show the CommandBarFlyout.");
                    InputHelper.Tap(showCommandBarFlyoutButton);

                    // Pre-RS5, CommandBarFlyouts always open expanded,
                    // so we don't need to tap on the more button in that case.
                    if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                    {
                        Log.Comment("Expanding the CommandBar by invoking the more button.");
                        FindElement.ById <Button>("MoreButton").InvokeAndWait();
                    }
                };

                Log.Comment("Opening the CommandBar and invoking the first button in the secondary commands list.");
                openCommandBarAction();

                using (var waiter = isFlyoutOpenCheckBox.GetToggledWaiter())
                {
                    setup.ExecuteAndWaitForEvents(() => FindElement.ById <Button>("UndoButton1").Invoke(), new List <string>()
                    {
                        "UndoButton1 clicked"
                    });
                    waiter.Wait();
                }

                Verify.IsTrue(isFlyoutOpenCheckBox.ToggleState == ToggleState.Off);

                Log.Comment("Opening the CommandBar and invoking the second button in the secondary commands list.");
                openCommandBarAction();

                using (var waiter = isFlyoutOpenCheckBox.GetToggledWaiter())
                {
                    setup.ExecuteAndWaitForEvents(() => FindElement.ById <Button>("RedoButton1").Invoke(), new List <string>()
                    {
                        "RedoButton1 clicked"
                    });
                    waiter.Wait();
                }

                Verify.IsTrue(isFlyoutOpenCheckBox.ToggleState == ToggleState.Off);

                Log.Comment("Opening the CommandBar and invoking the third button in the secondary commands list.");
                openCommandBarAction();

                using (var waiter = isFlyoutOpenCheckBox.GetToggledWaiter())
                {
                    setup.ExecuteAndWaitForEvents(() => FindElement.ById <Button>("SelectAllButton1").Invoke(), new List <string>()
                    {
                        "SelectAllButton1 clicked"
                    });
                    waiter.Wait();
                }

                Verify.IsTrue(isFlyoutOpenCheckBox.ToggleState == ToggleState.Off);

                Log.Comment("Opening the CommandBar and invoking the toggle button in the secondary commands list.");
                openCommandBarAction();

                using (var waiter = isFlyoutOpenCheckBox.GetToggledWaiter())
                {
                    setup.ExecuteAndWaitForEvents(() => FindElement.ById <ToggleButton>("FavoriteToggleButton1").Toggle(), new List <string>()
                    {
                        "FavoriteToggleButton1 checked"
                    });
                    waiter.Wait();
                }

                Verify.IsTrue(isFlyoutOpenCheckBox.ToggleState == ToggleState.Off);
            }
        }
Exemplo n.º 14
0
        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);

                    // Clear any item selection
                    var clearSelectedItemButton = new Button(FindElement.ByName("ClearSelectedItemButton"));
                    clearSelectedItemButton.Click();
                    Wait.ForIdle();

                    Verify.AreEqual("null", GetSelectedItem());

                    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 item7        = FindElement.ByName("Volume");
                    UIObject item8        = FindElement.ByName("Integer");
                    UIObject item9        = FindElement.ByName("HasChildItem");
                    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);

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

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

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

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

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

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

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

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

                    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);
                }

                string GetSelectedItem()
                {
                    return(FindElement.ByName("SelectionChangedItemType").GetText());
                }
            }
        }
        private bool IsUsingAcrylicBrush()
        {
            TextBlock IsUsingAcrylicBrush_TextBlock = new TextBlock(FindElement.ById("IsUsingAcrylicBrush"));

            return(IsUsingAcrylicBrush_TextBlock.DocumentText.Equals("True"));
        }
        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);
                }
            }
        }
Exemplo n.º 17
0
 public TextCommandBarFlyoutTestSetupHelper(string languageOverride = "", bool attemptRestartOnDispose = true)
     : base(new[] { "CommandBarFlyout Tests", "TextCommandBarFlyout Tests" }, languageOverride, attemptRestartOnDispose)
 {
     FindElement.ById <Button>("ClearClipboardContentsButton").InvokeAndWait();
 }
        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);
            }
        }
Exemplo n.º 19
0
        public void ScrollWhileUsingExpressionAnimationSources()
        {
            Log.Comment("Selecting Scroller tests");

            using (var setup = new TestSetupHelper("Scroller Tests"))
            {
                SetOutputDebugStringLevel("Verbose");

                Log.Comment("Navigating to ScrollerExpressionAnimationSourcesPage");
                UIObject navigateToExpressionAnimationSourcesUIObject = FindElement.ByName("navigateToExpressionAnimationSources");
                Verify.IsNotNull(navigateToExpressionAnimationSourcesUIObject, "Verifying that navigateToExpressionAnimationSources Button was found");

                Button navigateToExpressionAnimationSourcesButton = new Button(navigateToExpressionAnimationSourcesUIObject);
                navigateToExpressionAnimationSourcesButton.Invoke();
                Wait.ForIdle();

                SetLoggingLevel(isPrivateLoggingEnabled: true);

                Log.Comment("Retrieving Scroller");
                Scroller scrollerUIObject = new Scroller(FindElement.ByName("scroller"));
                Verify.IsNotNull(scrollerUIObject, "Verifying that Scroller was found");

                Verify.IsTrue(scrollerUIObject.HorizontallyScrollable, "Verifying HorizontallyScrollable is true");
                Verify.IsTrue(scrollerUIObject.HorizontalViewSize > 0.0, "Verifying HorizontalViewSize is positive");
                Verify.AreEqual(scrollerUIObject.HorizontalScrollPercent, 0.0, "Verifying HorizontalScrollPercent is zero");

                Log.Comment("Waiting for final layout");
                WaitForEditValue(editName: "txtLayoutCompleted", editValue: "Yes");

                Edit textBox = new Edit(FindElement.ById("txtViewport"));
                Log.Comment("Viewport: " + textBox.Value);
                textBox = new Edit(FindElement.ById("txtExtent"));
                Log.Comment("Extent: " + textBox.Value);
                textBox = new Edit(FindElement.ById("txtBarVisualWidth"));

                Log.Comment("Scrolling Scroller horizontally and vertically");
                scrollerUIObject.SetScrollPercent(10.0, 20.0);

                Log.Comment("Waiting for HorizontalScrollPercent={0} to change", scrollerUIObject.HorizontalScrollPercent);
                Wait.ForScrollChanged(scrollerUIObject, ScrollProperty.HorizontalScrollPercent);

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

                if (Math.Abs(scrollerUIObject.HorizontalScrollPercent - 10.0) >= 0.0001 ||
                    Math.Abs(scrollerUIObject.VerticalScrollPercent - 20.0) >= 0.0001)
                {
                    LogAndClearTraces();
                }

                SetLoggingLevel(isPrivateLoggingEnabled: false);

                Verify.IsTrue(scrollerUIObject.HorizontallyScrollable, "Verifying HorizontallyScrollable is true");
                Verify.IsTrue(scrollerUIObject.HorizontalViewSize > 0.0, "Verifying HorizontalViewSize is positive");
                Verify.IsLessThan(Math.Abs(scrollerUIObject.HorizontalScrollPercent - 10.0), 0.0001, "Verifying HorizontalScrollPercent is close to 10.0");

                Verify.IsTrue(scrollerUIObject.VerticallyScrollable, "Verifying VerticallyScrollable is true");
                Verify.IsTrue(scrollerUIObject.VerticalViewSize > 0.0, "Verifying VerticalViewSize is positive");
                Verify.IsLessThan(Math.Abs(scrollerUIObject.VerticalScrollPercent - 20.0), 0.0001, "Verifying VerticalScrollPercent is close to 20.0");

                Log.Comment("Returning to the main Scroller test page");
                TestSetupHelper.GoBack();
                // Output-debug-string-level "None" is automatically restored when landing back on the Scroller test page.
            }
        }
Exemplo n.º 20
0
        public void RevealHoverLightPosition_Values()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Comment("RevealHoverLightPosition_Values needs to be running on RS2 or greater");
                return;
            }

            using (var setup = new TestSetupHelper(new[] { "Reveal Tests", "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");
            }
        }
        public void ValidateKeyboarding()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                Log.Warning("Test is disabled pre-RS5 because the keyboarding fixes needed to support this were not available pre-RS5.");
                return;
            }

            using (var setup = new TextCommandBarFlyoutTestSetupHelper())
            {
                Log.Comment("Give focus to the TextBox.");
                var textBox = FindElement.ById("TextBox");
                FocusHelper.SetFocus(textBox);

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromName("Select All")))
                {
                    Log.Comment("Use Shift+F10 to bring up the context menu. The Select All button should get focus.");
                    KeyboardHelper.PressKey(Key.F10, ModifierKey.Shift);
                    waiter.Wait();
                }

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromId("TextBox")))
                {
                    Log.Comment("Use Escape to close the context menu. The TextBox should now have focus.");
                    KeyboardHelper.PressKey(Key.Escape);

                    // On 19H1, there's a bug with the focus restoration code, so we'll manually restore focus to allow the rest of the test to run.
                    if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.NineteenH1))
                    {
                        textBox.SetFocus();
                    }

                    waiter.Wait();
                }

                Log.Comment("Give focus to the RichEditBox.");
                var richEditBox = FindElement.ById("RichEditBox");
                FocusHelper.SetFocus(richEditBox);

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromName("Bold")))
                {
                    Log.Comment("Use Shift+F10 to bring up the context menu. The Bold button should get focus.");
                    KeyboardHelper.PressKey(Key.F10, ModifierKey.Shift);
                    waiter.Wait();
                }

                Log.Comment("Press the spacebar to invoke the bold button. Focus should stay in the flyout.");
                KeyboardHelper.PressKey(Key.Space);
                Wait.ForIdle();

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromName("More app bar")))
                {
                    Log.Comment("Press the right arrow key three times.  The '...' button should get focus.");
                    KeyboardHelper.PressKey(Key.Right, ModifierKey.None, numPresses: 3);
                    waiter.Wait();
                }

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromName("Select All")))
                {
                    Log.Comment("Press the down arrow key twice.  The Select All button should get focus.");
                    KeyboardHelper.PressKey(Key.Down, ModifierKey.None, numPresses: 2);
                    waiter.Wait();
                }

                using (var waiter = new FocusAcquiredWaiter(UICondition.CreateFromId("RichEditBox")))
                {
                    Log.Comment("Use Escape to close the context menu. The RichEditBox should now have focus.");
                    KeyboardHelper.PressKey(Key.Escape);

                    // On 19H1, there's a bug with the focus restoration code, so we'll manually restore focus to allow the rest of the test to run.
                    if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.NineteenH1))
                    {
                        richEditBox.SetFocus();
                    }

                    waiter.Wait();
                }
            }
        }
Exemplo n.º 22
0
        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.º 23
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.º 24
0
        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");
            }
        }
Exemplo n.º 25
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.º 26
0
        // [TestMethod]
        public void VerifyRatingItemFallback()
        {
            // This test is actually performed in the test app itself, so go look at RatingControlPage.xaml.cs for the meat of it.

            using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page.
            {
                if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone1))
                {
                    Log.Warning("Test is disabled on RS1 due to scrolling unreliability");
                    return;
                }

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

                InputHelper.ScrollToElement(popRating);

                popRating.Tap(); // Since on phone it's touch, I do a tap to trigger that.
                popRating.Click();
                Wait.ForIdle();

                Log.Comment("Retrieve PointerOverFallbackRating rating control as generic UIElement");
                UIObject pointerOver = FindElement.ById("PointerOverFallbackRating");
                Verify.IsNotNull(pointerOver, "Verifying that we found a UIElement called PointerOverFallbackRating");
                InputHelper.ScrollToElement(pointerOver);
                pointerOver.Click();
                pointerOver.Tap();
                Wait.ForIdle();

                TextBlock textBlock = new TextBlock(FindElement.ById("UnsetFallbackTextBlock"));
                Verify.AreEqual("+", textBlock.DocumentText, "Verify Unset glyph falls back onto Glyph");
                TextBlock textBlock2 = new TextBlock(FindElement.ById("PlaceholderFallbackTextBlock"));
                Verify.AreEqual("+", textBlock2.DocumentText, "Verify Placeholder glyph falls back onto Glyph");
                TextBlock textBlock3 = new TextBlock(FindElement.ById("DisabledFallbackTextBlock"));
                Verify.AreEqual("+", textBlock3.DocumentText, "Verify Disabled glyph falls back onto Glyph");

                ElementCache.Clear();

                TextBlock textBlock4 = new TextBlock(FindElement.ById("PointerOverPlaceholderFallbackTextBlock"));
                Verify.AreEqual("+", textBlock4.DocumentText, "Verify PointerOverPlaceholder glyph falls back onto Placeholder");
                TextBlock textBlock5 = new TextBlock(FindElement.ById("PointerOverFallbackTextBlock"));
                Verify.AreEqual("+", textBlock5.DocumentText, "Verify PointerOver glyph falls back onto Glyph");
                TextBlock textBlock6 = new TextBlock(FindElement.ById("NoFallbackTextBlock"));
                Verify.AreEqual("+", textBlock6.DocumentText, "Verify a glyph didn't fall back if it wasn't meant to");

                // Image:
                Log.Comment("Retrieve PointerOverPlaceholderImageFallbackRating rating control as generic UIElement");
                popRating = FindElement.ById("PointerOverPlaceholderImageFallbackRating");
                Verify.IsNotNull(popRating, "Verifying that we found a UIElement called PointerOverPlaceholderImageFallbackRating");

                InputHelper.ScrollToElement(popRating);
                Wait.ForIdle();

                popRating.Tap(); // Since on phone it's touch, I do a tap to trigger that.
                popRating.Click();
                Wait.ForIdle();

                Log.Comment("Retrieve PointerOverImageFallbackRating rating control as generic UIElement");
                pointerOver = FindElement.ById("PointerOverImageFallbackRating");
                Verify.IsNotNull(pointerOver, "Verifying that we found a UIElement called PointerOverImageFallbackRating");
                pointerOver.Tap();
                pointerOver.Click();
                Wait.ForIdle();

                textBlock = new TextBlock(FindElement.ById("UnsetImageFallbackTextBlock"));
                Verify.AreEqual("+", textBlock.DocumentText, "Verify Unset image falls back onto Image");
                textBlock2 = new TextBlock(FindElement.ById("PlaceholderImageFallbackTextBlock"));
                Verify.AreEqual("+", textBlock2.DocumentText, "Verify Placeholder image falls back onto Image");
                textBlock3 = new TextBlock(FindElement.ById("DisabledImageFallbackTextBlock"));
                Verify.AreEqual("+", textBlock3.DocumentText, "Verify Disabled image falls back onto Image");

                ElementCache.Clear();
                textBlock4 = new TextBlock(FindElement.ById("PointerOverPlaceholderImageFallbackTextBlock"));
                Verify.AreEqual("+", textBlock4.DocumentText, "Verify PointerOverPlaceholder image falls back onto PlaceholderImage");
                textBlock5 = new TextBlock(FindElement.ById("PointerOverImageFallbackTextBlock"));
                Verify.AreEqual("+", textBlock5.DocumentText, "Verify PointerOver image falls back onto Image");
            }
        }
Exemplo n.º 27
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());
                    });
                }
            }
        }
        // Regression Test for Bug 11144540:Acrylic noise surface is lost after workstation sleep/resume
        //[TestMethod]
        //[TestProperty("Platform", "Desktop")]
        // Disabled due to: Bug 19996114: Unstable test: InteractionTests.AcrylicBrushTests.HideAndShowWindow
        public void HideAndShowWindow()
        {
            if (!OnRS2OrGreater())
            {
                return;
            }

            using (IDisposable page1 = new TestSetupHelper("Acrylic Tests"),
                   page2 = new TestSetupHelper("navigateToBasicAcrylic"))
            {
                {
                    ChooseFromComboBox("TestNameComboBox", "HideAndShowWindow");

                    if (PlatformConfiguration.IsDevice(DeviceType.Phone))
                    {
                        Log.Warning("Test is disabled on phone.");
                        return;
                    }

                    Button runTestButton;
                    var    result = new Edit(FindElement.ById("TestResult"));
                    using (var waiter = new ValueChangedEventWaiter(result))
                    {
                        runTestButton = new Button(FindElement.ById("RunTestButton"));
                        runTestButton.Invoke();
                        LogBrushSate();
                        waiter.Wait();
                    }

                    if (result.Value.Equals("HideAndShowWindow: Skipped"))
                    {
                        Log.Error("Error: FallbackBrush in use - expecting effect brush");
                        return;
                    }
                    else if (TestEnvironment.Application.ApplicationFrameWindow == null)
                    {
                        Log.Comment("Skipping test: No ApplicationFrameWindow (likely unsupported platform)");
                        return;
                    }
                    else
                    {
                        Thread waiterThread = new Thread(HideAndShowWindow_WaiterThreadProc);
                        waiterThread.Name = " HideAndShowWindow_WaiterThread";
                        waiterThread.Start();

                        Window            window             = new Window(TestEnvironment.Application.ApplicationFrameWindow);
                        WindowVisualState initialVisualState = window.WindowVisualState;
                        Verify.AreNotEqual(initialVisualState, WindowVisualState.Minimized);

                        // Minimize the app, which will also trigger it to supsend. Wait for Suspending event from app.
                        Log.Comment("Minimizing the window...");
                        window.SetWindowVisualState(WindowVisualState.Minimized);
                        HideAndShowWindow_GotWindowHiddenEvent.WaitOne();

                        // Restore the app. Wait for VisibilityChanged -> Visible event from app.
                        Log.Comment("Restoring the window...");
                        window.SetWindowVisualState(initialVisualState);
                        HideAndShowWindow_GotWindowVisibleEvent.WaitOne();

                        // Trigger test to validate that noise has been recreated (see Bug 11144540)
                        using (var waiter = new ValueChangedEventWaiter(result))
                        {
                            runTestButton.Invoke();
                            waiter.Wait();
                        }

                        // Read off validation result and complete the test
                        Verify.AreEqual(result.Value, "HideAndShowWindow: Passed");

                        Wait.ForIdle();
                    }
                }
            }
        }
Exemplo n.º 29
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.º 30
0
 public CommandBarFlyoutTestSetupHelper(string languageOverride = "", bool attemptRestartOnDispose = true)
     : base(new[] { "CommandBarFlyout Tests", "Base CommandBarFlyout Tests" }, languageOverride, attemptRestartOnDispose)
 {
     statusReportingTextBox = FindElement.ById <Edit>("StatusReportingTextBox");
 }