in dev/ColorPicker/InteractionTests/ColorPickerTests.cs [723:818]
public void CanUseKeyboardToInteractWithColorSpectrum(bool isRTL)
{
using (var setup = SetupColorPickerTest(TestOptions.EnableAlpha))
{
SetIsRTL(isRTL);
bool colorNamesAvailable = ApiInformation.IsMethodPresent("Windows.UI.ColorHelper", "ToDisplayName");
Log.Comment("Give initial keyboard focus to the color spectrum.");
FindElement.ById(ColorSpectrumAutomationId).SetFocus();
Wait.ForIdle();
VerifyElementIsFocused(ColorSpectrumAutomationId);
VerifySelectionEllipsePosition(0, 0);
Log.Comment("Keyboard to the right and left first. We expect this to change the hue by 1 each time (+/- 4 to one RGB channel), applying wrapping.");
PressKeyAndWaitForColorChange(isRTL ? Key.Left : Key.Right);
VerifyColorIsSelected(255, 4, 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(1, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Right : Key.Left);
VerifyColorIsSelected(255, 0, 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(0, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Right : Key.Left);
VerifyColorIsSelected(255, 0, 4);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(256, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Left : Key.Right);
VerifyColorIsSelected(255, 0, 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(0, 0);
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, applying wrapping.");
PressKeyAndWaitForColorChange(isRTL ? Key.Left : Key.Right, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 119 : 128, 0);
VerifyColorNameIsSelected("Orange");
VerifySelectionEllipsePosition(colorNamesAvailable ? 20 : 21, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Right : Key.Left, ModifierKey.Control);
VerifyColorIsSelected(255, 0, colorNamesAvailable ? 13 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Right : Key.Left, ModifierKey.Control);
VerifyColorIsSelected(255, 0, colorNamesAvailable ? 170 : 4);
VerifyColorNameIsSelected("Pink");
VerifySelectionEllipsePosition(colorNamesAvailable ? 228 : 256, 0);
PressKeyAndWaitForColorChange(isRTL ? Key.Left : Key.Right, ModifierKey.Control);
VerifyColorIsSelected(255, 0, colorNamesAvailable ? 13 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 0);
Log.Comment("Next, keyboard up and down. We expect this to change the saturation by 1 each time (+/- 2.5 to both non-max RGB channels), applying wrapping.");
PressKeyAndWaitForColorChange(Key.Down);
VerifyColorIsSelected(255, 3, colorNamesAvailable ? 15 : 3);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 3);
PressKeyAndWaitForColorChange(Key.Up);
VerifyColorIsSelected(255, 0, colorNamesAvailable ? 13 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 0);
PressKeyAndWaitForColorChange(Key.Up);
VerifyColorIsSelected(255, 255, 255);
VerifyColorNameIsSelected("White");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 256);
PressKeyAndWaitForColorChange(Key.Down);
VerifyColorIsSelected(255, 0, colorNamesAvailable ? 13 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, 0);
Log.Comment("Now hold control keyboard up and down again. We expect this to jump to the next named color each time, applying wrapping.");
PressKeyAndWaitForColorChange(Key.Down, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 153 : 25, colorNamesAvailable ? 158 : 25);
VerifyColorNameIsSelected("Rose");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 154 : 26);
PressKeyAndWaitForColorChange(Key.Up, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 38 : 0);
PressKeyAndWaitForColorChange(Key.Up, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 242 : 255, colorNamesAvailable ? 243 : 255);
VerifyColorNameIsSelected("White");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 243 : 256);
PressKeyAndWaitForColorChange(Key.Down, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 41 : 0, colorNamesAvailable ? 52 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 41 : 0);
PressKeyAndWaitForColorChange(Key.Down, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 153 : 25, colorNamesAvailable ? 158 : 25);
VerifyColorNameIsSelected("Rose");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 154 : 26);
PressKeyAndWaitForColorChange(Key.Up, ModifierKey.Control);
VerifyColorIsSelected(255, colorNamesAvailable ? 38 : 0, colorNamesAvailable ? 49 : 0);
VerifyColorNameIsSelected("Red");
VerifySelectionEllipsePosition(colorNamesAvailable ? 255 : 0, colorNamesAvailable ? 38 : 0);
}
}