public void CanUseKeyboardToInteractWithSliders()

in dev/ColorPicker/InteractionTests/ColorPickerTests.cs [820:895]


        public void CanUseKeyboardToInteractWithSliders(bool isRTL, bool shouldTryUpAndDown = false, bool shouldOrientationBeHorizontal = false)
        {
            using (var setup = SetupColorPickerTest(TestOptions.EnableAlpha | TestOptions.DisableColorSpectrumLoadWait))
            {
                SetIsRTL(isRTL);
                SetIsHorizontalOrientation(shouldOrientationBeHorizontal);
                Key increaseKey = shouldTryUpAndDown ? Key.Up : isRTL ? Key.Left : Key.Right;
                Key decreaseKey = shouldTryUpAndDown ? Key.Down : isRTL ? Key.Right : Key.Left;

                bool colorNamesAvailable = ApiInformation.IsMethodPresent("Windows.UI.ColorHelper", "ToDisplayName");

                Log.Comment("Initialize the color to what it was at the end of CanUseKeyboardToInteractWithColorSpectrum.");
                SetColorSpectrumColor(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);

                Log.Comment("Give initial keyboard focus to the color spectrum.");
                FindElement.ById(ColorSpectrumAutomationId).SetFocus();
                Wait.ForIdle();

                Log.Comment("Give keyboard focus to the value slider using tab.");
                KeyboardHelper.PressKey(Key.Tab);
                VerifyElementIsFocused(ThirdDimensionAutomationId);

                Log.Comment("Keyboard to the right and left first.  We expect this to change the value by 1 each time (+/- 2.5 to the max RGB channel), but not wrap.");
                KeyboardHelper.PressKey(decreaseKey);
                VerifyColorIsSelected(252, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
                VerifyColorNameIsSelected("Red");
                KeyboardHelper.PressKey(increaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
                VerifyColorNameIsSelected("Red");
                KeyboardHelper.PressKey(increaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
                VerifyColorNameIsSelected("Red");

                Log.Comment("Now hold control and keyboard to the right and left again.  We expect this to jump to the next named color each time, but not wrap.");
                KeyboardHelper.PressKey(decreaseKey, ModifierKey.Control);
                VerifyColorIsSelected(colorNamesAvailable ? 102 : 230, colorNamesAvailable ? 15 : 0, colorNamesAvailable ? 20 : 0);
                VerifyColorNameIsSelected("Dark red");
                KeyboardHelper.PressKey(decreaseKey, ModifierKey.Control);
                VerifyColorIsSelected(colorNamesAvailable ? 15 : 204, colorNamesAvailable ? 2 : 0, colorNamesAvailable ? 3 : 0);
                VerifyColorNameIsSelected("Black");
                KeyboardHelper.PressKey(decreaseKey, ModifierKey.Control);
                VerifyColorIsSelected(colorNamesAvailable ? 0 : 179, 0, 0);
                VerifyColorNameIsSelected("Black");
                KeyboardHelper.PressKey(increaseKey, ModifierKey.Control);
                VerifyColorIsSelected(colorNamesAvailable ? 105 : 204, colorNamesAvailable ? 16 : 0, colorNamesAvailable ? 20 : 0);
                VerifyColorNameIsSelected("Dark red");
                KeyboardHelper.PressKey(increaseKey, ModifierKey.Control);
                VerifyColorIsSelected(colorNamesAvailable ? 214 : 230, colorNamesAvailable ? 32 : 0, colorNamesAvailable ? 41 : 0);
                VerifyColorNameIsSelected("Red");
                KeyboardHelper.PressKey(increaseKey, ModifierKey.Control);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
                VerifyColorNameIsSelected("Red");

                Log.Comment("Give keyboard focus to the alpha slider using tab.");
                KeyboardHelper.PressKey(Key.Tab);
                VerifyElementIsFocused(AlphaSliderAutomationId);

                Log.Comment("Keyboard to the right and left first.  We expect this to change the alpha by 2.5 each time, but not wrap.");
                KeyboardHelper.PressKey(decreaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 252);
                KeyboardHelper.PressKey(increaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 255);
                KeyboardHelper.PressKey(increaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 255);

                Log.Comment("Now hold control and keyboard to the right and left again.  We expect this to change the alpha by 25 each time, but not wrap.  We also expect us to snap to multiples of 10 if we're between them.");
                KeyboardHelper.PressKey(decreaseKey, ModifierKey.Control);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 230);
                KeyboardHelper.PressKey(increaseKey);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 232);
                KeyboardHelper.PressKey(decreaseKey, ModifierKey.Control);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 230);
                KeyboardHelper.PressKey(increaseKey, ModifierKey.Control);
                VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0, 255);
            }
        }