10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 @test %I% %E%
26 @key headful
27 @bug 6315717
28 @summary verifies that modifiers are correct for extra buttons
29 @author Andrei Dmitriev : area=awt.mouse
30 @library ../../../../lib/testlibrary
31 @build jdk.testlibrary.OSInfo
32 @run main MouseModifiersUnitTest_Extra
33 */
34
35 import jdk.testlibrary.OSInfo;
36
37 import java.awt.*;
38 import java.awt.event.*;
39 import java.util.Arrays;
40 import java.util.HashMap;
41 import java.util.StringTokenizer;
42 import java.util.Vector;
43
44 // will process extra buttons only
45 // asking parameters from CMD: manual/automatic, modifier to test
46
47 public class MouseModifiersUnitTest_Extra extends Frame {
48 static final int NONE = 0;
49 static final int SHIFT = 1;
50 static final int CTRL = 2;
51 static final int ALT = 3;
52 static CheckingModifierAdapterExtra adapterTest1;
53 static CheckingModifierAdapterExtra adapterTest2;
54 static CheckingModifierAdapterExtra adapterTest3;
55 static CheckingModifierAdapterExtra adapterTest4;
56
57 static boolean debug = true; //dump all errors (debug) or throw first(under jtreg) exception
58 static boolean autorun = false; //use robot or manual run
59 static int testModifier = NONE;
60
61 static int [] mouseButtonDownMasks;
62
63 //an arrays representing a modifiersEx of extra mouse buttons while using ALT/CTRL/SHIFT or none of them
64 static int [] modifiersExStandard;
65 static int [] modifiersExStandardSHIFT;
66 static int [] modifiersExStandardCTRL;
67 static int [] modifiersExStandardALT;
68
69 private final static String SHIFT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
70 "\u21e7" : "Shift";
71
72 private final static String ALT_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
73 "\u2325" : "Alt";
74
75
76 private final static String CTRL_MODIFIER = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ?
77 "\u2303" : "Ctrl";
78
79
80 // BUTTON1, 2, 3 press-release.
81 final static int modifiersStandard = 0; //InputEvent.BUTTON_DOWN_MASK;
82
83 public static void checkPressedModifiersTest(int testModifier, MouseEvent event){
84 int [] curStandardExModifiers = getStandardExArray(testModifier);
85 int button = event.getButton();
86 int modifiers = event.getModifiers();
87 int modifiersEx = event.getModifiersEx();
88 int index = (button - 4)*3;
89 dumpValues(button, modifiers, modifiersStandard, modifiersEx, curStandardExModifiers[index]);
90 if (modifiers != modifiersStandard){
91 MessageLogger.reportError("Test failed : Pressed. modifiers != modifiersStandard");
92 }
93
94 if (modifiersEx != curStandardExModifiers[index]){
95 // System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
96 MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: "
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 @test %I% %E%
26 @key headful
27 @bug 6315717
28 @summary verifies that modifiers are correct for extra buttons
29 @author Andrei Dmitriev : area=awt.mouse
30 @library /test/lib
31 @build jdk.test.lib.Platform
32 @run main MouseModifiersUnitTest_Extra
33 */
34
35 import jdk.test.lib.Platform;
36
37 import java.awt.*;
38 import java.awt.event.*;
39 import java.util.Arrays;
40 import java.util.HashMap;
41 import java.util.StringTokenizer;
42 import java.util.Vector;
43
44 // will process extra buttons only
45 // asking parameters from CMD: manual/automatic, modifier to test
46
47 public class MouseModifiersUnitTest_Extra extends Frame {
48 static final int NONE = 0;
49 static final int SHIFT = 1;
50 static final int CTRL = 2;
51 static final int ALT = 3;
52 static CheckingModifierAdapterExtra adapterTest1;
53 static CheckingModifierAdapterExtra adapterTest2;
54 static CheckingModifierAdapterExtra adapterTest3;
55 static CheckingModifierAdapterExtra adapterTest4;
56
57 static boolean debug = true; //dump all errors (debug) or throw first(under jtreg) exception
58 static boolean autorun = false; //use robot or manual run
59 static int testModifier = NONE;
60
61 static int [] mouseButtonDownMasks;
62
63 //an arrays representing a modifiersEx of extra mouse buttons while using ALT/CTRL/SHIFT or none of them
64 static int [] modifiersExStandard;
65 static int [] modifiersExStandardSHIFT;
66 static int [] modifiersExStandardCTRL;
67 static int [] modifiersExStandardALT;
68
69 private final static String SHIFT_MODIFIER = Platform.isOSX() ?
70 "\u21e7" : "Shift";
71
72 private final static String ALT_MODIFIER = Platform.isOSX() ?
73 "\u2325" : "Alt";
74
75
76 private final static String CTRL_MODIFIER = Platform.isOSX() ?
77 "\u2303" : "Ctrl";
78
79
80 // BUTTON1, 2, 3 press-release.
81 final static int modifiersStandard = 0; //InputEvent.BUTTON_DOWN_MASK;
82
83 public static void checkPressedModifiersTest(int testModifier, MouseEvent event){
84 int [] curStandardExModifiers = getStandardExArray(testModifier);
85 int button = event.getButton();
86 int modifiers = event.getModifiers();
87 int modifiersEx = event.getModifiersEx();
88 int index = (button - 4)*3;
89 dumpValues(button, modifiers, modifiersStandard, modifiersEx, curStandardExModifiers[index]);
90 if (modifiers != modifiersStandard){
91 MessageLogger.reportError("Test failed : Pressed. modifiers != modifiersStandard");
92 }
93
94 if (modifiersEx != curStandardExModifiers[index]){
95 // System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
96 MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: "
|