author | serb |
Tue, 12 Nov 2013 20:24:25 +0400 | |
changeset 21596 | 0e3a39f29dbc |
parent 6643 | 38c5b164e76b |
child 21932 | 1588ae1fa2f9 |
permissions | -rw-r--r-- |
21596 | 1 |
/* |
2 |
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 |
||
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
24 |
/* |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
25 |
@test %I% %E% |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
26 |
@bug 6315717 |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
27 |
@summary verifies that modifiers are correct for extra buttons |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
28 |
@author Andrei Dmitriev : area=awt.mouse |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
29 |
@run main MouseModifiersUnitTest_Extra |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
30 |
*/ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
31 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
32 |
import java.awt.*; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
33 |
import java.awt.event.*; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
34 |
import java.util.Arrays; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
35 |
import java.util.HashMap; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
36 |
import java.util.StringTokenizer; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
37 |
import java.util.Vector; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
38 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
39 |
// will process extra buttons only |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
40 |
// asking parameters from CMD: manual/automatic, modifier to test |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
41 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
42 |
public class MouseModifiersUnitTest_Extra extends Frame { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
43 |
static final int NONE = 0; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
44 |
static final int SHIFT = 1; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
45 |
static final int CTRL = 2; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
46 |
static final int ALT = 3; |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
47 |
static CheckingModifierAdapterExtra adapterTest1; |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
48 |
static CheckingModifierAdapterExtra adapterTest2; |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
49 |
static CheckingModifierAdapterExtra adapterTest3; |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
50 |
static CheckingModifierAdapterExtra adapterTest4; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
51 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
52 |
static boolean debug = true; //dump all errors (debug) or throw first(under jtreg) exception |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
53 |
static boolean autorun = false; //use robot or manual run |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
54 |
static int testModifier = NONE; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
55 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
56 |
static int [] mouseButtonDownMasks; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
57 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
58 |
//an arrays representing a modifiersEx of extra mouse buttons while using ALT/CTRL/SHIFT or none of them |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
59 |
static int [] modifiersExStandard; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
60 |
static int [] modifiersExStandardSHIFT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
61 |
static int [] modifiersExStandardCTRL; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
62 |
static int [] modifiersExStandardALT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
63 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
64 |
// BUTTON1, 2, 3 press-release. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
65 |
final static int modifiersStandard = 0; //InputEvent.BUTTON_DOWN_MASK; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
66 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
67 |
public static void checkPressedModifiersTest(int testModifier, MouseEvent event){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
68 |
int [] curStandardExModifiers = getStandardExArray(testModifier); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
69 |
int button = event.getButton(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
70 |
int modifiers = event.getModifiers(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
71 |
int modifiersEx = event.getModifiersEx(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
72 |
int index = (button - 4)*3; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
73 |
dumpValues(button, modifiers, modifiersStandard, modifiersEx, curStandardExModifiers[index]); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
74 |
if (modifiers != modifiersStandard){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
75 |
MessageLogger.reportError("Test failed : Pressed. modifiers != modifiersStandard"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
76 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
77 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
78 |
if (modifiersEx != curStandardExModifiers[index]){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
79 |
// System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers"); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
80 |
MessageLogger.reportError("Test failed : Pressed. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
81 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
82 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
83 |
//check event.paramString() output |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
84 |
HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
85 |
System.out.println(event.paramString()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
86 |
checkButton(paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
87 |
checkModifiers(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
88 |
checkExtModifiersOnPress(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
89 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
90 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
91 |
public static void checkExtModifiersOnReleaseClick(int testModifier, HashMap h, int button){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
92 |
String ethalon = ""; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
93 |
switch (testModifier){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
94 |
case SHIFT:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
95 |
ethalon = "Shift"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
96 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
97 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
98 |
case ALT:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
99 |
ethalon = "Alt"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
100 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
101 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
102 |
case CTRL:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
103 |
ethalon = "Ctrl"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
104 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
105 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
106 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
107 |
// |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
108 |
if (h.get("extModifiers") == null){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
109 |
h.put("extModifiers", ""); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
110 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
111 |
if (!ethalon.equals(h.get("extModifiers"))) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
112 |
MessageLogger.reportError("Test failed : Released/Clicked. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
113 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
114 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
115 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
116 |
public static void checkExtModifiersOnPress(int testModifier, HashMap h, int button){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
117 |
String ethalon = ""; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
118 |
switch (testModifier){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
119 |
case SHIFT:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
120 |
ethalon = "Shift+"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
121 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
122 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
123 |
case ALT:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
124 |
ethalon = "Alt+"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
125 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
126 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
127 |
case CTRL:{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
128 |
ethalon = "Ctrl+"; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
129 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
130 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
131 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
132 |
ethalon = ethalon + "Button" +button; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
133 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
134 |
if (!h.get("extModifiers").equals(ethalon)) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
135 |
MessageLogger.reportError("Test failed : Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
136 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
137 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
138 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
139 |
public static void checkModifiers(int testModifier, HashMap<String, String> h, int button){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
140 |
// none of modifiers for extra button should be null |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
141 |
if (h.get("modifiers") != null) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
142 |
MessageLogger.reportError("Test failed : modifiers != null"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
143 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
144 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
145 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
146 |
public static void checkButton(HashMap<String, String> h, int button){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
147 |
if (h.get("button") == null) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
148 |
MessageLogger.reportError("Test failed : checkButton(). button is absent in paramString()"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
149 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
150 |
if (Integer.parseInt(h.get("button")) != button) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
151 |
MessageLogger.reportError("Test failed : checkButton. button in paramString() doesn't equal to button being pressed."); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
152 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
153 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
154 |
public static HashMap<String, String> tokenizeParamString(String param){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
155 |
HashMap <String, String> params = new HashMap<String, String>(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
156 |
StringTokenizer st = new StringTokenizer(param, ",="); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
157 |
while (st.hasMoreTokens()){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
158 |
String tmp = st.nextToken(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
159 |
// System.out.println("PARSER : "+tmp); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
160 |
if (tmp.equals("button") || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
161 |
tmp.equals("modifiers") || |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
162 |
tmp.equals("extModifiers")) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
163 |
params.put(tmp, st.nextToken()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
164 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
165 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
166 |
return params; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
167 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
168 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
169 |
public static Vector<String> tokenizeModifiers(String modifierList){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
170 |
Vector<String> modifiers = new Vector<String>(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
171 |
StringTokenizer st = new StringTokenizer(modifierList, "+"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
172 |
while (st.hasMoreTokens()){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
173 |
String tmp = st.nextToken(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
174 |
modifiers.addElement(tmp); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
175 |
System.out.println("MODIFIER PARSER : "+tmp); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
176 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
177 |
return modifiers; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
178 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
179 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
180 |
public static void checkReleasedModifiersTest(int testModifier, MouseEvent event){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
181 |
int [] curStandardExModifiers = getStandardExArray(testModifier); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
182 |
int button = event.getButton(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
183 |
int modifiers = event.getModifiers(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
184 |
int modifiersEx = event.getModifiersEx(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
185 |
int index = (button - 4)*3 + 1; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
186 |
dumpValues(button, modifiers, modifiersStandard, modifiersEx, curStandardExModifiers[index]); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
187 |
if (modifiers != modifiersStandard){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
188 |
MessageLogger.reportError("Test failed : Released. modifiers != modifiersStandard"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
189 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
190 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
191 |
if (modifiersEx != curStandardExModifiers[index]){ |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
192 |
MessageLogger.reportError("Test failed : Released. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
193 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
194 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
195 |
//check event.paramString() output |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
196 |
HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
197 |
checkButton(paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
198 |
checkModifiers(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
199 |
System.out.println("paramStringElements = "+paramStringElements); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
200 |
checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
201 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
202 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
203 |
public static void checkClickedModifiersTest(int testModifier, MouseEvent event){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
204 |
int [] curStandardExModifiers = getStandardExArray(testModifier); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
205 |
int button = event.getButton(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
206 |
int modifiers = event.getModifiers(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
207 |
int modifiersEx = event.getModifiersEx(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
208 |
int index = (button - 4)*3 + 2; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
209 |
dumpValues(button, modifiers, modifiersStandard, modifiersEx, curStandardExModifiers[index]); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
210 |
if (modifiers != modifiersStandard){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
211 |
MessageLogger.reportError("Test failed : Clicked. modifiers != modifiersStandard"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
212 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
213 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
214 |
if (modifiersEx != curStandardExModifiers[index]){ |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
215 |
MessageLogger.reportError("Test failed : Clicked. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
216 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
217 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
218 |
//check event.paramString() output |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
219 |
HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
220 |
checkButton(paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
221 |
checkModifiers(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
222 |
checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
223 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
224 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
225 |
private static int[] getStandardExArray(int testModifier) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
226 |
int [] curStandardExModifiers; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
227 |
switch (testModifier){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
228 |
case SHIFT: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
229 |
curStandardExModifiers = modifiersExStandardSHIFT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
230 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
231 |
case CTRL: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
232 |
curStandardExModifiers = modifiersExStandardCTRL; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
233 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
234 |
case ALT: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
235 |
curStandardExModifiers = modifiersExStandardALT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
236 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
237 |
default: //NONE by default |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
238 |
curStandardExModifiers = modifiersExStandard; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
239 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
240 |
return curStandardExModifiers; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
241 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
242 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
243 |
static Robot robot; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
244 |
public void init() { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
245 |
this.setLayout(new BorderLayout()); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
246 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
247 |
String[] instructions = |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
248 |
{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
249 |
"This test should be used with the mouse having more then three buttons.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
250 |
"Currently, " + MouseInfo.getNumberOfButtons() +" buttons are available.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
251 |
"If there are less then three buttons, press PASS.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
252 |
"1. Press each extra mouse button.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
253 |
"2. For each mouse event its modifiers and ExModifiers will be printed.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
254 |
"3. Verify that they are correct.", |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
255 |
"4. Press Pass or Fail accordingly." |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
256 |
}; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
257 |
// Sysout.createDialogWithInstructions( instructions ); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
258 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
259 |
// addMouseListener(adapterTest1); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
260 |
try { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
261 |
robot = new Robot(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
262 |
} catch (Exception e) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
263 |
MessageLogger.reportError("Test failed. "+e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
264 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
265 |
}//End init() |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
266 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
267 |
public void start() { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
268 |
//Get things going. Request focus, set size, et cetera |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
269 |
setSize(200,200); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
270 |
setVisible(true); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
271 |
validate(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
272 |
if (autorun) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
273 |
testNONE(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
274 |
testSHIFT(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
275 |
testCTRL(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
276 |
testALT(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
277 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
278 |
switch (testModifier){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
279 |
case SHIFT: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
280 |
this.addMouseListener(adapterTest2); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
281 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
282 |
case CTRL: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
283 |
this.addMouseListener(adapterTest3); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
284 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
285 |
case ALT: |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
286 |
this.addMouseListener(adapterTest4); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
287 |
break; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
288 |
default: //NONE by default |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
289 |
this.addMouseListener(adapterTest1); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
290 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
291 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
292 |
}// start() |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
293 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
294 |
//000000000000000000000000000000000000000000000000000000000000000 |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
295 |
public void testNONE(){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
296 |
this.addMouseListener(adapterTest1); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
297 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
298 |
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
299 |
for (int i = 3; i< mouseButtonDownMasks.length; i++){ |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
300 |
System.out.println("testNONE() => " +mouseButtonDownMasks[i] ); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
301 |
robot.mousePress(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
302 |
robot.delay(100); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
303 |
robot.mouseRelease(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
304 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
305 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
306 |
this.removeMouseListener(adapterTest1); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
307 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
308 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
309 |
public void testSHIFT(){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
310 |
this.addMouseListener(adapterTest2); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
311 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
312 |
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
313 |
for (int i = 3; i< mouseButtonDownMasks.length; i++){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
314 |
robot.keyPress(KeyEvent.VK_SHIFT); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
315 |
System.out.println("testSHIFT() => " +mouseButtonDownMasks[i] ); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
316 |
robot.mousePress(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
317 |
robot.delay(100); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
318 |
robot.mouseRelease(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
319 |
robot.keyRelease(KeyEvent.VK_SHIFT); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
320 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
321 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
322 |
this.removeMouseListener(adapterTest2); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
323 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
324 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
325 |
public void testCTRL(){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
326 |
this.addMouseListener(adapterTest3); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
327 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
328 |
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
329 |
for (int i = 3; i< mouseButtonDownMasks.length; i++){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
330 |
robot.keyPress(KeyEvent.VK_CONTROL); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
331 |
System.out.println("testCTRL() => " +mouseButtonDownMasks[i] ); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
332 |
robot.mousePress(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
333 |
robot.delay(100); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
334 |
robot.mouseRelease(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
335 |
robot.keyRelease(KeyEvent.VK_CONTROL); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
336 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
337 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
338 |
this.removeMouseListener(adapterTest3); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
339 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
340 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
341 |
public void testALT(){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
342 |
this.addMouseListener(adapterTest4); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
343 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
344 |
robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
345 |
for (int i = 3; i< mouseButtonDownMasks.length; i++){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
346 |
robot.keyPress(KeyEvent.VK_ALT); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
347 |
System.out.println("testALT() => " +mouseButtonDownMasks[i] ); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
348 |
robot.mousePress(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
349 |
robot.delay(100); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
350 |
robot.mouseRelease(mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
351 |
robot.keyRelease(KeyEvent.VK_ALT); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
352 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
353 |
robot.delay(1000); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
354 |
this.removeMouseListener(adapterTest4); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
355 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
356 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
357 |
//************************************************************************************************** |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
358 |
public static void dumpValues(int button, int modifiers, int modifiersStandard, int modifiersEx, int modifiersExStandard){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
359 |
System.out.println("Button = "+button + "Modifiers = "+ modifiers + "standard = "+ modifiersStandard); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
360 |
System.out.println("Button = "+button + "ModifiersEx = "+ modifiersEx + "standardEx = "+ modifiersExStandard); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
361 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
362 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
363 |
public static void initParams(String []s){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
364 |
if (s.length != 3){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
365 |
autorun = true; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
366 |
debug = false; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
367 |
testModifier = NONE; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
368 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
369 |
autorun = Boolean.valueOf(s[0]); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
370 |
debug = Boolean.valueOf(s[1]); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
371 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
372 |
if (s[2].equals("NONE")){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
373 |
testModifier = NONE; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
374 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
375 |
if (s[2].equals("SHIFT")){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
376 |
testModifier = SHIFT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
377 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
378 |
if (s[2].equals("CTRL")){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
379 |
testModifier = CTRL; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
380 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
381 |
if (s[2].equals("ALT")){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
382 |
testModifier = ALT; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
383 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
384 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
385 |
MessageLogger.setDebug(debug); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
386 |
System.out.println("Autorun : " +autorun); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
387 |
System.out.println("Debug mode : " +debug); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
388 |
System.out.println("Modifier to verify : " + testModifier); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
389 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
390 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
391 |
public static void initAdapters(){ |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
392 |
adapterTest1 = new CheckingModifierAdapterExtra(NONE); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
393 |
adapterTest2 = new CheckingModifierAdapterExtra(SHIFT); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
394 |
adapterTest3 = new CheckingModifierAdapterExtra(CTRL); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
395 |
adapterTest4 = new CheckingModifierAdapterExtra(ALT); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
396 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
397 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
398 |
public static void initVars(){ |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
399 |
//Init the array of the mouse button masks. It will be used for generating mouse events. |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
400 |
mouseButtonDownMasks = new int [MouseInfo.getNumberOfButtons()]; |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
401 |
for (int i = 0; i < mouseButtonDownMasks.length; i++){ |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
402 |
mouseButtonDownMasks[i] = InputEvent.getMaskForButton(i+1); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
403 |
System.out.println("MouseArray [i] == "+mouseButtonDownMasks[i]); |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
404 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
405 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
406 |
// So we need to get the number of extra buttons on the mouse: "MouseInfo.getNumberOfButtons() - 3" |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
407 |
// and multyply on 3 because each button will generate three events : PRESS, RELEASE and CLICK. |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
408 |
int [] tmp = new int [(MouseInfo.getNumberOfButtons()-3)*3]; |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
409 |
|
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
410 |
//Fill array of expected results for the case when mouse buttons are only used (no-modifier keys) |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
411 |
Arrays.fill(tmp, 0); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
412 |
for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
413 |
tmp[i] = mouseButtonDownMasks[j]; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
414 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
415 |
modifiersExStandard = Arrays.copyOf(tmp, tmp.length); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
416 |
|
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
417 |
//Fill array of expected results for the case when mouse buttons are only used with SHIFT modifier key |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
418 |
Arrays.fill(tmp, InputEvent.SHIFT_DOWN_MASK); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
419 |
for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){ |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
420 |
System.out.println("modifiersExStandardSHIFT FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
421 |
tmp[i] = tmp[i] | mouseButtonDownMasks[j]; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
422 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
423 |
modifiersExStandardSHIFT = Arrays.copyOf(tmp, tmp.length); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
424 |
|
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
425 |
//Fill array of expected results for the case when mouse buttons are only used with CTRL modifier key |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
426 |
Arrays.fill(tmp, InputEvent.CTRL_DOWN_MASK); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
427 |
for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){ |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
428 |
System.out.println("modifiersExStandardCTRL FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
429 |
tmp[i] = tmp[i] | mouseButtonDownMasks[j]; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
430 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
431 |
modifiersExStandardCTRL = Arrays.copyOf(tmp, tmp.length); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
432 |
|
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
433 |
//Fill array of expected results for the case when mouse buttons are only used with ALT modifier key |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
434 |
Arrays.fill(tmp, InputEvent.ALT_DOWN_MASK); |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
435 |
for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){ |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
436 |
System.out.println("modifiersExStandardALT FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]); |
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
437 |
tmp[i] = tmp[i] | mouseButtonDownMasks[j]; |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
438 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
439 |
modifiersExStandardALT = Arrays.copyOf(tmp, tmp.length); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
440 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
441 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
442 |
public static void main(String []s){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
443 |
if (MouseInfo.getNumberOfButtons() < 4){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
444 |
System.out.println("There are less then 4 buttons on the mouse. The test may not be accomplished. Skipping."); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
445 |
return; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
446 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
447 |
initVars(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
448 |
MouseModifiersUnitTest_Extra frame = new MouseModifiersUnitTest_Extra(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
449 |
frame.initParams(s); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
450 |
frame.init(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
451 |
initAdapters(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
452 |
frame.start(); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
453 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
454 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
455 |
}// class |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
456 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
457 |
/* A class that invoke appropriate verification |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
458 |
* routine with current modifier. |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
459 |
*/ |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
460 |
class CheckingModifierAdapterExtra extends MouseAdapter{ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
461 |
int modifier; |
6643
38c5b164e76b
6847155: test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java fails
dav
parents:
1962
diff
changeset
|
462 |
public CheckingModifierAdapterExtra(int modifier){ |
1962
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
463 |
this.modifier = modifier; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
464 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
465 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
466 |
public void mousePressed(MouseEvent e) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
467 |
System.out.println("PRESSED "+e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
468 |
if (e.getButton() <= MouseEvent.BUTTON3) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
469 |
System.out.println("Standard button affected. Skip."); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
470 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
471 |
MouseModifiersUnitTest_Extra.checkPressedModifiersTest(modifier, e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
472 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
473 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
474 |
public void mouseReleased(MouseEvent e) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
475 |
System.out.println("RELEASED "+e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
476 |
if (e.getButton() <= MouseEvent.BUTTON3) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
477 |
System.out.println("Standard button affected. Skip."); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
478 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
479 |
MouseModifiersUnitTest_Extra.checkReleasedModifiersTest(modifier, e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
480 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
481 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
482 |
public void mouseClicked(MouseEvent e) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
483 |
System.out.println("CLICKED "+e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
484 |
if (e.getButton() <= MouseEvent.BUTTON3) { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
485 |
System.out.println("Standard button affected. Skip."); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
486 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
487 |
MouseModifiersUnitTest_Extra.checkClickedModifiersTest(modifier, e); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
488 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
489 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
490 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
491 |
//Utility class that could report a message depending on current purpose of the test run |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
492 |
class MessageLogger{ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
493 |
private static boolean debug; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
494 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
495 |
public static void setDebug(boolean d){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
496 |
debug = d; |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
497 |
log("Switch to "+ ((debug)?"debug":"trial") +" mode"); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
498 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
499 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
500 |
public static void log(String message){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
501 |
System.out.println(message); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
502 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
503 |
|
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
504 |
public static void reportError(String message){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
505 |
if (debug){ |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
506 |
System.out.println(message); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
507 |
} else { |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
508 |
throw new RuntimeException(message); |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
509 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
510 |
} |
6c293d33645b
6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff
changeset
|
511 |
} |