mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-24 12:28:12 +00:00
7152982: [TEST_BUG][macosx] Extremely unstable mouse modifiers test
Reviewed-by: anthony, serb
This commit is contained in:
parent
27a7aa78e9
commit
ee95a2a1c4
@ -29,6 +29,8 @@
|
||||
@run main MouseModifiersUnitTest_Extra
|
||||
*/
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Arrays;
|
||||
@ -61,6 +63,17 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
static int [] modifiersExStandardCTRL;
|
||||
static int [] modifiersExStandardALT;
|
||||
|
||||
private final static String SHIFT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
|
||||
"\u21e7" : "Shift";
|
||||
|
||||
private final static String ALT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
|
||||
"\u2325" : "Alt";
|
||||
|
||||
|
||||
private final static String CTRL_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
|
||||
"\u2303" : "Ctrl";
|
||||
|
||||
|
||||
// BUTTON1, 2, 3 press-release.
|
||||
final static int modifiersStandard = 0; //InputEvent.BUTTON_DOWN_MASK;
|
||||
|
||||
@ -77,7 +90,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
|
||||
if (modifiersEx != curStandardExModifiers[index]){
|
||||
// System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
|
||||
MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: "
|
||||
+ modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
}
|
||||
|
||||
//check event.paramString() output
|
||||
@ -88,51 +102,54 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
checkExtModifiersOnPress(testModifier, paramStringElements, button);
|
||||
}
|
||||
|
||||
public static void checkExtModifiersOnReleaseClick(int testModifier, HashMap h, int button){
|
||||
public static void checkExtModifiersOnReleaseClick(int testModifier, HashMap<String, String> h, int button){
|
||||
String ethalon = "";
|
||||
switch (testModifier){
|
||||
case SHIFT:{
|
||||
ethalon = "Shift";
|
||||
ethalon = SHIFT_MODIFIER;
|
||||
break;
|
||||
}
|
||||
case ALT:{
|
||||
ethalon = "Alt";
|
||||
ethalon = ALT_MODIFIER;
|
||||
break;
|
||||
}
|
||||
case CTRL:{
|
||||
ethalon = "Ctrl";
|
||||
ethalon = CTRL_MODIFIER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
if (h.get("extModifiers") == null){
|
||||
h.put("extModifiers", "");
|
||||
}
|
||||
|
||||
if (!ethalon.equals(h.get("extModifiers"))) {
|
||||
MessageLogger.reportError("Test failed : Released/Clicked. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
|
||||
MessageLogger.reportError("Test failed : Released/Clicked. extModifiers = "
|
||||
+ h.get("extModifiers") + " instead of : " + ethalon);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkExtModifiersOnPress(int testModifier, HashMap h, int button){
|
||||
public static void checkExtModifiersOnPress(int testModifier, HashMap<String, String> h, int button){
|
||||
String ethalon = "";
|
||||
switch (testModifier){
|
||||
case SHIFT:{
|
||||
ethalon = "Shift+";
|
||||
ethalon = SHIFT_MODIFIER + "+";
|
||||
break;
|
||||
}
|
||||
case ALT:{
|
||||
ethalon = "Alt+";
|
||||
ethalon = ALT_MODIFIER + "+";
|
||||
break;
|
||||
}
|
||||
case CTRL:{
|
||||
ethalon = "Ctrl+";
|
||||
ethalon = CTRL_MODIFIER + "+";
|
||||
break;
|
||||
}
|
||||
}
|
||||
ethalon = ethalon + "Button" +button;
|
||||
|
||||
if (!h.get("extModifiers").equals(ethalon)) {
|
||||
MessageLogger.reportError("Test failed : Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
|
||||
MessageLogger.reportError("Test failed : Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "
|
||||
+ ethalon);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +169,7 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
}
|
||||
}
|
||||
public static HashMap<String, String> tokenizeParamString(String param){
|
||||
HashMap <String, String> params = new HashMap<String, String>();
|
||||
HashMap <String, String> params = new HashMap<>();
|
||||
StringTokenizer st = new StringTokenizer(param, ",=");
|
||||
while (st.hasMoreTokens()){
|
||||
String tmp = st.nextToken();
|
||||
@ -167,7 +184,7 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
}
|
||||
|
||||
public static Vector<String> tokenizeModifiers(String modifierList){
|
||||
Vector<String> modifiers = new Vector<String>();
|
||||
Vector<String> modifiers = new Vector<>();
|
||||
StringTokenizer st = new StringTokenizer(modifierList, "+");
|
||||
while (st.hasMoreTokens()){
|
||||
String tmp = st.nextToken();
|
||||
@ -189,7 +206,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
}
|
||||
|
||||
if (modifiersEx != curStandardExModifiers[index]){
|
||||
MessageLogger.reportError("Test failed : Released. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
MessageLogger.reportError("Test failed : Released. modifiersEx != curStandardExModifiers. Got: "
|
||||
+ modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
}
|
||||
|
||||
//check event.paramString() output
|
||||
@ -212,7 +230,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
}
|
||||
|
||||
if (modifiersEx != curStandardExModifiers[index]){
|
||||
MessageLogger.reportError("Test failed : Clicked. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
MessageLogger.reportError("Test failed : Clicked. modifiersEx != curStandardExModifiers. Got: "
|
||||
+ modifiersEx + " , Expected: " + curStandardExModifiers[index]);
|
||||
}
|
||||
|
||||
//check event.paramString() output
|
||||
@ -243,22 +262,10 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
static Robot robot;
|
||||
public void init() {
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
String[] instructions =
|
||||
{
|
||||
"This test should be used with the mouse having more then three buttons.",
|
||||
"Currently, " + MouseInfo.getNumberOfButtons() +" buttons are available.",
|
||||
"If there are less then three buttons, press PASS.",
|
||||
"1. Press each extra mouse button.",
|
||||
"2. For each mouse event its modifiers and ExModifiers will be printed.",
|
||||
"3. Verify that they are correct.",
|
||||
"4. Press Pass or Fail accordingly."
|
||||
};
|
||||
// Sysout.createDialogWithInstructions( instructions );
|
||||
|
||||
// addMouseListener(adapterTest1);
|
||||
try {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
robot.setAutoWaitForIdle(true);
|
||||
} catch (Exception e) {
|
||||
MessageLogger.reportError("Test failed. "+e);
|
||||
}
|
||||
@ -297,9 +304,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
robot.delay(1000);
|
||||
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
|
||||
for (int i = 3; i< mouseButtonDownMasks.length; i++){
|
||||
System.out.println("testNONE() => " +mouseButtonDownMasks[i] );
|
||||
System.out.println("testNONE() => " + mouseButtonDownMasks[i]);
|
||||
robot.mousePress(mouseButtonDownMasks[i]);
|
||||
robot.delay(100);
|
||||
robot.mouseRelease(mouseButtonDownMasks[i]);
|
||||
}
|
||||
robot.delay(1000);
|
||||
@ -312,9 +318,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
|
||||
for (int i = 3; i< mouseButtonDownMasks.length; i++){
|
||||
robot.keyPress(KeyEvent.VK_SHIFT);
|
||||
System.out.println("testSHIFT() => " +mouseButtonDownMasks[i] );
|
||||
System.out.println("testSHIFT() => " + mouseButtonDownMasks[i]);
|
||||
robot.mousePress(mouseButtonDownMasks[i]);
|
||||
robot.delay(100);
|
||||
robot.mouseRelease(mouseButtonDownMasks[i]);
|
||||
robot.keyRelease(KeyEvent.VK_SHIFT);
|
||||
}
|
||||
@ -328,9 +333,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
|
||||
for (int i = 3; i< mouseButtonDownMasks.length; i++){
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
System.out.println("testCTRL() => " +mouseButtonDownMasks[i] );
|
||||
System.out.println("testCTRL() => " + mouseButtonDownMasks[i]);
|
||||
robot.mousePress(mouseButtonDownMasks[i]);
|
||||
robot.delay(100);
|
||||
robot.mouseRelease(mouseButtonDownMasks[i]);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
@ -344,9 +348,8 @@ public class MouseModifiersUnitTest_Extra extends Frame {
|
||||
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
|
||||
for (int i = 3; i< mouseButtonDownMasks.length; i++){
|
||||
robot.keyPress(KeyEvent.VK_ALT);
|
||||
System.out.println("testALT() => " +mouseButtonDownMasks[i] );
|
||||
System.out.println("testALT() => " + mouseButtonDownMasks[i]);
|
||||
robot.mousePress(mouseButtonDownMasks[i]);
|
||||
robot.delay(100);
|
||||
robot.mouseRelease(mouseButtonDownMasks[i]);
|
||||
robot.keyRelease(KeyEvent.VK_ALT);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user