コード例 #1
0
        public void CloseSelectionTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject firstTab    = FindElement.ByName("FirstTab");
                Button   closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                TextBlock selectedIndexTextBlock = FindElement.ByName <TextBlock>("SelectedIndexTextBlock");
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "0");

                Log.Comment("When the selected tab is closed, selection should move to the next one.");
                // Use Tab's close button:
                closeButton.InvokeAndWait();
                VerifyElement.NotFound("FirstTab", FindBy.Name);
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "0");

                Log.Comment("Select last tab.");
                UIObject lastTab = FindElement.ByName("LastTab");
                lastTab.Click();
                Wait.ForIdle();
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "3");

                Log.Comment("When the selected tab is last and is closed, selection should move to the previous item.");

                // Use Middle Click to close the tab:
                lastTab.Click(PointerButtons.Middle);
                Wait.ForIdle();
                VerifyElement.NotFound("LastTab", FindBy.Name);
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "2");
            }
        }
コード例 #2
0
        [TestMethod] //bug 18033309
        public void TopNavigationSecondClickOnSuppressSelectionItemTest()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                Button   resetResultButton = new Button(FindElement.ById("ResetResult"));
                UIObject suppressSelection = FindElement.ByName("SuppressSelection");

                var invokeResult = new Edit(FindElement.ById("ItemInvokedResult"));
                var selectResult = new Edit(FindElement.ById("SelectionChangedResult"));
                using (var waiter = new ValueChangedEventWaiter(invokeResult))
                {
                    suppressSelection.Click();
                    waiter.Wait();
                }

                // First time selection only raise ItemInvoke
                Verify.AreEqual(invokeResult.Value, "SuppressSelection");
                Verify.AreEqual(selectResult.Value, "");

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

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

                // Click it again, only raise ItemInvoke event
                Verify.AreEqual(invokeResult.Value, "SuppressSelection");
                Verify.AreEqual(selectResult.Value, "");
            }
        }
コード例 #3
0
        public void Test_ADDCarrierModulator()
        {
            UICondition uIconAddCa = UICondition.Create("@Name='Add Carrier'", new Object[0]);
            UICondition uIconAddMo = UICondition.Create("@Name='Add Modulator'", new Object[0]);
            Random      rand       = new Random(System.Environment.TickCount);
            UIObject    uIOAddCa   = this.uImain.Children.Find(uIconAddCa);
            UIObject    uIOAddMo   = this.uImain.Children.Find(uIconAddMo);

            uIOAddCa.Click();
            for (int i = 0; i < 25; i++)
            {
                int a = rand.Next(2);
                switch (a)
                {
                case 0:
                    uIOAddCa.Click();
                    CarNum++;
                    break;

                case 1:
                    uIOAddMo.Click();
                    break;
                }
            }
        }
コード例 #4
0
        public void SettingsItemClickTest()
        {
            var testScenarios = RegressionTestScenario.BuildAllRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    if (testScenario.IsLeftNavTest)
                    {
                        Log.Comment("Bring Settings into view.");
                        FindElement.ByName <Button>("BringSettingsIntoViewButton").Invoke();
                        Wait.ForIdle();
                    }

                    UIObject settingsItem = FindElement.ByName("Settings");

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

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

                    Log.Comment("Verify settings is selected");
                    TextBlock header = new TextBlock(FindElement.ByName("Settings as header"));
                    Verify.AreEqual("Settings as header", header.DocumentText);
                }
            }
        }
コード例 #5
0
        // Clicks the clickTarget, waits for the edit's text to change its value,
        // and returns the value of the edit.
        void ClickWaitAndVerifyText(
            UIObject clickTarget,
            Edit edit,
            string expectedValue,
            [global::System.Runtime.CompilerServices.CallerMemberName] string testName = "")
        {
            if (clickTarget is null)
            {
                Verify.Fail($"{testName}: {nameof(clickTarget)} UIElement not found.");
                return;
            }

            if (edit is null)
            {
                Verify.Fail($"{testName}: {nameof(edit)} UIElement not found.");
                return;
            }

            // Clear out the text box so it starts in a known state.
            edit.SetValueAndWait(string.Empty);

            using (var waiter = new ValueChangedEventWaiter(edit))
            {
                clickTarget.Click();
                Log.Comment($"{testName}: Waiting for text to change.");
                waiter.Wait();
            }

            Log.Comment($"{testName}: Value of text: \"{edit.Value}\".");
            Verify.AreEqual(expectedValue, edit.Value);
        }
コード例 #6
0
        public static void Tap(UIObject obj)
        {
            // Allowing three attempts to work around occasional failure on Phone builds.
            int retries = 3;

            while (retries > 0)
            {
                try
                {
                    Log.Comment("Tap on {0}.", obj.GetIdentifier());
                    using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Tap))
                    {
                        if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
                        {
                            Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
                            obj.Click(PointerButtons.Primary);
                        }
                        else
                        {
                            obj.Tap();
                        }
                    }

                    retries = 0;
                }
                catch (Exception e)
                {
                    Log.Warning("Exception while tapping: " + e.Message);
                    retries--;
                }
            }

            Wait.ForIdle();
        }
コード例 #7
0
        public void VerifyMulticlickCrash()
        {
            using (var setup = new TestSetupHelper("BreadcrumbBar Tests"))
            {
                UIObject breadcrumb = RetrieveBreadcrumbControl();
                ClickOnElements(new string[] { "Node A", "Node A_1" });

                UIObject slider = RetrieveWidthSlider();
                slider.Click(PointerButtons.Primary, 1, slider.BoundingRectangle.Height / 2);

                InvokeEllipsisItem(breadcrumb);

                var ellipsisItemNodeA = VerifyDropDownItemContainsText("EllipsisItem2", "Root");
                ellipsisItemNodeA.Invoke();
                Thread.Sleep(500);

                for (int i = 0; i < 5; ++i)
                {
                    breadcrumb.Children[1].Click();

                    VerifyLastClickedItemIndexIs(0);
                    VerifyLastClickedItemIs("Root");
                }
            }
        }
コード例 #8
0
        public void SelectionTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Verify content is displayed for initially selected tab.");
                UIObject tabContent = FindElement.ByName("FirstTabContent");
                Verify.IsNotNull(tabContent);

                Log.Comment("Changing selection.");
                UIObject lastTab = FindElement.ByName("LastTab");
                lastTab.Click();
                Wait.ForIdle();

                Log.Comment("Verify content is displayed for newly selected tab.");
                tabContent = FindElement.ByName("LastTabContent");
                Verify.IsNotNull(tabContent);

                Log.Comment("Verify that setting SelectedItem changes selection.");
                Button selectItemButton = FindElement.ByName <Button>("SelectItemButton");
                selectItemButton.InvokeAndWait();

                TextBlock selectedIndexTextBlock = FindElement.ByName <TextBlock>("SelectedIndexTextBlock");
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "1");

                Log.Comment("Verify that setting SelectedIndex changes selection.");
                Button selectIndexButton = FindElement.ByName <Button>("SelectIndexButton");
                selectIndexButton.InvokeAndWait();
                Verify.AreEqual(selectedIndexTextBlock.DocumentText, "2");
            }
        }
コード例 #9
0
        public void VerifyCorrectNumberOfEventsRaised()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
            {
                TextBlock itemInvokedCountTextBlock      = new TextBlock(FindElement.ByName("NumberOfItemInvokedEventsRaisedTextBlock"));
                TextBlock selectionChangedCountTextBlock = new TextBlock(FindElement.ByName("NumberOfSelectionChangedEventsRaisedTextBlock"));

                Log.Comment("Verify that only one SelectionChanged event was raised.");
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "0");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "1");

                Log.Comment("Invoke MusicItem.");
                UIObject item1 = FindElement.ByName("Music");
                item1.Click();
                Wait.ForIdle();

                Log.Comment("Verify event counts.");
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "1");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "2");

                Log.Comment("Invoke selected item (MusicItem).");
                item1.Click();
                Wait.ForIdle();
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "2");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "2");

                Log.Comment("Clear event counters.");
                Button resetEventCounters = new Button(FindElement.ByName("ResetEventCounters"));
                resetEventCounters.Invoke();
                Wait.ForIdle();
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "0");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "0");

                Log.Comment("Verify that switching pane mode to top does not raise any events.");
                var flipOrientationButton = new Button(FindElement.ByName("FlipOrientationButton"));
                flipOrientationButton.Invoke();
                Wait.ForIdle();
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "0");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "0");

                Log.Comment("Verify that switching pane mode to auto does not raise any events.");
                flipOrientationButton.Invoke();
                Wait.ForIdle();
                Verify.AreEqual(itemInvokedCountTextBlock.GetText(), "0");
                Verify.AreEqual(selectionChangedCountTextBlock.GetText(), "0");
            }
        }
コード例 #10
0
        public void SelectionTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Verify content is displayed for initially selected tab.");
                UIObject tabContent = FindElement.ByName("FirstTabContent");
                Verify.IsNotNull(tabContent);

                Log.Comment("Changing selection.");
                UIObject lastTab = FindElement.ByName("LastTab");
                lastTab.Click();
                Wait.ForIdle();

                Log.Comment("Verify content is displayed for newly selected tab.");
                tabContent = FindElement.ByName("LastTabContent");
                Verify.IsNotNull(tabContent);

                Log.Comment("Verify that setting SelectedItem changes selection.");
                Button selectItemButton = FindElement.ByName <Button>("SelectItemButton");
                selectItemButton.InvokeAndWait();

                TextBlock selectedIndexTextBlock = FindElement.ByName <TextBlock>("SelectedIndexTextBlock");
                Verify.AreEqual("1", selectedIndexTextBlock.DocumentText);

                Log.Comment("Verify that setting SelectedIndex changes selection.");
                Button selectIndexButton = FindElement.ByName <Button>("SelectIndexButton");
                selectIndexButton.InvokeAndWait();
                Verify.AreEqual("2", selectedIndexTextBlock.DocumentText);

                Log.Comment("Verify that ctrl-click on tab selects it.");
                UIObject firstTab = FindElement.ByName("FirstTab");
                KeyboardHelper.PressDownModifierKey(ModifierKey.Control);
                firstTab.Click();
                KeyboardHelper.ReleaseModifierKey(ModifierKey.Control);
                Wait.ForIdle();
                Verify.AreEqual("0", selectedIndexTextBlock.DocumentText);

                Log.Comment("Verify that ctrl-click on tab does not deselect.");
                KeyboardHelper.PressDownModifierKey(ModifierKey.Control);
                firstTab.Click();
                KeyboardHelper.ReleaseModifierKey(ModifierKey.Control);
                Wait.ForIdle();
                Verify.AreEqual("0", selectedIndexTextBlock.DocumentText);
            }
        }
コード例 #11
0
 private void ClickOnElements(string[] elementNames)
 {
     foreach (var elementName in elementNames)
     {
         UIObject itemToAddButton = FindElement.ByName(elementName);
         Verify.IsNotNull(itemToAddButton, "Verifying that we found a button with " + elementName + " text");
         itemToAddButton.Click();
     }
 }
コード例 #12
0
 public static void LeftClick(UIObject obj)
 {
     Log.Comment("Left-click on {0}.", obj.GetIdentifier());
     using (var waiter = GetWaiterForInputEvent(obj, InputEvent.LeftClick))
     {
         obj.Click(PointerButtons.Primary);
     }
     Wait.ForIdle();
 }
コード例 #13
0
 public static void LeftClick(UIObject obj, double offsetX, double offsetY)
 {
     Log.Comment("Left-click on {0}, at ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY);
     using (var waiter = GetWaiterForInputEvent(obj, InputEvent.LeftClick))
     {
         obj.Click(PointerButtons.Primary, offsetX, offsetY);
     }
     Wait.ForIdle();
 }
コード例 #14
0
        public void TopNavigationSetSelectedItemToNullInItemInvoke()
        {
            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");

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

                Button expectNullSelectedItemInItemInvoke = new Button(FindElement.ById("ExpectNullSelectedItemInItemInvoke"));
                expectNullSelectedItemInItemInvoke.Click();
                Wait.ForIdle();

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

                // Click home, expect Null in select change event
                Verify.AreEqual(invokeResult.Value, "Home");
                Verify.AreEqual(selectResult.Value, "Null");

                // Only RS5 or above supports SlideNavigationTransitionInfo
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Verify.AreEqual(invokeRecommendedTransition.Value, "FromLeft");
                    Verify.AreEqual(selectionChangeRecommendedTransition.Value, "Default");
                }
            }
        }
コード例 #15
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());
            }
        }
コード例 #16
0
        private UIObject SetUpCrumbledTest()
        {
            var breadcrumb = SetUpTest();

            UIObject slider = RetrieveWidthSlider();

            slider.Click(PointerButtons.Primary, (slider.BoundingRectangle.Width / 3) - 10, slider.BoundingRectangle.Height / 2);

            return(breadcrumb);
        }
コード例 #17
0
        private void RevealStatesHelper(UIObject target)
        {
            var result = new Edit(FindElement.ById("TestResult"));

            Log.Comment("Move Mouse to (0,0). Validate target is initially in Normal state.");
            using (var waiter = new ValueChangedEventWaiter(result))
            {
                TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                Wait.ForIdle();
                ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidateNormalState");
                waiter.Wait();
            }
            LogResult(result, "Normal");

            Log.Comment("Move mouse over the target (which will attach RevealHoverLight). Validate PointerOver light state.");
            using (var waiter = new ValueChangedEventWaiter(result))
            {
                target.MovePointer(30, 30);
                Wait.ForIdle();
                ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidatePointerOverState");
                waiter.Wait();
            }
            LogResult(result, "PointerOver");

            Log.Comment("Click the Target. Verify Pressed light state.");
            using (var waiter = new ValueChangedEventWaiter(result))
            {
                target.MovePointer(30, 30);
                Wait.ForIdle();

                if (target is ListViewItem)
                {
                    ListView testListView = new ListView(FindElement.ById("TestListView"));
                    testListView.Click();
                }
                else
                {
                    target.Click();
                }
                waiter.Wait();
            }
            LogResult(result, "Pressed");

            Log.Comment("Move Mouse to (0, 0). Validate target button is again in Normal state.");
            using (var waiter = new ValueChangedEventWaiter(result))
            {
                TestEnvironment.Application.CoreWindow.MovePointer(0, 0);
                Wait.ForIdle();
                ChooseFromComboBox("ValidationActionsComboBox", "HoverLight_ValidateNormalState");
                waiter.Wait();
            }
            LogResult(result, "Normal");
        }
コード例 #18
0
        private UIObject SetUpCrumbledTest()
        {
            var breadcrumb = SetUpTest();

            UIObject slider = RetrieveWidthSlider();

            slider.Click(PointerButtons.Primary, (slider.BoundingRectangle.Width / 3) - 10, slider.BoundingRectangle.Height / 2);

            Verify.AreEqual(6, breadcrumb.Children.Count, "The breadcrumb should contain 6 items: 5 items and ellipsis");

            return(breadcrumb);
        }
コード例 #19
0
        public void VerifyOverflowButtonIsCollapsedWhenOverflowMenuIsEmpty()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Overflow Button Test" }))
            {
                VerifyOverflowButtonIsVisibleAndOverflowMenuHasSingleItem();

                Log.Comment("Verify that removing the final overflow menu item collapses the overflow button");
                FindElement.ByName <Button>("RemoveLastItemButton").InvokeAndWait();

                // Refresh the cache to make sure that the overflow button we are going to be searching for
                // does not return as a false positive due to the caching mechanism.
                ElementCache.Clear();

                VerifyOverflowButtonIsCollapsed();

                Log.Comment("Add menu item to show the overflow button again with the overflow menu item containing a single item");
                FindElement.ByName <Button>("AddItem4Button").InvokeAndWait();

                VerifyOverflowButtonIsVisibleAndOverflowMenuHasSingleItem();

                Log.Comment("Verify that removing a primary menu item which creates enough room for the single overflow menu item to be moved into collapses the overflow button");
                FindElement.ByName <Button>("RemoveFirstItemButton").InvokeAndWait();

                // Refresh the cache to make sure that the overflow button we are going to be searching for
                // does not return as a false positive due to the caching mechanism.
                ElementCache.Clear();

                VerifyOverflowButtonIsCollapsed();

                void VerifyOverflowButtonIsVisibleAndOverflowMenuHasSingleItem()
                {
                    UIObject overflowButton = FindElement.ById("TopNavOverflowButton");

                    Verify.IsNotNull(overflowButton, "The overflow button is required to be visible for this test");

                    Log.Comment("Verify that the overflow menu contains a single item");
                    overflowButton.Click();
                    Wait.ForIdle();

                    int numOverflowMenuItems = GetTopNavigationItems(TopNavPosition.Overflow).Count;

                    Verify.IsTrue(numOverflowMenuItems == 1, "The overflow menu should only contain a single item");
                }

                void VerifyOverflowButtonIsCollapsed()
                {
                    UIObject overflowButton = FindElement.ById("TopNavOverflowButton");

                    Verify.IsNull(overflowButton, "The overflow button should have been collapsed");
                }
            }
        }
コード例 #20
0
        public void VerifyPaneIsClosedWhenClickingOnSelectedItem()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Test" }))
            {
                var displayModeTextBox       = new TextBlock(FindElement.ByName("DisplayModeTextBox"));
                var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));

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

                WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

                Log.Comment("Click on ToggleButton");
                Button navButton = new Button(FindElement.ById("TogglePaneButton"));
                navButton.Invoke();
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Opened);

                Log.Comment("Select Apps");
                UIObject appsItem = FindElement.ByName("Apps");
                appsItem.Click();
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Closed);

                Log.Comment("Click on ToggleButton");
                navButton.Invoke();
                Wait.ForIdle();

                Log.Comment("Click on SelectedItem Apps");
                appsItem.Click();
                Wait.ForIdle();

                WaitAndAssertPaneStatus(PaneOpenStatus.Closed);
            }
        }
コード例 #21
0
        public void SelectionFollowFocusTest()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled on RS1 and earlier because SingleSelectionFollowFocus on RS2.");
                return;
            }
            var testScenarios = RegressionTestScenario.BuildTopNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    Log.Comment("Check SelectionFollowFocus");
                    CheckBox selectionFollowFocusCheckbox = new CheckBox(FindElement.ById("SelectionFollowFocusCheckbox"));
                    selectionFollowFocusCheckbox.Check();
                    Wait.ForIdle();

                    UIObject firstItem  = FindElement.ByName("Apps");
                    UIObject secondItem = FindElement.ByName("Games");

                    Log.Comment("Verify the second item is not already selected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    firstItem.Click();
                    Wait.ForIdle();

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

                    Log.Comment("Move focus to the second item by pressing down(left nav)/right(right nav) arrow once");
                    var key = Key.Right;
                    if (testScenario.IsLeftNavTest)
                    {
                        key = Key.Down;
                    }
                    KeyboardHelper.PressKey(key);
                    Wait.ForIdle();

                    Log.Comment("Verify second item is selected and has focus because of SelectionFollowFocus");
                    Verify.IsTrue(secondItem.HasKeyboardFocus);
                    Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    ClickClearSelectionButton();
                    Log.Comment("second item is unselected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                }
            }
        }
コード例 #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="offsetX">value from top left</param>
        /// <param name="offsetY">value from top left</param>
        public static void Tap(UIObject obj, double offsetX, double offsetY)
        {
            // Allowing three attempts to work around occasional failure on Phone builds.
            int retries = 3;

            while (retries > 0)
            {
                try
                {
                    Log.Comment("Tap on {0} at ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY);
                    Log.Comment("Bounding rectangle is: " + obj.BoundingRectangle.ToString());

                    if (offsetX > obj.BoundingRectangle.Width)
                    {
                        Log.Warning("Warning, the tap offsetX is higher than the bounding rectangle width");
                    }

                    if (offsetY > obj.BoundingRectangle.Height)
                    {
                        Log.Warning("Warning, the tap offsetY is higher than the bounding rectangle height");
                    }

                    using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Tap))
                    {
                        if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
                        {
                            Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
                            obj.Click(PointerButtons.Primary, offsetX, offsetY);
                        }
                        else
                        {
                            obj.Tap(offsetX, offsetY);
                        }
                    }

                    retries = 0;
                }
                catch (Exception e)
                {
                    Log.Warning("Exception while tapping: " + e.Message);
                    retries--;
                }
            }

            Wait.ForIdle();
        }
コード例 #23
0
        public static void RightClick(UIObject obj, int offsetX = 0, int offsetY = 0)
        {
            if (offsetX == 0 && offsetY == 0)
            {
                Log.Comment("Right-click on {0}.", obj.GetIdentifier());
            }
            else
            {
                Log.Comment("Right-click on {0} at offset ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY);
            }

            using (var waiter = GetWaiterForInputEvent(obj, InputEvent.RightClick))
            {
                obj.Click(PointerButtons.Secondary, offsetX, offsetY);
            }

            Wait.ForIdle();
        }
コード例 #24
0
        public void VerifyFlyoutRecycleCrash()
        {
            using (var setup = new TestSetupHelper("BreadcrumbBar Tests"))
            {
                UIObject breadcrumb = SetUpCrumbledTest();

                UIObject slider = RetrieveWidthSlider();
                slider.Click(PointerButtons.Primary, 1, slider.BoundingRectangle.Height / 2);

                InvokeEllipsisItem(breadcrumb);

                var ellipsisItemNodeA_2_3 = VerifyDropDownItemContainsText("EllipsisItem1", "Node A_2_3");
                ellipsisItemNodeA_2_3.Invoke();
                Thread.Sleep(500);

                InvokeEllipsisItem(breadcrumb);
            }
        }
コード例 #25
0
        // TODO: This test doesn't pass because it can't find the tab content -- this is an acc bug.
        //[TestMethod]
        public void SelectionTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Verify content is displayed for initially selected tab.");
                UIObject tabContent = FindElement.ByName("FirstTabContent");
                Verify.IsNotNull(tabContent);

                Log.Comment("Changing selection.");
                UIObject lastTab = FindElement.ByName("LastTab");
                lastTab.Click();
                Wait.ForIdle();

                Log.Comment("Verify content is displayed for newly selected tab.");
                tabContent = FindElement.ByName("LastTabContent");
                Verify.IsNotNull(tabContent);
            }
        }
コード例 #26
0
        public void VerifyDeselectionDisabled()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    UIObject homeItem = FindElement.ByName("Home");
                    Verify.IsNotNull(homeItem);
                    Verify.IsTrue(Convert.ToBoolean(homeItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    KeyboardHelper.PressDownModifierKey(ModifierKey.Control);
                    homeItem.Click(); // Explicitly testing ctrl+click here
                    Wait.ForIdle();
                    Verify.IsTrue(Convert.ToBoolean(homeItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                    KeyboardHelper.ReleaseModifierKey(ModifierKey.Control);
                }
            }
        }
コード例 #27
0
        public void TopNavigationOverflowButtonClickTest()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                Log.Comment("Setting focus to Home");
                UIObject home = FindElement.ByName("Home");
                home.SetFocus();
                Wait.ForIdle();

                Log.Comment("Add ten items to make overflow happen");
                Button addTenItems = new Button(FindElement.ByName("AddTenItems"));
                addTenItems.Invoke();
                Wait.ForIdle();

                InvokeOverflowButton();

                UIObject overflowItem = FindElement.ByName("Added Item 5");
                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))
                {
                    overflowItem.Click();
                    waiter.Wait();
                }

                // First time selection raise ItemInvoke and SelectionChange events
                Verify.AreEqual(invokeResult.Value, "Added Item 5");
                Verify.AreEqual(selectResult.Value, "Added Item 5");

                // only RS5 or above supports SlideNavigationTransitionInfo
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Verify.AreEqual(invokeRecommendedTransition.Value, "FromRight");
                    Verify.AreEqual(selectionChangeRecommendedTransition.Value, "FromRight");
                }
            }
        }
コード例 #28
0
        private void SetupScrollViewerTestWithImage(string suffix, out UIObject imageInScrollViewer, out Scroller scroller)
        {
            Log.Comment("Retrieving cmbShowScrollViewer");
            ComboBox cmbShowScrollViewer = new ComboBox(FindElement.ByName("cmbShowScrollViewer"));

            Verify.IsNotNull(cmbShowScrollViewer, "Verifying that cmbShowScrollViewer was found");

            Log.Comment("Changing ScrollViewer selection to scrollViewer" + suffix);
            cmbShowScrollViewer.SelectItemByName("scrollViewer_" + suffix);
            Log.Comment("Selection is now {0}", cmbShowScrollViewer.Selection[0].Name);

            Log.Comment("Retrieving img" + suffix);
            imageInScrollViewer = FindElement.ById("img" + suffix);
            Verify.IsNotNull(imageInScrollViewer, "Verifying that img" + suffix + " was found");

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

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

            imageInScrollViewer.Click();
            Wait.ForIdle();
        }
コード例 #29
0
        private void SetupSimpleSingleScrollViewerTest(out UIObject buttonInScrollViewer11, out Scroller scroller11)
        {
            Log.Comment("Retrieving cmbShowScrollViewer");
            ComboBox cmbShowScrollViewer = new ComboBox(FindElement.ByName("cmbShowScrollViewer"));

            Verify.IsNotNull(cmbShowScrollViewer, "Verifying that cmbShowScrollViewer was found");

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

            Log.Comment("Retrieving buttonInScrollViewer11");
            buttonInScrollViewer11 = FindElement.ById("buttonInScrollViewer11");
            Verify.IsNotNull(buttonInScrollViewer11, "Verifying that buttonInScrollViewer11 was found");

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

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

            buttonInScrollViewer11.Click();
            Wait.ForIdle();
        }
コード例 #30
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");
                }
            }
        }