/*
@test %I% %E%
@bug 6315717
@summary verifies that InputEvents button masks arrays are the same
@author Andrei Dmitriev : area=awt.event
@run main ButtonArraysEquality
*/
// get array InputEvent.BUTTON_MASK via reflection
// get array InputEvent.BUTTON_DOWN_MASK via reflection
// compare their lengths and values
public class ButtonArraysEquality {
static int [] eventDownMask = new int []{InputEvent.BUTTON1_DOWN_MASK, InputEvent.BUTTON2_DOWN_MASK, InputEvent.BUTTON3_DOWN_MASK};
}
// getButtonDownMasks()
new PrivilegedAction() {
try {
method.setAccessible(true);
}
}catch (Exception e){
throw new RuntimeException("Test failed. Exception occured:", e);
}
return null;
}
});
//check lengths: array shouldn't contain less elements then the number of buttons on a mouse
throw new RuntimeException("Test failed. The lengths array is less then the number of buttons");
}
// verify values for first three buttons
for (int i = 0; i < 3; i++) {
if (eventDownMask[i] != buttonDownMasks[i])
{
throw new RuntimeException("Failure: masks are not correct for standard buttons");
}
}
// verify values for extra buttons if any
if (buttonDownMasksAPI[i] != buttonDownMasks[i]) {
throw new RuntimeException("Failure: masks are not the same for extra buttons");
}
}
}
}
}
}
}