Skip to content

Commit

Permalink
Regard all modifier keys in SingleKeyAction
Browse files Browse the repository at this point in the history
26814a1 added META, but COMMAND and LEFT_* were left out as
they were misinterpreted as aliases, which they aren't (they only
use the enum definition to get the same char code of the keys).

This time added a test case to avoid similar issues in the future.

Fixes
https://code.google.com/p/selenium/issues/detail?id=4843

Signed-off-by: Andreas Tolfsen <ato@mozilla.com>
  • Loading branch information
zch authored and andreastt committed Mar 17, 2014
1 parent bf917a9 commit 9b57e72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/
public abstract class SingleKeyAction extends KeysRelatedAction {
protected final Keys key;
private static final Keys[] MODIFIER_KEYS = {Keys.SHIFT, Keys.CONTROL, Keys.ALT, Keys.META};
private static final Keys[] MODIFIER_KEYS = {Keys.SHIFT, Keys.CONTROL, Keys.ALT, Keys.META,
Keys.COMMAND, Keys.LEFT_ALT, Keys.LEFT_CONTROL,
Keys.LEFT_SHIFT};

protected SingleKeyAction(Keyboard keyboard, Mouse mouse, Keys key) {
this(keyboard, mouse, null, key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,16 @@ public void keyDownActionFailsOnNonModifier() {
assertTrue(e.getMessage().contains("modifier keys"));
}
}

@Test
public void testAllModifierKeysRegardedAsSuch() {
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.SHIFT);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_SHIFT);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.CONTROL);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_CONTROL);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.ALT);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.LEFT_ALT);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.META);
new KeyDownAction(mockKeyboard, mockMouse, stubLocatable, Keys.COMMAND);
}
}

0 comments on commit 9b57e72

Please sign in to comment.