8155742: [Windows] robot.keyPress(KeyEvent.VK_ALT_GRAPH) throws java.lang.IllegalArgumentException in windows

Reviewed-by: rchamyal, serb
This commit is contained in:
Ambarish Rapte 2016-05-05 14:56:42 +03:00
parent 6fd98f9b98
commit 08482543b4
4 changed files with 23 additions and 15 deletions

View File

@ -2720,6 +2720,7 @@ KeyMapEntry keyMapTable[] = {
{java_awt_event_KeyEvent_VK_SHIFT, VK_SHIFT},
{java_awt_event_KeyEvent_VK_CONTROL, VK_CONTROL},
{java_awt_event_KeyEvent_VK_ALT, VK_MENU},
{java_awt_event_KeyEvent_VK_ALT_GRAPH, VK_RMENU},
{java_awt_event_KeyEvent_VK_NUM_LOCK, VK_NUMLOCK},
// Miscellaneous Windows keys

View File

@ -335,6 +335,9 @@ void AwtRobot::DoKeyEvent( jint jkey, DWORD dwFlags )
} else {
// get the scancode from the virtual key
scancode = ::MapVirtualKey(vkey, 0);
if (vkey == VK_RMENU) {
dwFlags |= KEYEVENTF_EXTENDEDKEY;
}
keybd_event(vkey, scancode, dwFlags, 0);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,17 +21,23 @@
* questions.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import static jdk.testlibrary.Asserts.assertTrue;
/*
* @test
* @test 8155742
* @summary Make sure that modifier key mask is set when robot press
* some key with one or more modifiers.
*
* some key with one or more modifiers.
* @library ../../../../lib/testlibrary/
* @build ExtendedRobot
* @run main ModifierRobotKeyTest
@ -60,15 +66,17 @@ public class ModifierRobotKeyTest extends KeyAdapter {
}
public ModifierRobotKeyTest() throws Exception {
modifierKeys = new int[3];
modifierKeys = new int[4];
modifierKeys[0] = KeyEvent.VK_SHIFT;
modifierKeys[1] = KeyEvent.VK_CONTROL;
modifierKeys[2] = KeyEvent.VK_ALT;
modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;
inputMasks = new int[3];
inputMasks = new int[4];
inputMasks[0] = InputEvent.SHIFT_MASK;
inputMasks[1] = InputEvent.CTRL_MASK;
inputMasks[2] = InputEvent.ALT_MASK;
inputMasks[3] = InputEvent.ALT_GRAPH_MASK;
modifierStatus = new boolean[modifierKeys.length];

View File

@ -44,12 +44,8 @@ public class AltGraphModifierTest {
= {
"This test is for verifying Alt-Gr modifier of an event.",
"Windows :-",
"1. Please check if Alt-Gr key is present on keyboard.",
"2. If present, press the Alt-Gr key and perform",
" mouse click on the TestWindow.",
"3. If Alt-Gr key is not present, press Ctrl+Alt keys &",
" perform mouse click on the TestWindow.",
"4. Test will exit by itself with appropriate result.",
"1. Click Pass.",
"2. Alt-Gr modifier is tested under Robot tests.",
" ",
"Linux :-",
"1. Please check if Alt-Gr key is present on keyboard.",