public void CanGetBehaviors()
        {
            var cache = new ElementCache(new ISpecificationElement[]
            {
                ElementFixtures.Specification1,
                ElementFixtures.Behavior1Specification1,
                ElementFixtures.Behavior1Specification2,
                ElementFixtures.Behavior2Specification1,
            });

            var behaviors = cache.GetBehaviors(ElementFixtures.Context).ToArray();

            Assert.That(behaviors, Has.Length.EqualTo(2));
            Assert.That(behaviors, Contains.Item(ElementFixtures.Behavior1));
            Assert.That(behaviors, Contains.Item(ElementFixtures.Behavior2));
        }
Ejemplo n.º 2
0
        public void IsCloseableTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject firstTab    = FindElement.ByName("FirstTab");
                Button   closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                Log.Comment("Setting IsCloseable=false on the first tab.");
                CheckBox isCloseableCheckBox = FindElement.ByName <CheckBox>("IsCloseableCheckBox");
                isCloseableCheckBox.Uncheck();
                Wait.ForIdle();

                ElementCache.Refresh();
                closeButton = FindCloseButton(firstTab);
                Verify.IsNull(closeButton);

                Log.Comment("Setting IsCloseable=true on the first tab.");
                isCloseableCheckBox.Check();
                Wait.ForIdle();

                ElementCache.Refresh();
                closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                Log.Comment("Setting CanCloseTabs=false on the TabView.");
                CheckBox canCloseCheckBox = FindElement.ByName <CheckBox>("CanCloseCheckBox");
                canCloseCheckBox.Uncheck();
                Wait.ForIdle();

                ElementCache.Refresh();

                Log.Comment("First close button should be visible because IsCloseable was set to true");
                closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                UIObject tab = FindElement.ByName("SecondTab");
                Log.Comment("Second close button should be visible because IsCloseable was set to true in xaml");
                closeButton = FindCloseButton(tab);
                Verify.IsNotNull(closeButton);

                tab = FindElement.ByName("LongHeaderTab");
                Log.Comment("Third close button should not be visible because IsCloseable is still unset");
                closeButton = FindCloseButton(tab);
                Verify.IsNull(closeButton);
            }
        }
Ejemplo n.º 3
0
        public void CanSelectItemInFlyoutAndNVIGetsCollapsedOnFlyoutClose()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "HierarchicalNavigationView Markup Test" }))
            {
                Log.Comment("Put NavigationView into Left Compact Mode.");
                var panelDisplayModeComboBox = new ComboBox(FindElement.ByName("PaneDisplayModeCombobox"));
                panelDisplayModeComboBox.SelectItemByName("LeftCompact");
                Wait.ForIdle();

                TextBlock displayModeTextBox = new TextBlock(FindElement.ByName("SelectedItemLabel"));
                Verify.AreEqual(displayModeTextBox.DocumentText, "uninitialized");

                Log.Comment("Select Menu Item 11 which should open flyout.");
                var item = FindElement.ByName("Menu Item 11");
                InputHelper.LeftClick(item);
                Wait.ForIdle();

                Log.Comment("Select Menu Item 12 which should keep flyout open.");
                item = FindElement.ByName("Menu Item 12");
                InputHelper.LeftClick(item);
                Wait.ForIdle();

                Verify.IsNotNull(FindElement.ById("ChildrenFlyout"), "Flyout should still be open.");

                Log.Comment("Select Menu Item 14.");
                item = FindElement.ByName("Menu Item 14");
                InputHelper.LeftClick(item);
                Wait.ForIdle();

                // Refresh the cache to make sure that the flyout object we are going to be searching for
                // does not return as a false positive due to the caching mechanism.
                ElementCache.Refresh();
                Verify.IsNull(FindElement.ById("ChildrenFlyout"), "Flyout should be closed.");

                Log.Comment("Verify that the correct item has been selected");
                var getSelectItemButton = new Button(FindElement.ByName("GetSelectedItemLabelButton"));
                getSelectItemButton.Invoke();
                Wait.ForIdle();
                Verify.AreEqual(displayModeTextBox.DocumentText, "Menu Item 14");

                Log.Comment("Verify that parent has been collapsed");
                TextBlock textBlockCollapsedItem = new TextBlock(FindElement.ByName("TextBlockCollapsedItem"));
                Verify.AreEqual(textBlockCollapsedItem.DocumentText, "Menu Item 11");
            }
        }
Ejemplo n.º 4
0
        public void VerifyNumberBoxHeaderBehavior()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                var headerBeforeApplyTemplate = FindElement.ByName <TextBlock>("HeaderBeforeApplyTemplateTest");
                Verify.IsNotNull(headerBeforeApplyTemplate);

                var headerTemplateBeforeApplyTemplate = FindElement.ByName <TextBlock>("HeaderTemplateBeforeApplayTemplateTest");
                Verify.IsNotNull(headerBeforeApplyTemplate);

                var toggleHeaderButton = FindElement.ByName <Button>("ToggleHeaderValueButton");
                var header             = FindElement.ByName <TextBlock>("NumberBoxHeaderClippingDemoHeader");

                Log.Comment("Check header is null");
                Verify.IsNull(header);

                Log.Comment("Set header");
                toggleHeaderButton.Invoke();
                Wait.ForIdle();

                header = FindElement.ByName <TextBlock>("NumberBoxHeaderClippingDemoHeader");
                Log.Comment("Check if header is present");
                Verify.IsNotNull(header);
                Log.Comment("Remove header");
                toggleHeaderButton.Invoke();
                Wait.ForIdle();
                ElementCache.Clear();

                Log.Comment("Check that header is null again");
                header = FindElement.ByName <TextBlock>("NumberBoxHeaderClippingDemoHeader");
                Verify.IsNull(header);


                var toggleHeaderTemplateButton = FindElement.ByName <Button>("ToggleHeaderTemplateValueButton");
                var headerTemplate             = FindElement.ByName <TextBlock>("HeaderTemplateTestingBlock");

                Verify.IsNull(headerTemplate);

                toggleHeaderTemplateButton.Invoke();
                Wait.ForIdle();

                headerTemplate = FindElement.ByName <TextBlock>("HeaderTemplateTestingBlock");
                Verify.IsNotNull(headerTemplate);
            }
        }
Ejemplo n.º 5
0
        public void AddButtonTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Add new tab button should be visible.");
                var addButton = FindElement.ByName("Add New Tab");
                Verify.IsNotNull(addButton);

                CheckBox isAddButtonVisibleCheckBox = FindElement.ByName <CheckBox>("IsAddButtonVisibleCheckBox");
                isAddButtonVisibleCheckBox.Uncheck();
                Wait.ForIdle();

                ElementCache.Refresh();
                Log.Comment("Add new tab button should not be visible.");
                addButton = TryFindElement.ByName("Add New Tab");
                Verify.IsNull(addButton);
            }
        }
Ejemplo n.º 6
0
        public void AccessibilityViewTest()
        {
            using (var setup = new TestSetupHelper("InfoBar Tests"))
            {
                StatusBar infoBar = FindElement.ByName <StatusBar>("TestInfoBar");
                Verify.IsNotNull(infoBar, "TestInfoBar should be visible by default");

                Log.Comment("Close InfoBar and make sure it can't be found.");
                Uncheck("IsOpenCheckBox");
                ElementCache.Clear();

                infoBar = FindElement.ByName <StatusBar>("TestInfoBar");
                Verify.IsNull(infoBar, "TestInfoBar should not be in the accessible tree");

                infoBar = FindElement.ByName <StatusBar>("DefaultInfoBar");
                Verify.IsNull(infoBar, "By default, Infobar should not be visible");
            }
        }
Ejemplo n.º 7
0
        public void CanNotifyAssembly()
        {
            const string path = "path/to/assembly.dll";

            var sink    = Substitute.For <IExecutionListener>();
            var cache   = new ElementCache(Array.Empty <ISpecificationElement>());
            var tracker = new RunTracker(Array.Empty <ISpecificationElement>());

            var listener = new ExecutionAdapterRunListener(sink, cache, tracker);

            var assembly = new TestAssemblyInfo(path);

            listener.OnAssemblyStart(assembly);
            listener.OnAssemblyEnd(assembly);

            sink.Received().OnAssemblyStart(path);
            sink.Received().OnAssemblyEnd(path);
        }
Ejemplo n.º 8
0
        public void ReorderItemsTest()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                // TODO 19727004: Re-enable this on versions below RS5 after fixing the bug where mouse click-and-drag doesn't work.
                Log.Warning("This test relies on touch input, the injection of which is only supported in RS5 and up. Test is disabled.");
                return;
            }

            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Button tabItemsSourcePageButton = FindElement.ByName <Button>("TabViewTabItemsSourcePageButton");
                tabItemsSourcePageButton.InvokeAndWait();

                UIObject sourceTab = null;
                int      attempts  = 0;

                do
                {
                    Wait.ForMilliseconds(100);
                    ElementCache.Refresh();

                    sourceTab = FindElement.ByName("tabViewItem0");
                    attempts++;
                }while (sourceTab == null && attempts < 4);

                Verify.IsNotNull(sourceTab);

                UIObject dropTab = FindElement.ByName("tabViewItem2");
                Verify.IsNotNull(dropTab);

                Log.Comment("Reordering tabs with drag-drop operation...");
                InputHelper.DragToTarget(sourceTab, dropTab, -5);
                Wait.ForIdle();
                ElementCache.Refresh();
                Log.Comment("...reordering done. Expecting a TabView.TabItemsChanged event was raised with CollectionChange=ItemInserted and Index=1.");

                TextBlock tblIVectorChangedEventArgsCollectionChange = FindElement.ByName <TextBlock>("tblIVectorChangedEventArgsCollectionChange");
                Verify.AreEqual("ItemInserted", tblIVectorChangedEventArgsCollectionChange.DocumentText);

                TextBlock tblIVectorChangedEventArgsIndex = FindElement.ByName <TextBlock>("tblIVectorChangedEventArgsIndex");
                Verify.AreEqual("1", tblIVectorChangedEventArgsIndex.DocumentText);
            }
        }
Ejemplo n.º 9
0
        public void CancelTabClosingTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject firstTab    = FindElement.ByName("FirstTab");
                Button   closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                CheckBox cancelCloseCheckBox = FindElement.ByName <CheckBox>("CancelCloseCheckBox");
                cancelCloseCheckBox.Check();
                Wait.ForIdle();

                Log.Comment("Clicking close button should not close tab if app returns cancel = true.");
                closeButton.InvokeAndWait();

                ElementCache.Refresh();
                firstTab = TryFindElement.ByName("FirstTab");
                Verify.IsNotNull(firstTab);

                cancelCloseCheckBox.Uncheck();

                CheckBox cancelItemCloseCheckBox = FindElement.ByName <CheckBox>("CancelItemCloseCheckBox");
                cancelCloseCheckBox.Check();
                Wait.ForIdle();

                Log.Comment("Clicking close button should not close tab if the tab item returns cancel = true.");
                closeButton.InvokeAndWait();

                ElementCache.Refresh();
                firstTab = TryFindElement.ByName("FirstTab");
                Verify.IsNotNull(firstTab);

                cancelCloseCheckBox.Uncheck();
                Wait.ForIdle();

                Log.Comment("Clicking close button should close tab if app doesn't handle either TabClosing event.");
                closeButton.InvokeAndWait();

                ElementCache.Refresh();
                firstTab = TryFindElement.ByName("FirstTab");
                Verify.IsNull(firstTab);
            }
        }
Ejemplo n.º 10
0
        public void CanStartAndEndContext()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context
            });
            var cache = new ElementCache(Array.Empty <ISpecificationElement>());

            var sink    = Substitute.For <ITestExecutionSink>();
            var context = new RunContext(depot, sink);

            var listener = new TestExecutionListener(context, cache, CancellationToken.None);

            listener.OnContextStart(ElementFixtures.Context);
            listener.OnContextEnd(ElementFixtures.Context, string.Empty);

            sink.Received(1).TestStarting(RemoteTaskFixtures.Context);
            sink.Received(1).TestFinished(RemoteTaskFixtures.Context, Arg.Any <string>(), TestResult.Success);
        }
Ejemplo n.º 11
0
        public void HoveringBehaviorTest()
        {
            // Overlay pass through element is only available from IFlyoutBase3 forward
            // On OS versions below RS5 test is unreliable/not working.
            // Tracked by https://github.com/Microsoft/microsoft-ui-xaml/issues/115
            if (PlatformConfiguration.IsDevice(DeviceType.Phone) ||
                !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Primitives.IFlyoutBase3") ||
                PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone4))
            {
                Log.Comment("Skipping tests on phone, because menubar is not supported.");
                return;
            }
            using (var setup = new TestSetupHelper("MenuBar Tests"))
            {
                var menuBar   = FindElement.ById("SizedMenuBar");
                var addButton = FindElement.ByName("AddItemsToEmptyMenuBar");

                addButton.Click();
                addButton.Click();
                addButton.Click();

                var help0 = FindElement.ByName <Button>("Help0");
                var help1 = FindElement.ByName <Button>("Help1");

                // This behavior seems to a bit unreliable, so repeat
                InputHelper.LeftClick(help0);
                TestEnvironment.VerifyAreEqualWithRetry(20,
                                                        () => FindCore.ByName("Add0", shouldWait: false) != null, // The item should be in the tree
                                                        () => true);

                // Check if hovering over the next button actually will show the correct item
                VerifyElement.NotFound("Add1", FindBy.Name);
                InputHelper.MoveMouse(help1, 0, 0);
                InputHelper.MoveMouse(help1, 1, 1);
                InputHelper.MoveMouse(help1, 5, 5);

                UIObject add1Element = null;
                ElementCache.Clear();
                var element = GetElement(ref add1Element, "Add1");
                Verify.IsNotNull(add1Element);
            }
        }
        public void CanGetSpecificationsByBehavior()
        {
            var cache = new ElementCache(new ISpecificationElement[]
            {
                ElementFixtures.Specification1,
                ElementFixtures.Behavior1Specification1,
                ElementFixtures.Behavior1Specification2,
                ElementFixtures.Behavior2Specification1
            });

            var specifications1 = cache.GetSpecifications(ElementFixtures.Behavior1).ToArray();
            var specifications2 = cache.GetSpecifications(ElementFixtures.Behavior2).ToArray();

            Assert.That(specifications1, Has.Length.EqualTo(2));
            Assert.That(specifications1, Contains.Item(ElementFixtures.Behavior1Specification1));
            Assert.That(specifications1, Contains.Item(ElementFixtures.Behavior1Specification2));

            Assert.That(specifications2, Has.Length.EqualTo(1));
            Assert.That(specifications2, Contains.Item(ElementFixtures.Behavior2Specification1));
        }
Ejemplo n.º 13
0
        public void IsClosableTest()
        {
            using (var setup = new TestSetupHelper("InfoBar Tests"))
            {
                StatusBar infoBar = FindElement.ByName <StatusBar>("TestInfoBar");

                Button closeButton = FindCloseButton(infoBar);
                Verify.IsNotNull(closeButton, "Close button should be visible by default");

                Uncheck("IsClosableCheckBox");
                ElementCache.Clear();
                closeButton = FindCloseButton(infoBar);
                Verify.IsNull(closeButton, "Close button should not be visible when IsClosable=false");

                Check("IsClosableCheckBox");
                ElementCache.Clear();
                closeButton = FindCloseButton(infoBar);
                Verify.IsNotNull(closeButton, "Close button should be visible when IsClosable=true");
            }
        }
Ejemplo n.º 14
0
        public void AddRemoveTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                Log.Comment("Adding tab.");
                Button addTabButton = FindElement.ByName <Button>("Add New Tab");
                addTabButton.InvokeAndWait();

                ElementCache.Refresh();
                UIObject newTab = FindElement.ByName("New Tab 1");
                Verify.IsNotNull(newTab);

                Log.Comment("Removing tab.");
                Button removeTabButton = FindElement.ByName <Button>("RemoveTabButton");
                removeTabButton.InvokeAndWait();

                ElementCache.Refresh();
                newTab = FindElement.ByName("New Tab 1");
                Verify.IsNull(newTab);
            }
        }
Ejemplo n.º 15
0
        public void HandleItemCloseRequestedTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject firstTab    = FindElement.ByName("FirstTab");
                Button   closeButton = FindCloseButton(firstTab);
                Verify.IsNotNull(closeButton);

                CheckBox tabCloseRequestedCheckBox = FindElement.ByName <CheckBox>("HandleTabCloseRequestedCheckBox");
                tabCloseRequestedCheckBox.Uncheck();
                CheckBox tabItemCloseRequestedCheckBox = FindElement.ByName <CheckBox>("HandleTabItemCloseRequestedCheckBox");
                tabItemCloseRequestedCheckBox.Check();
                Wait.ForIdle();

                Log.Comment("TabViewItem.CloseRequested should be raised when the close button is pressed.");
                closeButton.InvokeAndWait();

                ElementCache.Refresh();
                firstTab = TryFindElement.ByName("FirstTab");
                Verify.IsNull(firstTab);
            }
        }
Ejemplo n.º 16
0
        public AssemblyExplorer(MSpecUnitTestProvider provider,
                                IUnitTestElementManager manager,
                                PsiModuleManager psiModuleManager,
                                CacheManager cacheManager,
                                IMetadataAssembly assembly,
                                IProject project,
                                UnitTestElementConsumer consumer)
        {
            _assembly = assembly;
            _consumer = consumer;

            using (ReadLockCookie.Create())
            {
                var projectEnvoy = new ProjectModelElementEnvoy(project);

                var cache = new ElementCache();
                _contextFactory = new ContextFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, _assembly.Location.FullPath, cache);
                _contextSpecificationFactory  = new ContextSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache);
                _behaviorFactory              = new BehaviorFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache);
                _behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy);
            }
        }
Ejemplo n.º 17
0
        public void CanStartAndEndContext()
        {
            var sink     = Substitute.For <IExecutionListener>();
            var elements = new ISpecificationElement[]
            {
                ElementFixtures.Specification1,
                ElementFixtures.Behavior1Specification1,
                ElementFixtures.Behavior1Specification2
            };

            var cache   = new ElementCache(elements);
            var tracker = new RunTracker(elements);

            var listener = new ExecutionAdapterRunListener(sink, cache, tracker);

            var context = new TestContextInfo(ElementFixtures.Context.TypeName, string.Empty);

            listener.OnContextStart(context);
            listener.OnContextEnd(context);

            sink.Received().OnContextStart(ElementFixtures.Context);
            sink.Received().OnContextEnd(ElementFixtures.Context, Arg.Any <string>());
        }
Ejemplo n.º 18
0
        public void LayoutTest()
        {
            using (var setup = new TestSetupHelper("InfoBar Tests"))
            {
                ComboBox actionComboBox = FindElement.ByName <ComboBox>("ActionButtonComboBox");
                actionComboBox.SelectItemByName("Button");
                Check("HasCustomContentCheckBox");
                ElementCache.Clear();

                StatusBar infoBar       = FindElement.ByName <StatusBar>("TestInfoBar");
                CheckBox  customContent = FindElement.ByName <CheckBox>("CustomContentCheckBox");

                // 0: icon; 1: title; 2: message; 3: action button
                Log.Comment("Verify that title, message, and action button layout is left-to-right");
                Verify.IsGreaterThan(infoBar.Children[2].BoundingRectangle.X, infoBar.Children[1].BoundingRectangle.X, "Expect Message to be on the right of Title");
                Verify.IsGreaterThan(infoBar.Children[3].BoundingRectangle.X, infoBar.Children[2].BoundingRectangle.X, "Expect action button to be on the right of Message");
                VerifyIsPrettyClose(infoBar.Children[2].BoundingRectangle.Y, infoBar.Children[1].BoundingRectangle.Y, "Expect Message to be top-aligned with Title");

                Verify.IsGreaterThan(customContent.BoundingRectangle.Y, infoBar.Children[1].BoundingRectangle.Y, "Expect custom content to be on under all other things");
                VerifyIsPrettyClose(customContent.BoundingRectangle.X, infoBar.Children[1].BoundingRectangle.X, "Expect custom content to be left-aligned with title");

                Log.Comment("Change title and message to long strings");
                Edit editTitle   = FindElement.ByName <Edit>("TitleTextBox");
                Edit editMessage = FindElement.ByName <Edit>("MessageTextBox");
                editTitle.SetValueAndWait("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vel orci eros. Sed ut lectus ultrices quam hendrerit sagittis. Cras gravida eleifend eros, eu pulvinar lectus molestie dictum. Vivamus et tellus euismod, dapibus odio vel, volutpat risus.");
                editMessage.SetValueAndWait("Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent vehicula mauris eu libero pretium ullamcorper.");

                Log.Comment("Verify that title, message, and action button layout is top-to-bottom");
                Verify.IsGreaterThan(infoBar.Children[2].BoundingRectangle.Y, infoBar.Children[1].BoundingRectangle.Y, "Expect Message to be below Title");
                Verify.IsGreaterThan(infoBar.Children[3].BoundingRectangle.Y, infoBar.Children[2].BoundingRectangle.Y, "Expect action button to be below Message");
                VerifyIsPrettyClose(infoBar.Children[2].BoundingRectangle.X, infoBar.Children[1].BoundingRectangle.X, "Expect Message to be left-aligned with Title");
                VerifyIsPrettyClose(infoBar.Children[3].BoundingRectangle.X, infoBar.Children[2].BoundingRectangle.X, "Expect action button to be left-aligned Message");

                Verify.IsGreaterThan(customContent.BoundingRectangle.Y, infoBar.Children[3].BoundingRectangle.Y, "Expect custom content to be on under all other things");
                VerifyIsPrettyClose(customContent.BoundingRectangle.X, infoBar.Children[1].BoundingRectangle.X, "Expect custom content to be left-aligned with everyone else");
            }
        }
Ejemplo n.º 19
0
        // this function returns true for successful run and false for unsuccessful run
        // in case of false, the calling function will retry calling this function
        private bool TestSingleRun(ICollection <string> testNames, bool shouldRestrictInnerFrameSize)
        {
            PreTestSetup();

            // We were hitting an issue in the lab where sometimes the very first click would fail to go through resulting in
            // test instability. We work around this by clicking on element when the app launches.
            if (!string.IsNullOrEmpty(Options.AutomationIdOfSafeItemToClick))
            {
                var safeItemToClick = FindElement.ById(Options.AutomationIdOfSafeItemToClick);
                if (safeItemToClick == null)
                {
                    string errorMessage = $"Cannot find object with automation id '{Options.AutomationIdOfSafeItemToClick}'";
                    Log.Warning(errorMessage);
                    DumpHelper.DumpFullContext();
                    return(false);  //retry needed
                }
                InputHelper.LeftClick(safeItemToClick);
            }


            foreach (string testName in testNames)
            {
                Log.Comment(testName + " initializing TestSetupHelper");

                UIObject uiObject;
                if (!String.IsNullOrEmpty(Options.ClassNameOfNavigationItemToInvoke))
                {
                    uiObject = FindElement.ByNameAndClassName(testName, Options.ClassNameOfNavigationItemToInvoke);
                }
                else
                {
                    uiObject = FindElement.ByName(testName);
                }

                if (uiObject == null)
                {
                    string errorMessage = string.Format("Cannot find test page for: {0}.", testName);

                    // We'll raise the error message first so the dump has proper context preceding it,
                    // and will then throw it as an exception so we immediately cease execution.
                    Log.Warning(errorMessage);
                    DumpHelper.DumpFullContext();
                    return(false);   //retry needed
                }

                // We're now entering a new test page, so everything has changed.  As such, we should clear our
                // element cache in order to ensure that we don't accidentally retrieve any stale UI objects.
                ElementCache.Clear();

                Log.Comment("Waiting until __TestContentLoadedCheckBox to be checked by test app.");
                CheckBox cb = new CheckBox(FindElement.ById("__TestContentLoadedCheckBox"));

                using (var waiter = cb.GetToggledWaiter())
                {
                    var testButton = new Button(uiObject);
                    testButton.Invoke();

                    if (cb.ToggleState != ToggleState.On)
                    {
                        waiter.Wait();
                    }
                }

                Wait.ForIdle();

                Log.Comment("__TestContentLoadedCheckBox checkbox checked, page has loaded");

                SetInnerFrameInLabDimensions(shouldRestrictInnerFrameSize);

                OpenedTestPages++;
            }

            TestCleanupHelper.TestSetupHelperPendingDisposals++;

            return(true);  //no retry needed, it is a success
        }
Ejemplo n.º 20
0
        private void PreTestSetup()
        {
            bool restartedTestApp = false;

            if (TestEnvironment.ShouldRestartApplication)
            {
                ElementCache.Clear();
                Wait.ResetIdleHelper();

                TestEnvironment.ShouldRestartApplication = false;

                Log.Comment("Restarting application to ensure test stability...");
                TestEnvironment.Application.Close();

                restartedTestApp = true;
            }

            if (restartedTestApp ||
                (TestEnvironment.Application.Process != null && TestEnvironment.Application.Process.HasExited))
            {
                if (!restartedTestApp)
                {
                    // If the test application process exited because something crashed,
                    // we'll restart it in order to make sure that other tests aren't affected.
                    Log.Comment("Application exited unexpectedly. Reinitializing...");
                }

                ElementCache.Clear();
                Wait.ResetIdleHelper();

#if USING_TAEF
                string deploymentDir = TestEnvironment.TestContext.TestDeploymentDir;
#else
                // TestDeploymentDir doesn't exist on MSTest's TestContext.  The only thing we use it for
                // is to install the AppX, and we install the AppX in other ways when using MSTest, so
                // we don't need it there.
                string deploymentDir = null;
#endif

                TestEnvironment.Application.Initialize(true, deploymentDir);
            }

            ElementCache.Clear();
            Wait.ForIdle();

            if (!String.IsNullOrEmpty(Options.LanguageOverride))
            {
                // Before we navigate to the test page, we need to make sure that we've set the language to what was requested.
                var languageChooser = TryFindElement.ById("LanguageChooser");

                // Sometimes TestSetupHelper is used to navigate off of a page other than the main page.  In those circumstances,
                // we won't have a pseudo-loc check box on the page, which is fine - we can just skip this step when that's the case,
                // as we'll have already gone into whatever language we wanted previously.
                if (languageChooser != null)
                {
                    ComboBox languageChooserComboBox = new ComboBox(languageChooser);

                    languageChooserComboBox.SelectItemById(Options.LanguageOverride);
                }
            }
        }
Ejemplo n.º 21
0
        public void TabSizeAndScrollButtonsTest()
        {
            using (var setup = new TestSetupHelper("TabView Tests"))
            {
                UIObject smallerTab = FindElement.ByName("FirstTab");
                UIObject largerTab  = FindElement.ByName("LongHeaderTab");

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

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

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

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

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

                Log.Comment("Changing tab header to short/long.");
                Button shortLongButton = FindElement.ByName <Button>("ShortLongTextButton");
                shortLongButton.InvokeAndWait();
                ElementCache.Refresh();

                diff = Math.Abs(smallerTab.BoundingRectangle.Width - 100);
                Verify.IsLessThanOrEqual(diff, 1, "Smaller text should have min width of 100");

                diff = Math.Abs(largerTab.BoundingRectangle.Width - 240);
                Verify.IsLessThanOrEqual(diff, 1, "Smaller text should have max width of 240");

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

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

                Log.Comment("Scroll buttons should disappear");
                Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should disappear");

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

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

                Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear");
            }
        }
Ejemplo n.º 22
0
        private void PageLoadedTimer_Tick(object sender, EventArgs e)
        {
            ElementCache.Clear();

            try
            {
                var topbox = WebBrowser.Document.GetElementById("nexonCLogin");
                if (topbox == null)
                {
                    return;
                }
            }
            catch
            {
                return;
            }



            WebBrowser.Document.Body.Style = "background-color: #222222";

            //Put Password in passwordbox
            var passwordBox = WebBrowser.Document.GetElementById("txtCPWD");

            if (passwordBox != null)
            {
                PageLoadedTimer.Stop();

                try
                {
                    if (tbRememberPassword.Text.Trim() != "")
                    {
                        passwordBox.Focus();
                        passwordBox.InnerText = tbRememberPassword.Text;
                    }
                }
                catch { } //eat it
            }



            //Page Cleanup

            try
            {
                var header = GetElementsByAttribMatch("div", "className", "header");
                HideElements(header);

                var gnb = GetElementsByAttribMatch("div", "className", "gnbBarLeft");
                HideElements(header);

                var h1 = WebBrowser.Document.GetElementsByTagName("h1").Cast <HtmlElement>();
                HideElements(h1);

                var forgetPass = GetElementsByAttribMatch("p", "className", "loginMenu");
                HideElements(forgetPass);

                var topbox = WebBrowser.Document.GetElementById("nexonCLogin");
                if (topbox != null)
                {
                    topbox.Style = "padding-top:13px";
                }

                var capcha = GetElementsByAttribMatch("div", "className", "captchaSec");
                foreach (var elem in capcha)
                {
                    elem.Style = "margin: 0 0 0px";
                }
            }
            catch { } //eat it



            //page translation

            try
            {
                var btLogin = GetElementsByAttribMatch("div", "className", "btLogin");
                foreach (var elem in btLogin)
                {
                    //for some reason, the login screen REALLY doesn't like it if you touch the button's text...
                    //elem.InnerHtml = elem.InnerHtml.Replace("넥슨ID 로그인", "Log in");

                    elem.Style = "height: 40px";
                }

                var btnLogin = GetElementsByAttribMatch("button", "className", "button01");
                foreach (var elem in btnLogin)
                {
                    elem.Style = "height: 40px";
                }
            }
            catch { } //eat it

            try
            {
                var labelSaveUser = GetElementsByAttribMatch("div", "className", "saveid").FirstOrDefault();
                if (labelSaveUser != null)
                {
                    labelSaveUser.Style = "top:8px";

                    var actualLabel = labelSaveUser.Children.Cast <HtmlElement>().Last();
                    actualLabel.InnerText = "Remember Nexon ID";
                    actualLabel.Style     = "color: #FFFFFF";
                }
            }
            catch { } //eat it


            /* Captcha Changed on Nexon 5/26/2021, removing this functionality, no longer needed.
             * try
             * {
             *  var capchaHeader = GetElementsByAttribMatch("p", "className", "captchaMsg");//.FirstOrDefault();
             *
             *  var idmarge = capchaHeader.FirstOrDefault().Parent.Children.Cast<HtmlElement>().FirstOrDefault(it => it.GetAttribute("className") == "id");
             *
             *  if (idmarge != null)
             *      idmarge.Style = "margin-top:32px";
             *
             *  HideElements(capchaHeader);
             *
             * }
             * catch { } //eat it
             */


            WebBrowser.Visible = true;
        }
Ejemplo n.º 23
0
        // The value of 'testName' should match that which was used when
        // registering the test in TestInventory.cs in the test app project.
        public TestSetupHelper(string testName, string languageOverride = "", bool attemptRestartOnDispose = true)
        {
            // If a test crashes, it can take a little bit of time before we can
            // restart the app again especially if watson is collecting dumps. Adding a
            // delayed retry can help avoid the case where we might otherwise fail a slew of
            // tests that come after the one that crashes the app.
            var retryCount = 10;

            while (retryCount-- > 0)
            {
                try
                {
                    AttemptRestartOnDispose = attemptRestartOnDispose;
                    bool restartedTestApp = false;

                    Log.Comment(testName + " initializing TestSetupHelper");

                    if (TestEnvironment.ShouldRestartApplication)
                    {
                        ElementCache.Clear();
                        Wait.ResetIdleHelper();

                        TestEnvironment.ShouldRestartApplication = false;

                        Log.Comment("Restarting application to ensure test stability...");
                        TestEnvironment.Application.Close();

                        restartedTestApp = true;
                    }

                    if (restartedTestApp ||
                        (TestEnvironment.Application.Process != null && TestEnvironment.Application.Process.HasExited))
                    {
                        if (!restartedTestApp)
                        {
                            // If the test application process exited because something crashed,
                            // we'll restart it in order to make sure that other tests aren't affected.
                            Log.Comment("Application exited unexpectedly. Reinitializing...");
                        }

                        ElementCache.Clear();
                        Wait.ResetIdleHelper();

#if USING_TAEF
                        string deploymentDir = TestEnvironment.TestContext.TestDeploymentDir;
#else
                        // TestDeploymentDir doesn't exist on MSTest's TestContext.  The only thing we use it for
                        // is to install the AppX, and we install the AppX in other ways when using MSTest, so
                        // we don't need it there.
                        string deploymentDir = null;
#endif

                        TestEnvironment.Application.Initialize(true, deploymentDir);
                    }

                    ElementCache.Clear();
                    Wait.ForIdle();

                    // Before we navigate to the test page, we need to make sure that we've set the language to what was requested.
                    var languageChooser = TryFindElement.ById("LanguageChooser");

                    // Sometimes TestSetupHelper is used to navigate off of a page other than the main page.  In those circumstances,
                    // we won't have a pseudo-loc check box on the page, which is fine - we can just skip this step when that's the case,
                    // as we'll have already gone into whatever language we wanted previously.
                    if (languageChooser != null)
                    {
                        ComboBox languageChooserComboBox = new ComboBox(languageChooser);

                        if (!String.IsNullOrEmpty(languageOverride))
                        {
                            languageChooserComboBox.SelectItemById(languageOverride);
                        }
                    }

                    // We were hitting an issue in the lab where sometimes the very first click would fail to go through resulting in
                    // test instability. We work around this by clicking on element when the app launches.
                    var currentPageTextBlock = FindElement.ById("__CurrentPage");
                    if (currentPageTextBlock == null)
                    {
                        string errorMessage = "Cannot find __CurrentPage textblock";
                        Log.Error(errorMessage);
                        DumpHelper.DumpFullContext();
                        throw new InvalidOperationException(errorMessage);
                    }
                    InputHelper.LeftClick(currentPageTextBlock);

                    var uiObject = FindElement.ByNameAndClassName(testName, "Button");
                    if (uiObject == null)
                    {
                        string errorMessage = string.Format("Cannot find test page for: {0}.", testName);

                        // We'll raise the error message first so the dump has proper context preceding it,
                        // and will then throw it as an exception so we immediately cease execution.
                        Log.Error(errorMessage);
                        DumpHelper.DumpFullContext();
                        throw new InvalidOperationException(errorMessage);
                    }

                    // We're now entering a new test page, so everything has changed.  As such, we should clear our
                    // element cache in order to ensure that we don't accidentally retrieve any stale UI objects.
                    ElementCache.Clear();

                    Log.Comment("Waiting until __TestContentLoadedCheckBox to be checked by test app.");
                    CheckBox cb = new CheckBox(FindElement.ById("__TestContentLoadedCheckBox"));

                    if (cb.ToggleState != ToggleState.On)
                    {
                        using (var waiter = cb.GetToggledWaiter())
                        {
                            var testButton = new Button(uiObject);
                            testButton.Invoke();
                            Wait.ForIdle();
                            waiter.Wait();
                        }
                    }
                    else
                    {
                        var testButton = new Button(uiObject);
                        testButton.Invoke();
                    }

                    Wait.ForIdle();

                    Log.Comment("__TestContentLoadedCheckBox checkbox checked, page has loaded");

                    TestCleanupHelper.TestSetupHelperPendingDisposals++;

                    break;
                }
                catch
                {
                    Log.Warning("Failed to setup test. pending retries: " + retryCount);
                    if (retryCount > 0)
                    {
                        Log.Comment("Waiting before retry...");
                        TestEnvironment.ShouldRestartApplication = true;
                        Task.Delay(5000);
                    }
                    else
                    {
                        Log.Error("Failed to set up test!");
                        try
                        {
                            DumpHelper.DumpFullContext();
                        }
                        catch (Exception e)
                        {
                            Log.Error("Also failed to dump context because of an exception: {0}", e.ToString());
                        }

                        throw;
                    }
                }
            }
        }
        public FileExplorer(MSpecUnitTestProvider provider,
                            IUnitTestElementManager manager,
                            PsiModuleManager psiModuleManager,
                            CacheManager cacheManager,
                            UnitTestElementLocationConsumer consumer,
                            IFile file,
                            CheckForInterrupt interrupted)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            _consumer    = consumer;
            _file        = file;
            _interrupted = interrupted;

            var project      = file.GetSourceFile().ToProjectFile().GetProject();
            var projectEnvoy = new ProjectModelElementEnvoy(project);
            var assemblyPath = UnitTestManager.GetOutputAssemblyPath(project).FullPath;

            var cache = new ElementCache();

            var contextFactory = new ContextFactory(provider,
                                                    manager,
                                                    psiModuleManager,
                                                    cacheManager,
                                                    project,
                                                    projectEnvoy,
                                                    assemblyPath,
                                                    cache);
            var contextSpecificationFactory = new ContextSpecificationFactory(provider,
                                                                              manager,
                                                                              psiModuleManager,
                                                                              cacheManager,
                                                                              project,
                                                                              projectEnvoy,
                                                                              cache);
            var behaviorFactory = new BehaviorFactory(provider,
                                                      manager,
                                                      psiModuleManager,
                                                      cacheManager,
                                                      project,
                                                      projectEnvoy,
                                                      cache);
            var behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider,
                                                                                manager,
                                                                                psiModuleManager,
                                                                                cacheManager,
                                                                                project,
                                                                                projectEnvoy);

            _elementHandlers = new List <IElementHandler>
            {
                new ContextElementHandler(contextFactory),
                new ContextSpecificationElementHandler(contextSpecificationFactory),
                new BehaviorElementHandler(behaviorFactory, behaviorSpecificationFactory)
            };
        }
Ejemplo n.º 25
0
        private void PageLoadedTimer_Tick(object sender, EventArgs e)
        {
            ElementCache.Clear();

            var passwordBox = WebBrowser.Document.GetElementById("txtCPWD");

            if (passwordBox != null)
            {
                PageLoadedTimer.Stop();

                try
                {
                    if (tbRememberPassword.Text.Trim() != "")
                    {
                        passwordBox.Focus();
                        passwordBox.InnerText = tbRememberPassword.Text;
                    }
                }
                catch { } //eat it



                try
                {
                    var header = GetElementsByAttribMatch("div", "className", "header");
                    HideElements(header);

                    var gnb = GetElementsByAttribMatch("div", "className", "gnbBarLeft");
                    HideElements(header);

                    var h1 = WebBrowser.Document.GetElementsByTagName("h1").Cast <HtmlElement>();
                    HideElements(h1);
                }
                catch { } //eat it

                /* Captcha Changed on Nexon 5/26/2021, removing this functionality, no longer needed.
                 * try
                 * {
                 *  var capchaHeader = GetElementsByAttribMatch("p", "className", "captchaMsg");//.FirstOrDefault();
                 *
                 *  var idmarge = capchaHeader.FirstOrDefault().Parent.Children.Cast<HtmlElement>().FirstOrDefault(it => it.GetAttribute("className") == "id");
                 *
                 *  if (idmarge != null)
                 *      idmarge.Style = "margin-top:32px";
                 *
                 *  HideElements(capchaHeader);
                 *
                 * }
                 * catch { } //eat it
                 */

                try
                {
                    var labelSaveUser = GetElementsByAttribMatch("div", "className", "saveid").FirstOrDefault();
                    labelSaveUser.Style = "top:8px";

                    var actualLabel = labelSaveUser.Children.Cast <HtmlElement>().Last();
                    actualLabel.InnerText = "Remember Nexon ID";
                }
                catch { } //eat it



                WebBrowser.Visible = true;
            }
        }
Ejemplo n.º 26
0
        private void VerifyViewMode(ViewMode mode)
        {
            // Verify configuration is correct for mode
            TwoPaneViewMode expectedConfiguration = TwoPaneViewMode.SinglePane;

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

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

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

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

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

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

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

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

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

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

            case ViewMode.TopBottom:
            case ViewMode.BottomTop:
                Verify.AreEqual(paneContent1.BoundingRectangle.Left, paneContent2.BoundingRectangle.Left, "Verify panes are vertically aligned");
                if (mode == ViewMode.TopBottom)
                {
                    Verify.IsGreaterThanOrEqual(paneContent2.BoundingRectangle.Top, paneContent1.BoundingRectangle.Bottom, "Verify top/bottom pane placement");
                }
                else
                {
                    Verify.IsGreaterThanOrEqual(paneContent1.BoundingRectangle.Top, paneContent2.BoundingRectangle.Bottom, "Verify bottom/top pane placement");
                }
                break;
            }
        }
Ejemplo n.º 27
0
        public void DisabledItemsAtTopOfColumnKeyboardTest()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
            {
                Log.Warning("This test requires RS3+ keyboarding behavior");
                return;
            }
            using (var setup = new TestSetupHelper("RadioButtons Tests"))
            {
                elements = new RadioButtonsTestPageElements();
                SetItemType(RadioButtonsSourceType.RadioButton);
                SetNumberOfColumns(3);
                foreach (RadioButtonsSourceLocation location in Enum.GetValues(typeof(RadioButtonsSourceLocation)))
                {
                    SetSource(location);

                    SetNumberOfItems(10);
                    InsertDisabledRadioButton(5);
                    InsertDisabledRadioButton(5);
                    InsertDisabledRadioButton(5);

                    TapOnItem(0);
                    VerifySelectedFocusedIndex(0);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(9);
                    TapOnItem(1);
                    VerifySelectedFocusedIndex(1);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(10);
                    TapOnItem(2);
                    VerifySelectedFocusedIndex(2);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(11);
                    TapOnItem(3);
                    VerifySelectedFocusedIndex(3);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(8);
                    TapOnItem(4);
                    VerifySelectedFocusedIndex(4);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(8);
                    TapOnItem(6);
                    VerifySelectedFocusedIndex(9);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(0);
                    TapOnItem(7);
                    VerifySelectedFocusedIndex(10);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(1);
                    TapOnItem(8);
                    VerifySelectedFocusedIndex(11);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(2);
                    TapOnItem(9);
                    VerifySelectedFocusedIndex(12);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(8);

                    ElementCache.Clear();
                }
            }
        }
Ejemplo n.º 28
0
        public void DisabledItemsKeyboardTest()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3))
            {
                Log.Warning("This test requires RS3+ keyboarding behavior");
                return;
            }
            using (var setup = new TestSetupHelper("RadioButtons Tests"))
            {
                elements = new RadioButtonsTestPageElements();
                SetItemType(RadioButtonsSourceType.RadioButton);
                SetNumberOfColumns(3);
                foreach (RadioButtonsSourceLocation location in Enum.GetValues(typeof(RadioButtonsSourceLocation)))
                {
                    SetSource(location);

                    SetNumberOfItems(10);
                    InsertDisabledRadioButton(10);
                    TapOnItem(7);
                    VerifySelectedFocusedIndex(7);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(9);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(5);
                    KeyboardHelper.PressKey(Key.Down);
                    VerifySelectedFocusedIndex(6);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(9);
                    //There is a known bug here where pressing down or right will put focus
                    //On the first item because RadioButton handles the event.
                    //RadioButtons doesn't catch this because it only catches when the
                    //Last item is focused, but that item is disabled here...
                    //Bug #1654
                    //KeyboardHelper.PressKey(Key.Down);
                    //VerifySelectedFocusedIndex(9);
                    //KeyboardHelper.PressKey(Key.Right);
                    //VerifySelectedFocusedIndex(9);

                    InsertDisabledRadioButton(6);
                    InsertDisabledRadioButton(6);

                    TapOnItem(1);
                    VerifySelectedFocusedIndex(1);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(10);
                    TapOnItem(2);
                    VerifySelectedFocusedIndex(2);
                    KeyboardHelper.PressKey(Key.Right);
                    VerifySelectedFocusedIndex(11);
                    TapOnItem(5);
                    KeyboardHelper.PressKey(Key.Up);
                    VerifySelectedFocusedIndex(4);
                    KeyboardHelper.PressKey(Key.Down);
                    VerifySelectedFocusedIndex(5);
                    KeyboardHelper.PressKey(Key.Down);
                    VerifySelectedFocusedIndex(8);
                    TapOnItem(8);
                    VerifySelectedFocusedIndex(10);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(1);
                    TapOnItem(9);
                    VerifySelectedFocusedIndex(11);
                    KeyboardHelper.PressKey(Key.Left);
                    VerifySelectedFocusedIndex(2);

                    ElementCache.Clear();
                }
            }
        }
Ejemplo n.º 29
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");
            }
        }