/*
@test %I% %E%
@bug 6315717
@summary verifies that sun.awt.enableExtraMouseButtons = false consumes extra events
@author Andrei Dmitriev : area=awt.mouse
*/
// Testcase 1: set to FALSE and check
// Testcase 2: set to FALSE and check that extra events are not coming
// check that standard events are coming
static boolean propValue;
static int [] buttonsPressed;
static int [] buttonsReleased;
static int [] buttonsClicked;
static boolean lessThenFourButtons;
frame.setVisible(true);
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
};
try {
robot.mouseMove(frame.getLocationOnScreen().x + frame.getWidth()/2, frame.getLocationOnScreen().y + frame.getHeight()/2);
testCase0();
testCase1();
if ( !lessThenFourButtons ) {
testCase2();
}
} catch (Exception e){
e.printStackTrace();
// throw new RuntimeException(e);
} finally {
// frame.removeMouseListener(ma1);
}
}
public static void testCase0(){
if (propValue){
throw new RuntimeException("TEST FAILED (0): System property sun.awt.enableExtraMouseButtons = " + propValue);
}
}
public static void testCase1(){
throw new RuntimeException("TEST FAILED (1): setting to FALSE. Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() = " + Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled());
}
}
public static void testCase2(){
emptyArrays();
}
try {
//no exception is thrown
if (i >= 3) {
throw new RuntimeException("TESTCASE 2 FAILED : robot accepted the extra button " + (i+1) + " instead of throwing an exception.");
}
} catch (IllegalArgumentException e){
if (i >= 3) {
} else {
throw new RuntimeException("TESTCASE 2 FAILED : exception happen on standard button.", e);
}
}
}
}
}
} else {
for (int i = 0; i < 3; i++){
}
}
}
}
}
}
public static void emptyArrays(){
buttonsPressed[i] = 0;
buttonsReleased[i] = 0;
buttonsClicked[i] = 0;
}
}
}