Пример #1
0
        public void ScrollTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that scroll doesn't work when the control doesn't have focus.");
                InputHelper.RotateWheel(numBox, 1);
                Wait.ForIdle();
                Verify.AreEqual(0, numBox.Value);

                FindTextBox(numBox).SetFocus();

                InputHelper.RotateWheel(numBox, 1);
                InputHelper.RotateWheel(numBox, 1);
                Wait.ForIdle();
                Verify.AreEqual(2, numBox.Value);

                InputHelper.RotateWheel(numBox, -1);
                InputHelper.RotateWheel(numBox, -1);
                InputHelper.RotateWheel(numBox, -1);
                Wait.ForIdle();
                Verify.AreEqual(-1, numBox.Value);
            }
        }
Пример #2
0
        public void ChangeValueTest()
        {
            using (var setup = new TestSetupHelper("ProgressRing Tests"))
            {
                Log.Comment("Changing Value of ProgressRing");

                CheckBox indeterminateCheckBox = FindElement.ByName <CheckBox>("ShowIsIndeterminateCheckBox");
                indeterminateCheckBox.Uncheck();

                RangeValueSpinner progressRing = FindElement.ByName <RangeValueSpinner>("TestProgressRing");
                Verify.AreEqual(0, progressRing.Value);

                double oldValue = progressRing.Value;

                // NOTE: Interaction tests can only access what accessibility tools see. In this case, we can find the button because we
                // set AutomationProperties.Name on the button in ProgressRingPage.xaml
                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                changeValueButton.InvokeAndWait();

                double newValue = progressRing.Value;
                double diff     = Math.Abs(oldValue - newValue);

                Log.Comment("ProgressRing value changed");
                Verify.IsGreaterThan(diff, 0.0);
            }
        }
        public void ValueTextTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that focusing the NumberBox selects the text");
                numBox.SetFocus();
                Wait.ForIdle();
                Wait.ForSeconds(3);
                Edit edit = FindTextBox(numBox);
                Verify.AreEqual("0", edit.GetTextSelection());

                Log.Comment("Verify that setting the value through UIA changes the textbox text");
                numBox.SetValue(10);
                Wait.ForIdle();
                Verify.AreEqual("10", edit.GetText());

                Log.Comment("Verify that setting the text programmatically changes the value and textbox text");
                Button button = FindElement.ByName <Button>("SetTextButton");
                button.InvokeAndWait();
                Verify.AreEqual(15, numBox.Value);
                Verify.AreEqual("15", edit.GetText());

                Log.Comment("Verify that even if the value doesn't change, the textbox text is updated");
                EnterText(numBox, " 15 ");
                Verify.AreEqual("15", edit.GetText());
            }
        }
Пример #4
0
        public void BasicKeyboardTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that loss of focus validates textbox contents");
                EnterText(numBox, "8", false);
                KeyboardHelper.PressKey(Key.Tab);
                Wait.ForIdle();
                Verify.AreEqual(8, numBox.Value);

                Log.Comment("Verify that whitespace around a number still evaluates to the number");
                EnterText(numBox, "  75 ", true);
                Wait.ForIdle();
                Verify.AreEqual(75, numBox.Value);

                Log.Comment("Verify that pressing escape cancels entered text");
                EnterText(numBox, "3", false);
                KeyboardHelper.PressKey(Key.Escape);
                Wait.ForIdle();
                Verify.AreEqual(75, numBox.Value);

                Log.Comment("Verify that pressing up arrow increases the value");
                KeyboardHelper.PressKey(Key.Up);
                Wait.ForIdle();
                Verify.AreEqual(76, numBox.Value);

                Log.Comment("Verify that pressing down arrow decreases the value");
                KeyboardHelper.PressKey(Key.Down);
                Wait.ForIdle();
                Verify.AreEqual(75, numBox.Value);
            }
        }
        public void MinMaxTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                Check("MinCheckBox");
                Check("MaxCheckBox");

                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(10);
                Wait.ForIdle();

                Log.Comment("Verify that setting the value to -1 changes the value to 0");
                numBox.SetValue(-1);
                Wait.ForIdle();
                Verify.AreEqual(0, numBox.Value);

                Log.Comment("Verify that typing '123' in the NumberBox changes the value to 100");
                EnterText(numBox, "123");
                Verify.AreEqual(100, numBox.Value);

                Log.Comment("Changing Max to 90; verify value also changes to 90");
                EnterText(FindElement.ByName <RangeValueSpinner>("MaxNumberBox"), "90");
                Verify.AreEqual(90, numBox.Value);
            }
        }
Пример #6
0
        public void UpdateIndicatorWidthTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Set ProgressBar settings to default for testing");

                RangeValueSpinner progressBar = FindElement.ByName <RangeValueSpinner>("TestProgressBar");

                Edit minimumInput = FindElement.ByName <Edit>("MinimumInput");
                Edit maximumInput = FindElement.ByName <Edit>("MaximumInput");
                Edit widthInput   = FindElement.ByName <Edit>("WidthInput");

                TextBlock widthInputText     = FindElement.ByName <TextBlock>("WidthInputText");
                TextBlock indicatorWidthText = FindElement.ByName <TextBlock>("IndicatorWidthText");

                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                Button updateWidthButton = FindElement.ByName <Button>("UpdateWidthButton");

                minimumInput.SetValue("0");
                maximumInput.SetValue("100");
                widthInput.SetValue("100");

                Verify.AreEqual(progressBar.Minimum, 0);
                Verify.AreEqual(progressBar.Maximum, 100);
                Verify.AreEqual(Convert.ToDouble(widthInputText.DocumentText), 100);

                Log.Comment("Changing value of ProgressBar updates Indicator Width");

                changeValueButton.Invoke();

                Verify.AreEqual(progressBar.Value, Convert.ToDouble(indicatorWidthText.DocumentText));

                Log.Comment("Updating width of ProgressBar also updates Indicator Width");

                widthInput.SetValue("200");
                updateWidthButton.InvokeAndWait();

                Verify.AreEqual((progressBar.Value * 2), Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator width is adjusted to ProgressBar width");

                Log.Comment("Changing value of ProgressBar of different width updates Indicator width");

                changeValueButton.InvokeAndWait();

                Verify.AreEqual((progressBar.Value * 2), Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator width is adjusted to ProgressBar width");

                Log.Comment("Updating Maximum and Minimum also updates Indicator Width");

                minimumInput.SetValue("10");
                maximumInput.SetValue("16");

                changeValueButton.InvokeAndWait();

                double range = progressBar.Maximum - progressBar.Minimum;
                double adjustedValueFromRange = progressBar.Value - progressBar.Minimum;
                double calculatedValue        = (adjustedValueFromRange / range) * Convert.ToDouble(widthInputText.DocumentText);

                Verify.AreEqual(calculatedValue, Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator Width is adjusted based on range and ProgressBar width");
            }
        }
        public void UpdateMinMaxTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Updating Minimum and Maximum value of ProgressBar");

                RangeValueSpinner progressBar = FindElement.ByName <RangeValueSpinner>("TestProgressBar");

                double oldMinimumInputText = progressBar.Minimum;
                double oldMaximumInputText = progressBar.Maximum;

                Button updateMinMaxButton = FindElement.ByName <Button>("UpdateMinMaxButton");
                Edit   minimumInput       = FindElement.ByName <Edit>("MinimumInput");
                Edit   maximumInput       = FindElement.ByName <Edit>("MaximumInput");

                minimumInput.SetValue("10");
                maximumInput.SetValue("15");
                updateMinMaxButton.InvokeAndWait();

                double newMinimumInputText = progressBar.Minimum;
                double newMaximumInputText = progressBar.Maximum;

                Verify.AreNotSame(oldMinimumInputText, newMinimumInputText, "Minimum updated");
                Verify.AreNotSame(oldMaximumInputText, newMaximumInputText, "Maximum updated");

                // Below edge cases are handled by Rangebase

                Log.Comment("Updating Minimum and Maximum when Maximum < Minimum");

                maximumInput.SetValue("5");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(progressBar.Minimum, progressBar.Maximum, "Maximum updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum when Minimum > Value");

                minimumInput.SetValue("15");
                updateMinMaxButton.InvokeAndWait();

                Verify.AreEqual(progressBar.Value, progressBar.Minimum, "Value updates to equal Minimum");
                Verify.AreEqual(progressBar.Maximum, progressBar.Minimum, "Maximum also updates to equal Minimum");

                Log.Comment("Updating Minimum and Maximum to be a decimal number");

                minimumInput.SetValue("0.1");
                maximumInput.SetValue("1.1");
                updateMinMaxButton.InvokeAndWait();

                double oldValue = progressBar.Value;

                Button changeValueButton = FindElement.ByName <Button>("ChangeValueButton");
                changeValueButton.InvokeAndWait();

                double newValue = progressBar.Value;
                double diff     = Math.Abs(oldValue - newValue);

                Verify.IsGreaterThan(diff, Convert.ToDouble(0), "Value of ProgressBar increments properly within range with decimal Minimum and Maximum");
            }
        }
Пример #8
0
        public void UpDownTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                Verify.AreEqual(0, numBox.Value);

                ComboBox spinModeComboBox = FindElement.ByName <ComboBox>("SpinModeComboBox");
                spinModeComboBox.SelectItemByName("Inline");
                Wait.ForIdle();

                Button upButton   = FindButton(numBox, "Increase");
                Button downButton = FindButton(numBox, "Decrease");

                Log.Comment("Verify that up button increases value by 1");
                upButton.InvokeAndWait();
                Verify.AreEqual(1, numBox.Value);

                Log.Comment("Verify that down button decreases value by 1");
                downButton.InvokeAndWait();
                Verify.AreEqual(0, numBox.Value);

                Log.Comment("Change Step value to 5");
                RangeValueSpinner stepNumBox = FindElement.ByName <RangeValueSpinner>("StepNumberBox");
                stepNumBox.SetValue(5);
                Wait.ForIdle();

                Log.Comment("Verify that up button increases value by 5");
                upButton.InvokeAndWait();
                Verify.AreEqual(5, numBox.Value);

                Check("MinCheckBox");
                Check("MaxCheckBox");

                numBox.SetValue(98);
                Wait.ForIdle();
                Log.Comment("Verify that when wrapping is off, clicking the up button won't go past the max value.");
                upButton.InvokeAndWait();
                Verify.AreEqual(100, numBox.Value);

                Check("WrapCheckBox");

                Log.Comment("Verify that when wrapping is on, clicking the up button wraps to the min value.");
                upButton.InvokeAndWait();
                Verify.AreEqual(0, numBox.Value);

                Uncheck("WrapCheckBox");

                Log.Comment("Verify that when wrapping is off, clicking the down button won't go past the min value.");
                downButton.InvokeAndWait();
                Verify.AreEqual(0, numBox.Value);

                Check("WrapCheckBox");

                Log.Comment("Verify that when wrapping is on, clicking the down button wraps to the max value.");
                downButton.InvokeAndWait();
                Verify.AreEqual(100, numBox.Value);
            }
        }
Пример #9
0
        public void ValueChangedTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                TextBlock newValueTextBlock = FindElement.ByName <TextBlock>("NewValueTextBox");
                TextBlock oldValueTextBlock = FindElement.ByName <TextBlock>("OldValueTextBox");
                TextBlock textTextBlock     = FindElement.ByName <TextBlock>("TextTextBox");

                Check("MinCheckBox");
                Check("MaxCheckBox");

                Log.Comment("Verify that entering a new number fires ValueChanged event.");
                EnterText(numBox, "12");
                Verify.AreEqual("12", textTextBlock.GetText());
                Verify.AreEqual("12", newValueTextBlock.GetText());
                Verify.AreEqual("NaN", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value through UIA fires ValueChanged event.");
                Button button = FindElement.ByName <Button>("SetValueButton");
                button.InvokeAndWait();
                Verify.AreEqual("42", textTextBlock.GetText());
                Verify.AreEqual("42", newValueTextBlock.GetText());
                Verify.AreEqual("12", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value below min gives proper values.");
                EnterText(numBox, "-5");
                Verify.AreEqual("0", textTextBlock.GetText());
                Verify.AreEqual("0", newValueTextBlock.GetText());
                Verify.AreEqual("42", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value above max gives proper values.");
                EnterText(numBox, "150");
                Verify.AreEqual("100", textTextBlock.GetText());
                Verify.AreEqual("100", newValueTextBlock.GetText());
                Verify.AreEqual("0", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting text to an empty string sets value to NaN.");
                EnterText(numBox, "");
                Verify.AreEqual("", textTextBlock.GetText());
                Verify.AreEqual("NaN", newValueTextBlock.GetText());
                Verify.AreEqual("100", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting two way bound value to NaN doesn't cause a crash");
                Button twoWayBindNanbutton = FindElement.ByName <Button>("SetTwoWayBoundValueNaNButton");
                twoWayBindNanbutton.InvokeAndWait();
                TextBlock twoWayBoundNumberBoxValue = FindElement.ByName <TextBlock>("TwoWayBoundNumberBoxValue");
                Verify.AreEqual("NaN", twoWayBoundNumberBoxValue.GetText());

                Log.Comment("Verify that setting value to NaN doesn't have any effect");
                Button nanbutton = FindElement.ByName <Button>("SetValueNaNButton");
                nanbutton.InvokeAndWait();
                Verify.AreEqual("", textTextBlock.GetText());
                Verify.AreEqual("NaN", newValueTextBlock.GetText());
                Verify.AreEqual("100", oldValueTextBlock.GetText());
            }
        }
Пример #10
0
        public void ValueChangedTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                TextBlock newValueTextBlock = FindElement.ByName <TextBlock>("NewValueTextBox");
                TextBlock oldValueTextBlock = FindElement.ByName <TextBlock>("OldValueTextBox");
                TextBlock textTextBlock     = FindElement.ByName <TextBlock>("TextTextBox");

                Check("MinCheckBox");
                Check("MaxCheckBox");

                Log.Comment("Verify that entering a new number fires ValueChanged event.");
                EnterText(numBox, "12");
                Verify.AreEqual("12", textTextBlock.GetText());
                Verify.AreEqual("12", newValueTextBlock.GetText());
                Verify.AreEqual("0", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value through UIA fires ValueChanged event.");
                Button button = FindElement.ByName <Button>("SetValueButton");
                button.InvokeAndWait();
                Verify.AreEqual("42", textTextBlock.GetText());
                Verify.AreEqual("42", newValueTextBlock.GetText());
                Verify.AreEqual("12", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value below min gives proper values.");
                EnterText(numBox, "-5");
                Verify.AreEqual("0", textTextBlock.GetText());
                Verify.AreEqual("0", newValueTextBlock.GetText());
                Verify.AreEqual("42", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value above max gives proper values.");
                EnterText(numBox, "150");
                Verify.AreEqual("100", textTextBlock.GetText());
                Verify.AreEqual("100", newValueTextBlock.GetText());
                Verify.AreEqual("0", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value to NaN is invalid and does not fire an event.");
                Button nanbutton = FindElement.ByName <Button>("SetValueNaNButton");
                nanbutton.InvokeAndWait();
                Verify.AreEqual("100", textTextBlock.GetText());
                Verify.AreEqual("100", newValueTextBlock.GetText());
                Verify.AreEqual("0", oldValueTextBlock.GetText());

                Log.Comment("Verify that setting value to NaN is valid when validation is disabled.");
                ComboBox validationComboBox = FindElement.ByName <ComboBox>("ValidationComboBox");
                validationComboBox.SelectItemByName("Disabled");
                Wait.ForIdle();
                nanbutton.InvokeAndWait();
                Verify.AreEqual("NaN", textTextBlock.GetText());
                Verify.AreEqual("NaN", newValueTextBlock.GetText());
                Verify.AreEqual("100", oldValueTextBlock.GetText());
            }
        }
        public void UpDownTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                Verify.AreEqual(0, numBox.Value);

                ComboBox spinModeComboBox = FindElement.ByName <ComboBox>("SpinModeComboBox");
                spinModeComboBox.SelectItemByName("Inline");
                Wait.ForIdle();

                Button upButton   = FindButton(numBox, "Increase");
                Button downButton = FindButton(numBox, "Decrease");

                Log.Comment("Verify that up button increases value by 1");
                upButton.InvokeAndWait();
                Verify.AreEqual(1, numBox.Value);

                Log.Comment("Verify that down button decreases value by 1");
                downButton.InvokeAndWait();
                Verify.AreEqual(0, numBox.Value);

                Log.Comment("Change SmallChange value to 5");
                RangeValueSpinner smallChangeNumBox = FindElement.ByName <RangeValueSpinner>("SmallChangeNumberBox");
                smallChangeNumBox.SetValue(5);
                Wait.ForIdle();

                Log.Comment("Verify that up button increases value by 5");
                upButton.InvokeAndWait();
                Verify.AreEqual(5, numBox.Value);

                Check("MinCheckBox");
                Check("MaxCheckBox");

                numBox.SetValue(100);
                Check("WrapCheckBox");

                Log.Comment("Verify that when wrapping is on, and value is at max, clicking the up button wraps to the min value.");
                upButton.InvokeAndWait();
                Verify.AreEqual(0, numBox.Value);

                Log.Comment("Verify that when wrapping is on, clicking the down button wraps to the max value.");
                downButton.InvokeAndWait();
                Verify.AreEqual(100, numBox.Value);

                Log.Comment("Verify that incrementing after typing in a value validates the text first.");
                EnterText(numBox, "50", false);
                upButton.InvokeAndWait();
                Verify.AreEqual(55, numBox.Value);
            }
        }
        void EnterText(RangeValueSpinner numBox, string text, bool pressEnter = true)
        {
            Edit edit = FindTextBox(numBox);

            if (edit != null)
            {
                KeyboardHelper.EnterText(edit, text);
                if (pressEnter)
                {
                    KeyboardHelper.PressKey(Key.Enter);
                }
                Wait.ForIdle();
            }
        }
Пример #13
0
        public void CustomFormatterTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(8);
                Wait.ForIdle();
                Edit edit = FindTextBox(numBox);
                Verify.AreEqual("8", edit.GetText());

                Button button = FindElement.ByName <Button>("CustomFormatterButton");
                button.InvokeAndWait();

                Verify.AreEqual("8.00", edit.GetText());
            }
        }
        public void GamepadTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that pressing A validates textbox contents");
                EnterText(numBox, "8", false);
                GamepadHelper.PressButton(numBox, GamepadButton.A);
                Wait.ForIdle();
                Verify.AreEqual(8, numBox.Value);

                Log.Comment("Verify that pressing B cancels entered text");
                EnterText(numBox, "3", false);
                GamepadHelper.PressButton(numBox, GamepadButton.B);
                Wait.ForIdle();
                Verify.AreEqual(8, numBox.Value);
            }
        }
        public void PaddingOffsetTest()
        {
            using (var setup = new TestSetupHelper("ProgressBar Tests"))
            {
                Log.Comment("Set ProgressBar Padding settings to default for testing");

                RangeValueSpinner progressBar = FindElement.ByName <RangeValueSpinner>("TestProgressBar");

                Edit paddingLeftInput  = FindElement.ByName <Edit>("PaddingLeftInput");
                Edit paddingRightInput = FindElement.ByName <Edit>("PaddingRightInput");

                TextBlock paddingLeftText    = FindElement.ByName <TextBlock>("PaddingLeftText");
                TextBlock paddingRightText   = FindElement.ByName <TextBlock>("PaddingRightText");
                TextBlock indicatorWidthText = FindElement.ByName <TextBlock>("IndicatorWidthText");
                TextBlock widthInputText     = FindElement.ByName <TextBlock>("WidthInputText");

                paddingLeftInput.SetValue("0");
                paddingRightInput.SetValue("0");

                Button updatePaddingButton = FindElement.ByName <Button>("UpdatePaddingButton");
                updatePaddingButton.InvokeAndWait();

                Verify.AreEqual(Convert.ToDouble(paddingLeftText.DocumentText), 0);
                Verify.AreEqual(Convert.ToDouble(paddingRightText.DocumentText), 0);

                Log.Comment("IndicatorWidth offsets where ProgressBar has Padding");

                paddingLeftInput.SetValue("10");
                paddingRightInput.SetValue("10");

                updatePaddingButton.InvokeAndWait();

                Edit valueInput = FindElement.ByName <Edit>("ValueInput");
                valueInput.SetValue("100");

                Button updateValueButton = FindElement.ByName <Button>("UpdateValueButton");
                updateValueButton.InvokeAndWait();

                double maxIndicatorWidth = Convert.ToDouble(widthInputText.DocumentText) - Convert.ToDouble(paddingLeftText.DocumentText) - Convert.ToDouble(paddingRightText.DocumentText);

                Verify.AreEqual(maxIndicatorWidth, Convert.ToDouble(indicatorWidthText.DocumentText), "Indicator at max width is reduced by Padding");
            }
        }
Пример #16
0
        public void ScrollTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(0);
                Wait.ForIdle();

                Log.Comment("Verify that scroll doesn't work when the control doesn't have focus.");
                FindElement.ByName("MaxCheckBox").SetFocus();
                Wait.ForIdle();
                InputHelper.RotateWheel(numBox, 1);
                Wait.ForIdle();
                Verify.AreEqual(0, numBox.Value);

                FindTextBox(numBox).SetFocus();
                Wait.ForIdle();

                InputHelper.RotateWheel(FindTextBox(numBox), 1);
                InputHelper.RotateWheel(FindTextBox(numBox), 1);
                Wait.ForIdle();
                Verify.AreEqual(2, numBox.Value);

                InputHelper.RotateWheel(FindTextBox(numBox), -1);
                InputHelper.RotateWheel(FindTextBox(numBox), -1);
                InputHelper.RotateWheel(FindTextBox(numBox), -1);
                Wait.ForIdle();
                Verify.AreEqual(-1, numBox.Value);

                // Testing for 1705
                RangeValueSpinner numBoxInScrollViewer = FindElement.ByName <RangeValueSpinner>("NumberBoxInScroller");
                numBoxInScrollViewer.SetValue(0);
                Wait.ForIdle();
                FindTextBox(numBoxInScrollViewer).SetFocus();
                InputHelper.RotateWheel(numBoxInScrollViewer, 1);
                InputHelper.RotateWheel(numBoxInScrollViewer, 1);
                Wait.ForIdle();
                Verify.AreEqual(2, numBoxInScrollViewer.Value);

                TextBlock vertOffset = FindElement.ByName <TextBlock>("VerticalOffsetDisplayBlock");
                Verify.AreEqual("0", vertOffset.GetText());
            }
        }
        public void CustomFormatterTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(8);
                Wait.ForIdle();
                Edit edit = FindTextBox(numBox);
                Verify.AreEqual("8", edit.GetText());

                Button button = FindElement.ByName <Button>("CustomFormatterButton");
                button.InvokeAndWait();

                Verify.AreEqual("8,00", edit.GetText());

                Log.Comment("Verify that using a formatter with a different decimal symbol works as expected.");
                EnterText(numBox, "7,45");
                Verify.AreEqual(7.45, numBox.Value);
            }
        }
Пример #18
0
        public void ScrollTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Check("HyperScrollCheckBox");

                InputHelper.RotateWheel(numBox, 1);
                InputHelper.RotateWheel(numBox, 1);
                Wait.ForIdle();
                Verify.AreEqual(2, numBox.Value);

                InputHelper.RotateWheel(numBox, -1);
                InputHelper.RotateWheel(numBox, -1);
                InputHelper.RotateWheel(numBox, -1);
                Wait.ForIdle();
                Verify.AreEqual(-1, numBox.Value);
            }
        }
        public void ValidationDisabledTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                ComboBox validationComboBox = FindElement.ByName <ComboBox>("ValidationComboBox");
                validationComboBox.SelectItemByName("Disabled");
                Wait.ForIdle();

                Check("MinCheckBox");
                Check("MaxCheckBox");

                Log.Comment("Verify that numbers outside the range can be set if validation is disabled.");
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(-10);
                Wait.ForIdle();
                Verify.AreEqual(-10, numBox.Value);

                numBox.SetValue(150);
                Wait.ForIdle();
                Verify.AreEqual(150, numBox.Value);
            }
        }
        public void VerifyRightClickForContextMenuDoesNotDeselectText()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");
                numBox.SetValue(0);

                Log.Comment("Verify that focusing the NumberBox selects the text");
                numBox.SetFocus();
                Wait.ForIdle();
                Wait.ForSeconds(3);
                Edit edit = FindTextBox(numBox);
                Verify.AreEqual("0", edit.GetTextSelection());

                Log.Comment("Verify that right-clicking on the NumberBox's input field (to bring up the context menu) does not clear the selection");
                // (15, 15): Just some offset large enough to make sure the right-click below will actually bring up the context menu
                InputHelper.RightClick(edit, 15, 15);
                Wait.ForIdle();

                Verify.AreEqual("0", edit.GetTextSelection());
            }
        }
        public void UpDownEnabledTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                ComboBox spinModeComboBox = FindElement.ByName <ComboBox>("SpinModeComboBox");
                spinModeComboBox.SelectItemByName("Inline");
                Wait.ForIdle();

                Button upButton   = FindButton(numBox, "Increase");
                Button downButton = FindButton(numBox, "Decrease");

                Check("MinCheckBox");
                Check("MaxCheckBox");

                Log.Comment("Verify that when Value is at Minimum, the down spin button is disabled.");
                Verify.IsTrue(upButton.IsEnabled);
                Verify.IsFalse(downButton.IsEnabled);

                Log.Comment("Verify that when Value is at Maximum, the up spin button is disabled.");
                numBox.SetValue(100);
                Wait.ForIdle();
                Verify.IsFalse(upButton.IsEnabled);
                Verify.IsTrue(downButton.IsEnabled);

                Log.Comment("Verify that when wrapping is enabled, spin buttons are enabled.");
                Check("WrapCheckBox");
                Verify.IsTrue(upButton.IsEnabled);
                Verify.IsTrue(downButton.IsEnabled);
                Uncheck("WrapCheckBox");

                Log.Comment("Verify that when Maximum is updated the up button is updated also.");
                RangeValueSpinner maxBox = FindElement.ByName <RangeValueSpinner>("MaxNumberBox");
                maxBox.SetValue(200);
                Wait.ForIdle();
                Verify.IsTrue(upButton.IsEnabled);
                Verify.IsTrue(downButton.IsEnabled);

                Log.Comment("Verify that spin buttons are disabled if value is NaN.");
                numBox.SetValue(double.NaN);
                Wait.ForIdle();
                Verify.IsFalse(upButton.IsEnabled);
                Verify.IsFalse(downButton.IsEnabled);

                ComboBox validationComboBox = FindElement.ByName <ComboBox>("ValidationComboBox");
                validationComboBox.SelectItemByName("Disabled");
                Wait.ForIdle();

                Log.Comment("Verify that when validation is off, spin buttons are enabled");
                numBox.SetValue(0);
                Wait.ForIdle();
                Verify.IsTrue(upButton.IsEnabled);
                Verify.IsTrue(downButton.IsEnabled);

                Log.Comment("...except in the NaN case");
                numBox.SetValue(double.NaN);
                Wait.ForIdle();
                Verify.IsFalse(upButton.IsEnabled);
                Verify.IsFalse(downButton.IsEnabled);
            }
        }
        public void BasicExpressionTest()
        {
            using (var setup = new TestSetupHelper("NumberBox Tests"))
            {
                RangeValueSpinner numBox = FindElement.ByName <RangeValueSpinner>("TestNumberBox");

                Log.Comment("Verify that expressions don't work if AcceptsExpression is false");
                EnterText(numBox, "5 + 3");
                Verify.AreEqual(0, numBox.Value);

                Check("ExpressionCheckBox");

                int          numErrors  = 0;
                const double resetValue = 1234;

                Dictionary <string, double> expressions = new Dictionary <string, double>
                {
                    // Valid expressions. None of these should evaluate to the reset value.
                    { "5", 5 },
                    { "-358", -358 },
                    { "12.34", 12.34 },
                    { "5 + 3", 8 },
                    { "12345 + 67 + 890", 13302 },
                    { "000 + 0011", 11 },
                    { "5 - 3 + 2", 4 },
                    { "3 + 2 - 5", 0 },
                    { "9 - 2 * 6 / 4", 6 },
                    { "9 - -7", 16 },
                    { "9-3*2", 3 },         // no spaces
                    { " 10  *   6  ", 60 }, // extra spaces
                    { "10 /( 2 + 3 )", 2 },
                    { "5 * -40", -200 },
                    { "(1 - 4) / (2 + 1)", -1 },
                    { "3 * ((4 + 8) / 2)", 18 },
                    { "23 * ((0 - 48) / 8)", -138 },
                    { "((74-71)*2)^3", 216 },
                    { "2 - 2 ^ 3", -6 },
                    { "2 ^ 2 ^ 2 / 2 + 9", 17 },
                    { "5 ^ -2", 0.04 },
                    { "5.09 + 14.333", 19.423 },
                    { "2.5 * 0.35", 0.875 },
                    { "-2 - 5", -7 },       // begins with negative number
                    { "(10)", 10 },         // number in parens
                    { "(-9)", -9 },         // negative number in parens
                    { "0^0", 1 },           // who knew?

                    // These should not parse, which means they will reset back to the previous value.
                    { "5x + 3y", resetValue },        // invalid chars
                    { "5 + (3", resetValue },         // mismatched parens
                    { "9 + (2 + 3))", resetValue },
                    { "(2 + 3)(1 + 5)", resetValue }, // missing operator
                    { "9 + + 7", resetValue },        // extra operators
                    { "9 - * 7", resetValue },
                    { "9 - - 7", resetValue },
                    { "+9", resetValue },
                    { "1 / 0", resetValue },          // divide by zero

                    // These don't currently work, but maybe should.
                    { "-(3 + 5)", resetValue }, // negative sign in front of parens -- should be -8
                };
                foreach (KeyValuePair <string, double> pair in expressions)
                {
                    numBox.SetValue(resetValue);
                    Wait.ForIdle();

                    EnterText(numBox, pair.Key);
                    string output = "Expression '" + pair.Key + "' - expected: " + pair.Value + ", actual: " + numBox.Value;
                    if (Math.Abs(pair.Value - numBox.Value) > 0.00001)
                    {
                        numErrors++;
                        Log.Warning(output);
                    }
                    else
                    {
                        Log.Comment(output);
                    }
                }

                Verify.AreEqual(0, numErrors);
            }
        }