Пример #1
0
        public void AutomationPeerTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                var fileButton   = FindElement.ById <Button>("FileItem");
                var fileButtonEC = new ExpandCollapseImplementation(fileButton);

                // Invoke
                fileButton.Invoke();
                Wait.ForIdle();
                VerifyElement.Found("New", FindBy.Name);
                fileButton.Invoke();
                Wait.ForIdle();
                VerifyElement.NotFound("New", FindBy.Name);

                // Expand collapse
                fileButtonEC.Expand();
                Wait.ForIdle();
                VerifyElement.Found("New", FindBy.Name);
                fileButtonEC.Collapse();
                Wait.ForIdle();
                VerifyElement.NotFound("New", FindBy.Name);

                // Verify GetNameCore() is working if AutomationProperties.Name isn't set
                VerifyElement.Found("Format", FindBy.Name);
            }
        }
Пример #2
0
        public void AddRemoveMenuBarItemTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                var addButton    = FindElement.ById <Button>("AddMenuBarItemButton");
                var removeButton = FindElement.ById <Button>("RemoveMenuBarItemButton");

                Log.Comment("Verify that menu bar items can be added");
                addButton.Invoke();
                VerifyElement.Found("New Menu Bar Item", FindBy.Name);

                Log.Comment("Verify that menu bar items can be removed");
                removeButton.Invoke();
                VerifyElement.NotFound("New Menu Bar Item", FindBy.Name);

                Log.Comment("Verify that menu bar pre-existing items can be removed");
                VerifyElement.Found("Format", FindBy.Name);
                removeButton.Invoke();
                VerifyElement.NotFound("Format", FindBy.Name);
            }
        }
Пример #3
0
        // Disabled due to: MenuBarTests.KeyboardNavigationWithAccessKeysTest unreliable #135
        public void KeyboardNavigationWithAccessKeysTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                {
                    Log.Warning("Test is disabled on versions older that RS4");
                    return;
                }

                KeyboardHelper.PressDownModifierKey(ModifierKey.Alt);
                KeyboardHelper.ReleaseModifierKey(ModifierKey.Alt);
                Wait.ForIdle();

                TextInput.SendText("A"); // this clicks File menu bar item
                Wait.ForIdle();
                TextInput.SendText("B"); // this clicks New flyout item
                Wait.ForIdle();

                VerifyElement.Found("New Clicked", FindBy.Name);
            }
        }
Пример #4
0
        public void KeyboardAcceleratorsTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                if (!ApiInformation.IsTypePresent("Windows.UI.Xaml.Input.KeyboardAccelerator"))
                {
                    Log.Warning("Test is disabled on versions that not support KeyboardAccelerator");
                    return;
                }

                VerifyElement.NotFound("Undo Clicked", FindBy.Name);

                KeyboardHelper.PressDownModifierKey(ModifierKey.Control);
                Log.Comment("Send text z.");
                TextInput.SendText("z");
                KeyboardHelper.ReleaseModifierKey(ModifierKey.Control);

                Wait.ForIdle();

                VerifyElement.Found("Undo Clicked", FindBy.Name);
            }
        }
        public void BasicInteractionTest()
        {
            using (var setup = new TestSetupHelper("SplitButton Tests"))
            {
                SplitButton splitButton = FindElement.ByName <SplitButton>("TestSplitButton");

                TextBlock clickCountTextBlock        = FindElement.ByName <TextBlock>("ClickCountTextBlock");
                TextBlock flyoutOpenedCountTextBlock = FindElement.ByName <TextBlock>("FlyoutOpenedCountTextBlock");
                TextBlock flyoutClosedCountTextBlock = FindElement.ByName <TextBlock>("FlyoutClosedCountTextBlock");

                Verify.AreEqual("0", clickCountTextBlock.DocumentText);
                ClickPrimaryButton(splitButton);
                Verify.AreEqual("1", clickCountTextBlock.DocumentText);
                VerifyElement.NotFound("TestFlyout", FindBy.Name);

                Verify.AreEqual("0", flyoutOpenedCountTextBlock.DocumentText);
                ClickSecondaryButton(splitButton);
                Verify.AreEqual("1", flyoutOpenedCountTextBlock.DocumentText);
                VerifyElement.Found("TestFlyout", FindBy.Name);

                Verify.AreEqual("0", flyoutClosedCountTextBlock.DocumentText);
                Log.Comment("Close flyout by clicking over the button");
                splitButton.Click();
                Wait.ForIdle();
                Verify.AreEqual("1", flyoutClosedCountTextBlock.DocumentText);
            }
        }
Пример #6
0
        public void KeyboardNavigationWithArrowKeysTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                var editButton = FindElement.ById <Button>("EditItem");
                editButton.Invoke();
                VerifyElement.Found("Undo", FindBy.Name);

                KeyboardHelper.PressKey(Key.Left);
                VerifyElement.Found("New", FindBy.Name);

                KeyboardHelper.PressKey(Key.Escape);
                VerifyElement.NotFound("New", FindBy.Name);

                if (ApiInformation.IsTypePresent("Windows.UI.Xaml.IUIElement5")) // XYFocusNavigation is only availabe from IUElement5 foward
                {
                    KeyboardHelper.PressKey(Key.Right);
                    VerifyElement.NotFound("Undo", FindBy.Name);

                    KeyboardHelper.PressKey(Key.Enter);
                    VerifyElement.Found("Undo", FindBy.Name);
                }
            }
        }
 public void PaneFooterContentTest()
 {
     using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
     {
         Log.Comment("Verify that button in PaneFooterContent exists");
         VerifyElement.Found("FooterButton", FindBy.Id);
     }
 }
Пример #8
0
        //[TestMethod]
        // Disabled due to: Multiple unreliable NavigationView tests #134
        public void SuppressSelectionItemInvokeTest()
        {
            using (IDisposable page1 = new TestSetupHelper("NavigationView Tests"),
                   page2 = new TestSetupHelper("Top NavigationView Store Test"))
            {
                var removeItemButton = new Button(FindElement.ById("RemoveItemButton"));
                var addItemSuppressSelectionButton = new Button(FindElement.ById("AddItemSuppressSelectionButton"));
                var clearItemInvokedTextButton     = new Button(FindElement.ById("ClearItemInvokedTextButton"));

                removeItemButton.Click();
                Wait.ForIdle();
                removeItemButton.Click();
                Wait.ForIdle();
                removeItemButton.Click();
                Wait.ForIdle();
                addItemSuppressSelectionButton.Click();
                Wait.ForIdle();

                VerifyElement.Found("sup-selection-nav-item-0", FindBy.Id);
                var supSelectItem0 = TryFindElement.ById("sup-selection-nav-item-0");
                supSelectItem0.Click();
                Wait.ForIdle();

                var itemInvokedText = TryFindElement.ById("ItemInvokedText");
                Verify.AreEqual("New Menu Item S.S", itemInvokedText.GetText());

                clearItemInvokedTextButton.Click();
                Wait.ForIdle();
                Verify.AreEqual(string.Empty, itemInvokedText.GetText());

                UIObject moreButton = null;
                Log.Comment("Adding items until the More button shows up.");

                while (moreButton == null)
                {
                    moreButton = TryFindElement.ById("TopNavOverflowButton");

                    if (moreButton == null)
                    {
                        addItemSuppressSelectionButton.Click();
                        Log.Comment("Item added.");
                        Wait.ForIdle();
                    }
                }

                moreButton.Click();
                Wait.ForIdle();

                var firstChildOverflow = GetTopNavigationItems(TopNavPosition.Overflow)[0];
                firstChildOverflow.Click();
                Wait.ForIdle();

                itemInvokedText = TryFindElement.ById("ItemInvokedText");
                Verify.AreEqual("New Menu Item S.S", itemInvokedText.GetText());
            }
        }
        public void VerifyPaneVisibleOnInit()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Init Test" }))
            {
                Log.Comment("Verify PaneIsVisibleItem is invisible");
                VerifyElement.NotFound("PaneIsVisibleItem", FindBy.Name);

                FindElement.ByName <Button>("ChangePaneVisible").Invoke();
                Wait.ForIdle();

                Log.Comment("Verify PaneIsVisibleItem is visible");
                VerifyElement.Found("PaneIsVisibleItem", FindBy.Name);
            }
        }
Пример #10
0
        // To verify two problems:
        // 1. NavigationViewItem not in overflow menu
        //      Layout doesn't know about overflow, so changing the content of NavigationViewItem may not trigger MeasureOverride
        //      Verify NavigationView will handle this
        // 2. NavigationViewItem in overflow menu
        //      We cached the Width when moving items to overflow, and cached width would be used to recover items to primary
        //      This test case verifies that cache is invalidated if content is changed for NavigationViewItem
        public void VerifyNavigationViewContentChangeOnTopNavImpactsLayout()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                Log.Comment("Verify there is overflow button");
                VerifyElement.Found("TopNavOverflowButton", FindBy.Id);

                Verify.IsTrue(IsItemInTopNavPrimaryList("Games"), "Games not in overflow");

                Log.Comment("Change Games Content to a long string");
                Button changeGamesContent = new Button(FindElement.ByName("ChangeGamesContent"));
                changeGamesContent.Invoke();
                Wait.ForIdle();

                Log.Comment("Verify Content change in primary may push Games item to overflow");
                Verify.IsFalse(IsItemInTopNavPrimaryList("Games"), "Games is moved to overflow");

                Log.Comment("Clear Content of all NavigationViewItems");
                Button clearNavItemContent = new Button(FindElement.ByName("ClearNavItemContent"));
                clearNavItemContent.Invoke();
                Wait.ForIdle();

                Log.Comment("Verify all items are moved out of overflow menu");
                VerifyElement.NotFound("TopNavOverflowButton", FindBy.Id);

                Log.Comment("Change Games Content to a long string");
                changeGamesContent.Invoke();
                Wait.ForIdle();

                Log.Comment("Verify change content of Game makes it to overflow");
                Verify.IsFalse(IsItemInTopNavPrimaryList("Games"), "Games is moved to overflow");

                Log.Comment("Clear Content of Games which is in overflow");
                clearNavItemContent.Invoke();
                Wait.ForIdle();

                // If NavigationViewItem is in overflow and the popup is not opened, we can't get NavigationView by the visualtree from NavigationViewItem itself
                // Change the content of NavigationViewItem in overflow will not Invalidate Layout, and request user to invalid measure.
                Log.Comment("Invalid Measure");
                Button invalidateMeasure = new Button(FindElement.ByName("NavInvalidateMeasure"));
                invalidateMeasure.Invoke();
                Wait.ForIdle();

                Log.Comment("Verify cached width is invalidated and InvalidateMeasure will move all items out of overflow");
                VerifyElement.NotFound("TopNavOverflowButton", FindBy.Id);
            }
        }
Пример #11
0
        // Disabled due to:
        // https://github.com/Microsoft/microsoft-ui-xaml/issues/115
        public void BasicMouseInteractionTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                CheckBox testFrameCheckbox = new CheckBox(FindElement.ByName("TestFrameCheckbox"));
                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                {
                    testFrameCheckbox.Uncheck();
                }

                var fileButton = FindElement.ById <Button>("FileItem");
                var editButton = FindElement.ById <Button>("EditItem");

                // click and click
                // From bug 17343407: this test is sometimes unreliable, use retries and see if that helps.
                InputHelper.LeftClick(fileButton);
                TestEnvironment.VerifyAreEqualWithRetry(20,
                                                        () => FindCore.ByName("NewItem", shouldWait: false) != null, // The item should be in the tree
                                                        () => true);

                InputHelper.LeftClick(fileButton);
                VerifyElement.NotFound("NewItem", FindBy.Id);

                // overlay pass through element is only available from IFlyoutBase3 forward
                if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Primitives.IFlyoutBase3"))
                {
                    // click and hover
                    InputHelper.LeftClick(fileButton);
                    VerifyElement.NotFound("Undo", FindBy.Name);
                    InputHelper.MoveMouse(editButton, 0, 0);
                    InputHelper.MoveMouse(editButton, 1, 1);
                    VerifyElement.Found("Undo", FindBy.Name);
                }

                if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                {
                    testFrameCheckbox.Check();
                }
            }
        }
Пример #12
0
        public void AccessibilityTest()
        {
            using (var setup = new TestSetupHelper("DropDownButton Tests"))
            {
                DropDownButton dropDownButton = FindElement.ByName <DropDownButton>("TestDropDownButton");

                TextBlock flyoutOpenedCountTextBlock = FindElement.ByName <TextBlock>("FlyoutOpenedCountTextBlock");
                TextBlock flyoutClosedCountTextBlock = FindElement.ByName <TextBlock>("FlyoutClosedCountTextBlock");

                Log.Comment("Verify that DropDownButton implements IExpandCollapseProvider");
                Verify.AreEqual("0", flyoutOpenedCountTextBlock.DocumentText);
                Log.Comment("IExpandCollapseProvider.Expand");
                dropDownButton.ExpandAndWait();
                Verify.AreEqual("1", flyoutOpenedCountTextBlock.DocumentText);
                VerifyElement.Found("TestFlyout", FindBy.Name);
                Verify.AreEqual(dropDownButton.ExpandCollapseState, ExpandCollapseState.Expanded);

                Verify.AreEqual("0", flyoutClosedCountTextBlock.DocumentText);
                Log.Comment("IExpandCollapseProvider.Collapse");
                dropDownButton.CollapseAndWait();
                Wait.ForIdle();
                Verify.AreEqual("1", flyoutClosedCountTextBlock.DocumentText);
                Verify.AreEqual(dropDownButton.ExpandCollapseState, ExpandCollapseState.Collapsed);

                Log.Comment("Change to a different flyout");
                CheckBox setFlyoutCheckBox = FindElement.ByName <CheckBox>("SetFlyoutCheckbox");
                setFlyoutCheckBox.Check();
                Wait.ForIdle();

                Verify.AreEqual("1", flyoutOpenedCountTextBlock.DocumentText);
                Log.Comment("IExpandCollapseProvider.Expand");
                dropDownButton.ExpandAndWait();
                Wait.ForIdle();
                Verify.AreEqual("2", flyoutOpenedCountTextBlock.DocumentText);
                Verify.AreEqual(dropDownButton.ExpandCollapseState, ExpandCollapseState.Expanded);

                Verify.AreEqual("1", flyoutClosedCountTextBlock.DocumentText);
                Log.Comment("IExpandCollapseProvider.Collapse");
                dropDownButton.CollapseAndWait();
                Wait.ForIdle();
                Verify.AreEqual("2", flyoutClosedCountTextBlock.DocumentText);
                Verify.AreEqual(dropDownButton.ExpandCollapseState, ExpandCollapseState.Collapsed);
            }
        }
Пример #13
0
        public void AddRemoveMenuFlyoutItemTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                var addButton    = FindElement.ById <Button>("AddFlyoutItemButton");
                var removeButton = FindElement.ById <Button>("RemoveFlyoutItemButton");
                var fileButton   = FindElement.ById <Button>("FileItem");

                Log.Comment("Verify that menu flyout items can be added");
                addButton.Invoke();
                Wait.ForIdle();

                // open flyout
                fileButton.Invoke();
                Wait.ForIdle();

                VerifyElement.Found("New Flyout Item", FindBy.Name);

                // close flyout
                fileButton.Invoke();
                Wait.ForIdle();

                Log.Comment("Verify that menu flyout items can be removed");
                removeButton.Invoke();
                Wait.ForIdle();

                // open flyout
                fileButton.Invoke();
                Wait.ForIdle();

                VerifyElement.NotFound("New Flyout Item", FindBy.Name);

                // close flyout
                fileButton.Invoke();
                Wait.ForIdle();
            }
        }
Пример #14
0
        public void EmptyMenuBarItemNoPopupTest()
        {
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                FindElement.ByName <Button>("NoChildrenFlyout").Click();
                VerifyElement.NotFound("Popup", FindBy.Name);

                FindElement.ByName <Button>("OneChildrenFlyout").Click();
                VerifyElement.Found("Popup", FindBy.Name);

                // Click twice to close flyout
                FindElement.ByName <Button>("RemoveItemsFromOneChildrenItem").Click();
                FindElement.ByName <Button>("RemoveItemsFromOneChildrenItem").Click();

                FindElement.ByName <Button>("OneChildrenFlyout").Click();
                VerifyElement.NotFound("Popup", FindBy.Name);
            }
        }
Пример #15
0
        public void AutomationPeerTest()
        {
            using (var setup = new TestSetupHelper("Expander Tests"))
            {
                Expander expander = FindElement.ByName <Expander>("ExpanderWithToggleSwitch");
                expander.SetFocus();
                Wait.ForIdle();

                // Verify ExpandedExpander header content AutomationProperties.Name properties are set
                VerifyElement.Found("This expander with ToggleSwitch is expanded by default.", FindBy.Name);
                VerifyElement.Found("This is the second line of text.", FindBy.Name);
                VerifyElement.Found("SettingsToggleSwitch", FindBy.Name);

                // Verify ExpandedExpander content AutomationProperties.Name property is set
                VerifyElement.Found("ExpanderWithToggleSwitch Content", FindBy.Name);

                Log.Comment("Collapse using keyboard space key.");
                KeyboardHelper.PressKey(Key.Space);
                Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed);

                // Verify ExpandedExpander content AutomationProperties.Name property is not visible once collapsed
                VerifyElement.NotFound("ExpanderWithToggleSwitch Content", FindBy.Name);
            }
        }
        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);
            }
        }