public void AccessibilityTest()
        {
            using (var setup = new TestSetupHelper("SplitButton Tests"))
            {
                SplitButton splitButton = FindElement.ByName <SplitButton>("TestSplitButton");

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

                Log.Comment("Verify that SplitButton has no accessible children");
                Verify.AreEqual(0, splitButton.Children.Count);

                Verify.AreEqual("0", clickCountTextBlock.DocumentText);
                Log.Comment("Verify that invoking the SplitButton causes a click");
                splitButton.InvokeAndWait();
                Verify.AreEqual("1", clickCountTextBlock.DocumentText);

                Verify.AreEqual("0", flyoutOpenedCountTextBlock.DocumentText);
                Log.Comment("Verify that expanding the SplitButton opens the flyout");
                splitButton.ExpandAndWait();
                Verify.AreEqual("1", flyoutOpenedCountTextBlock.DocumentText);
                Verify.AreEqual(ExpandCollapseState.Expanded, splitButton.ExpandCollapseState);

                Verify.AreEqual("0", flyoutClosedCountTextBlock.DocumentText);
                Log.Comment("Verify that collapsing the SplitButton closes the flyout");
                splitButton.CollapseAndWait();
                Verify.AreEqual("1", flyoutClosedCountTextBlock.DocumentText);
                Verify.AreEqual(ExpandCollapseState.Collapsed, splitButton.ExpandCollapseState);
            }
        }
Ejemplo n.º 2
0
        public void CommandTest()
        {
            using (var setup = new TestSetupHelper("SplitButton Tests"))
            {
                SplitButton splitButton = FindElement.ByName <SplitButton>("CommandSplitButton");

                CheckBox  canExecuteCheckBox    = FindElement.ByName <CheckBox>("CanExecuteCheckBox");
                TextBlock executeCountTextBlock = FindElement.ByName <TextBlock>("ExecuteCountTextBlock");

                Log.Comment("Verify that the control starts out enabled");
                Verify.AreEqual(ToggleState.On, canExecuteCheckBox.ToggleState);
                Verify.AreEqual(true, splitButton.IsEnabled);
                Verify.AreEqual("0", executeCountTextBlock.DocumentText);

                Log.Comment("Click primary button to execute command");
                ClickPrimaryButton(splitButton);
                Verify.AreEqual("1", executeCountTextBlock.DocumentText);

                Log.Comment("Click primary button with SPACE key to execute command");
                ClickPrimaryButtonWithKey(splitButton, "SPACE");
                Verify.AreEqual("2", executeCountTextBlock.DocumentText);

                Log.Comment("Click primary button with ENTER key to execute command");
                ClickPrimaryButtonWithKey(splitButton, "ENTER");
                Verify.AreEqual("3", executeCountTextBlock.DocumentText);

                Log.Comment("Use invoke pattern to execute command");
                splitButton.InvokeAndWait();
                Verify.AreEqual("4", executeCountTextBlock.DocumentText);

                Log.Comment("Verify that setting CanExecute to false disables the primary button");
                canExecuteCheckBox.Uncheck();
                Wait.ForIdle();
                ClickPrimaryButton(splitButton);
                Verify.AreEqual("4", executeCountTextBlock.DocumentText);
            }
        }