/*
@test %I% %E%
@bug 6315717
@summary verifies that modifiers are correct for extra buttons
@author Andrei Dmitriev : area=awt.mouse
@run main MouseModifiersUnitTest_Extra
*/
// will process extra buttons only
static int [] mouseButtonDownMasks;
//an arrays representing a modifiersEx of extra mouse buttons while using ALT/CTRL/SHIFT or none of them
static int [] modifiersExStandard;
static int [] modifiersExStandardSHIFT;
static int [] modifiersExStandardCTRL;
static int [] modifiersExStandardALT;
// BUTTON1, 2, 3 press-release.
if (modifiers != modifiersStandard){
}
// System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
}
//check event.paramString() output
}
switch (testModifier){
case SHIFT:{
ethalon = "Shift";
break;
}
case ALT:{
ethalon = "Alt";
break;
}
case CTRL:{
ethalon = "Ctrl";
break;
}
}
//
}
MessageLogger.reportError("Test failed : Released/Clicked. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
}
}
switch (testModifier){
case SHIFT:{
ethalon = "Shift+";
break;
}
case ALT:{
ethalon = "Alt+";
break;
}
case CTRL:{
ethalon = "Ctrl+";
break;
}
}
MessageLogger.reportError("Test failed : Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
}
}
// none of modifiers for extra button should be null
}
}
}
MessageLogger.reportError("Test failed : checkButton. button in paramString() doesn't equal to button being pressed.");
}
}
while (st.hasMoreTokens()){
// System.out.println("PARSER : "+tmp);
}
}
return params;
}
while (st.hasMoreTokens()){
}
return modifiers;
}
if (modifiers != modifiersStandard){
}
MessageLogger.reportError("Test failed : Released. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
}
//check event.paramString() output
}
if (modifiers != modifiersStandard){
}
MessageLogger.reportError("Test failed : Clicked. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
}
//check event.paramString() output
}
int [] curStandardExModifiers;
switch (testModifier){
case SHIFT:
break;
case CTRL:
break;
case ALT:
break;
default: //NONE by default
}
return curStandardExModifiers;
}
public void init() {
this.setLayout(new BorderLayout());
String[] instructions =
{
"This test should be used with the mouse having more then three buttons.",
"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 {
} catch (Exception e) {
}
}//End init()
public void start() {
//Get things going. Request focus, set size, et cetera
setVisible(true);
validate();
if (autorun) {
testNONE();
testSHIFT();
testCTRL();
testALT();
} else {
switch (testModifier){
case SHIFT:
this.addMouseListener(adapterTest2);
break;
case CTRL:
this.addMouseListener(adapterTest3);
break;
case ALT:
this.addMouseListener(adapterTest4);
break;
default: //NONE by default
this.addMouseListener(adapterTest1);
}
}
}// start()
//000000000000000000000000000000000000000000000000000000000000000
public void testNONE(){
this.addMouseListener(adapterTest1);
}
this.removeMouseListener(adapterTest1);
}
public void testSHIFT(){
this.addMouseListener(adapterTest2);
}
this.removeMouseListener(adapterTest2);
}
public void testCTRL(){
this.addMouseListener(adapterTest3);
}
this.removeMouseListener(adapterTest3);
}
public void testALT(){
this.addMouseListener(adapterTest4);
}
this.removeMouseListener(adapterTest4);
}
//**************************************************************************************************
public static void dumpValues(int button, int modifiers, int modifiersStandard, int modifiersEx, int modifiersExStandard){
System.out.println("Button = "+button + "Modifiers = "+ modifiers + "standard = "+ modifiersStandard);
System.out.println("Button = "+button + "ModifiersEx = "+ modifiersEx + "standardEx = "+ modifiersExStandard);
}
if (s.length != 3){
autorun = true;
debug = false;
testModifier = NONE;
} else {
testModifier = NONE;
}
}
testModifier = CTRL;
}
testModifier = ALT;
}
}
}
public static void initAdapters(){
}
public static void initVars(){
//Init the array of the mouse button masks. It will be used for generating mouse events.
}
// So we need to get the number of extra buttons on the mouse: "MouseInfo.getNumberOfButtons() - 3"
// and multyply on 3 because each button will generate three events : PRESS, RELEASE and CLICK.
//Fill array of expected results for the case when mouse buttons are only used (no-modifier keys)
tmp[i] = mouseButtonDownMasks[j];
}
//Fill array of expected results for the case when mouse buttons are only used with SHIFT modifier key
System.out.println("modifiersExStandardSHIFT FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]);
}
//Fill array of expected results for the case when mouse buttons are only used with CTRL modifier key
System.out.println("modifiersExStandardCTRL FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]);
}
//Fill array of expected results for the case when mouse buttons are only used with ALT modifier key
}
}
System.out.println("There are less then 4 buttons on the mouse. The test may not be accomplished. Skipping.");
return;
}
initVars();
frame.initParams(s);
initAdapters();
}
}// class
/* A class that invoke appropriate verification
* routine with current modifier.
*/
int modifier;
}
} else {
}
}
} else {
}
}
} else {
}
}
}
//Utility class that could report a message depending on current purpose of the test run
class MessageLogger{
private static boolean debug;
public static void setDebug(boolean d){
debug = d;
}
}
if (debug){
} else {
throw new RuntimeException(message);
}
}
}