File: MouseModifiersUnitTest_Standard.java

package info (click to toggle)
openjdk-11 11.0.4%2B11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 757,028 kB
  • sloc: java: 5,016,041; xml: 1,191,974; cpp: 934,731; ansic: 555,697; sh: 24,299; objc: 12,703; python: 3,602; asm: 3,415; makefile: 2,772; awk: 351; sed: 172; perl: 114; jsp: 24; csh: 3
file content (622 lines) | stat: -rw-r--r-- 28,103 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
/*
 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

/*
  @test %I% %E%
  @key headful
  @bug 6315717
  @summary verifies that modifiers are correct for standard (1, 2, 3, wheel) mouse buttons
  @author Andrei Dmitriev : area=awt.mouse
  @run main MouseModifiersUnitTest_Standard
 */

import java.awt.*;
import java.awt.event.*;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.Vector;

//the test verifies:
// 1) verifies that modifiers are correct for standard (1, 2, 3) mouse buttons
// TODO: 2) verifies that modifiers are correct for wheel
// TODO: 3)
// Case1. the test posts BUTTONx_MASK and verifies that paramString() contains correct modifiers and exModifiers
// Case2. the test posts BUTTONx_DOWN_MASK and verifies that paramString() contains correct modifiers and exModifiers
// Case3. the test posts getMaskForButton(n) and verifies that paramString() contains correct modifiers and exModifiers
// repeat all cases with SHIFT/ALT/CTRL modifiers verify that paramString() contains correct modifiers and exModifiers
// I'm verifying button, modifiers and extModifiers for now.

public class MouseModifiersUnitTest_Standard {
    static final int NONE = 0;
    static final int SHIFT = 1;
    static final int CTRL = 2;
    static final int ALT = 3;
    static boolean debug = true; //dump all errors (debug) or throw first(under jtreg) exception
    static boolean autorun = false; //use robot or manual run
    static int testModifier = NONE;
    //    static String testModifier = "NONE";
    static CheckingModifierAdapter adapterTest1;
    static CheckingModifierAdapter adapterTest2;
    static CheckingModifierAdapter adapterTest3;
    static CheckingModifierAdapter adapterTest4;
    static Frame f;
    final static int [] mouseButtons = new int [] {MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON2_MASK, MouseEvent.BUTTON3_MASK};
    // BUTTON1, 2, 3 press-release.
    final static int [] modifiersStandardTestNONE = new int[] {MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK,
    MouseEvent.BUTTON2_MASK, MouseEvent.BUTTON2_MASK, MouseEvent.BUTTON2_MASK,
    MouseEvent.BUTTON3_MASK, MouseEvent.BUTTON3_MASK, MouseEvent.BUTTON3_MASK };
    final static int [] modifiersExStandardTestNONE = new int[] {MouseEvent.BUTTON1_DOWN_MASK, 0, 0,
    MouseEvent.BUTTON2_DOWN_MASK, 0, 0,
    MouseEvent.BUTTON3_DOWN_MASK, 0, 0};
    // BUTTON1, 2, 3 press-release with shift modifier
    final static int [] modifiersStandardTestSHIFT = new int[] {MouseEvent.BUTTON1_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON1_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON1_MASK|InputEvent.SHIFT_MASK,
    MouseEvent.BUTTON2_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON2_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON2_MASK|InputEvent.SHIFT_MASK,
    MouseEvent.BUTTON3_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON3_MASK|InputEvent.SHIFT_MASK, MouseEvent.BUTTON3_MASK|InputEvent.SHIFT_MASK };
    final static int [] modifiersExStandardTestSHIFT = new int[] {MouseEvent.BUTTON1_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK,
    MouseEvent.BUTTON2_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK,
    MouseEvent.BUTTON3_DOWN_MASK|InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK, InputEvent.SHIFT_DOWN_MASK};
    // BUTTON1, 2, 3 press-release with CTRL modifier
    final static int [] modifiersStandardTestCTRL = new int[] {MouseEvent.BUTTON1_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON1_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON1_MASK|InputEvent.CTRL_MASK,
    MouseEvent.BUTTON2_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON2_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON2_MASK|InputEvent.CTRL_MASK,
    MouseEvent.BUTTON3_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON3_MASK|InputEvent.CTRL_MASK, MouseEvent.BUTTON3_MASK|InputEvent.CTRL_MASK };
    final static int [] modifiersExStandardTestCTRL = new int[] {MouseEvent.BUTTON1_DOWN_MASK|InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK,
    MouseEvent.BUTTON2_DOWN_MASK|InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK,
    MouseEvent.BUTTON3_DOWN_MASK|InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK, InputEvent.CTRL_DOWN_MASK};

    // BUTTON1, 2, 3 press-release with ALT modifier
    final static int [] modifiersStandardTestALT = new int[] {MouseEvent.BUTTON1_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON1_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON1_MASK|InputEvent.ALT_MASK,
    MouseEvent.BUTTON2_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON2_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON2_MASK|InputEvent.ALT_MASK,
    MouseEvent.BUTTON3_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON3_MASK|InputEvent.ALT_MASK, MouseEvent.BUTTON3_MASK|InputEvent.ALT_MASK };
    final static int [] modifiersExStandardTestALT = new int[] {MouseEvent.BUTTON1_DOWN_MASK|InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK,
    MouseEvent.BUTTON2_DOWN_MASK|InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK,
    MouseEvent.BUTTON3_DOWN_MASK|InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK, InputEvent.ALT_DOWN_MASK};

    static Robot robot;

    public static void main(String s[]){
        initParams(s);
        initAdapters();
        f = new Frame();
        final int [] modifiers = {InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK};
        final String [] modifierNames = {"InputEvent.SHIFT_MASK", "InputEvent.CTRL_MASK"};
        f.setLayout(new FlowLayout());
        f.addMouseWheelListener(new MouseWheelListener() {
            public void mouseWheelMoved(MouseWheelEvent e) {
                System.out.println("WHEEL "+e);
            }
        });
        f.setSize(300, 300);
        f.setVisible(true);

        try {
            robot = new Robot();
            robot.delay(500);
            robot.mouseMove(f.getLocationOnScreen().x + f.getWidth()/2, f.getLocationOnScreen().y + f.getHeight()/2);
            if (autorun) {
                //testing buttons 1, 2, 3 only
                testPlainButtons();
                robot.delay(500);

                //testing buttons 1, 2, 3 with SHIFT, CTRL, ALT keyboard modifiers
                testButtonsWithShift();
                robot.delay(500);

                testButtonsWithControl();
                robot.delay(500);

                testButtonsWithAlt();
                robot.delay(500);
            } else {
                switch (testModifier){
                    case SHIFT:
                        f.addMouseListener(adapterTest2);
                        break;
                    case CTRL:
                        f.addMouseListener(adapterTest3);
                        break;
                    case ALT:
                        f.addMouseListener(adapterTest4);
                        break;
                    default:  //NONE inclusive
                        f.addMouseListener(adapterTest1);
                }
            }
        } catch (Exception e){
            throw new RuntimeException("Test failed.");
        }

    }

    public static void initAdapters(){
        adapterTest1 = new CheckingModifierAdapter(NONE);
        adapterTest2 = new CheckingModifierAdapter(SHIFT);
        adapterTest3 = new CheckingModifierAdapter(CTRL);
        adapterTest4 = new CheckingModifierAdapter(ALT);
    }

    /*======================================================================*/
    public static void checkPressedModifiersTest(int testModifier, MouseEvent event){
        int [] curStandardModifiers = getStandardArray(testModifier);
        int [] curStandardExModifiers = getStandardExArray(testModifier);
        int button = event.getButton();
        int modifiers = event.getModifiers();
        int modifiersEx = event.getModifiersEx();
        int index = (button - 1)*3;
        //        int index = (button - 4)*3;
        dumpValues(button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]);
        if (modifiers != curStandardModifiers[index]){
            if (debug){
                System.out.println("Test failed :  Pressed. modifiers != modifiersStandard");
            } else {
                throw new RuntimeException("Test failed :  Pressed. modifiers != modifiersStandard");
            }
        }

        if (modifiersEx != curStandardExModifiers[index]){
//            System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
            if (debug){
                System.out.println("Test failed :  Pressed. modifiersEx != curStandardExModifiers");
            } else {
                throw new RuntimeException("Test failed :  Pressed. modifiersEx != curStandardExModifiers");
            }
        }
        HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString());
        System.out.println(event.paramString());
        checkButton(paramStringElements, button);
        checkModifiers(testModifier, paramStringElements, button);
        checkExtModifiersOnPress(testModifier, paramStringElements, button);
    }

    public static void checkButton(HashMap<String, String> h, int button){
        if (h.get("button") == null) {
            throw new RuntimeException("Test failed :  Clicked. button is absent in paramString()");
        }
        if (Integer.parseInt(h.get("button")) != button) {
            throw new RuntimeException("Test failed :  Clicked. button in paramString() doesn't equal to button being pressed.");
        }
    }

    public static void checkExtModifiersOnPress(int testModifier, HashMap h, int button){
        String ethalon = "";
        if (h.get("extModifiers") == null) {
            System.out.println("Test failed :  Pressed. extModifiers == null");
            throw new RuntimeException("Test failed :  Pressed. extModifiers == null");
        }
        switch (testModifier){
            case SHIFT:{
                ethalon = "Shift+";
                break;
            }
            case ALT:{
                ethalon = "Alt+";
                break;
            }
            case CTRL:{
                ethalon = "Ctrl+";
                break;
            }
            default: {
                ethalon = "";
            }
            ethalon = ethalon + "Button" +button;

            if (!h.get("extModifiers").equals(ethalon)) {
                System.out.println("Test failed :  Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
                throw new RuntimeException("Test failed :  Pressed. extModifiers = " +h.get("extModifiers")+" instead of : "+ethalon);
            }
        }
    }



    public static void checkModifiers(int testModifier, HashMap<String, String> h, int button){
        // none of modifiers should be null
        if (h.get("modifiers") == null) {
            System.out.println("Test failed : modifiers == null");
            throw new RuntimeException("Test failed :  modifiers == null");
        }
        Vector <String> modifierElements = tokenizeModifiers(h.get("modifiers"));
        //check that ButtonX is there
        String buttonEthalon = "Button" + button;
        if (modifierElements.contains(buttonEthalon)){
            modifierElements.remove(buttonEthalon);
        } else {
            System.out.println("Test failed :  modifiers doesn't contain Button "+h.get("modifiers"));
            throw new RuntimeException("Test failed :  modifiers doesn't contain Button "+h.get("modifiers"));
        }


        //Check all explicitly pressed modifires
//        boolean altIncluded = false; //don't duplicate Alt when ALT is pressed and BUTTON2_MASK.
        String excplicitModifier = "";
        boolean altIncluded = false;
        switch (testModifier){
            case SHIFT:{
                excplicitModifier = "Shift";
                break;
            }
            case ALT:{
                excplicitModifier = "Alt";
                altIncluded = true; //there should be only on "Alt" for two modifiers. So check it.
                break;
            }
            case CTRL:{
                excplicitModifier = "Ctrl";
                break;
            }
        }
        if (!excplicitModifier.equals("")){
            if (modifierElements.contains(excplicitModifier)){
                modifierElements.remove(excplicitModifier);
            } else {
                System.out.println("Test failed :  modifiers doesn't contain explicit modifier "+excplicitModifier + " in "+ h.get("modifiers"));
                throw new RuntimeException("Test failed :  modifiers doesn't contain explicit modifier "+excplicitModifier + " in "+ h.get("modifiers"));
            }
        }

        //Button 2 and 3 reports about Alt+Button2 and Meta+Button3 respectively.
        //Check these values too
        String extraModifiers = "";
        String extraModifiersButton3 = "";
        switch (button){
            //BUTTON1 with ALT reports about Alt+Button1+Button2.
            //We should fix this but I would not change this.
            case 1: {
                //Alt+Button1+Button2:
                // 1) we already handled "Alt" in excplicitModifier
                // 2) we already took "Button1" in buttonEthalon
                // 3) so "Button2" is only remained.
                // This should only happen when ALT+Button1 is pressed
                if (altIncluded){
                    extraModifiers = "Button2";
                }
                break;
            }
            case 2: {
                //Alt+Button2 report about "Alt+Button2".
                extraModifiers = "Alt";
                break;
            }
            case 3: {
                //ALT+BUTTON3 reports about "Alt+Meta+Button2+Button3"
                // This should only happen when ALT+Button3 is pressed
                extraModifiers = "Meta";
                if (altIncluded){
                    extraModifiersButton3 = "Button2";
                }
                break;
            }
        }//switch

        if (!extraModifiers.equals("")){
            if (modifierElements.contains(extraModifiers)){
                modifierElements.remove(extraModifiers);
            } else {
                //we may already removed "Alt" when filtered explicit modifiers.
                //Here is no failure in this case.
                if (!altIncluded) {
                    System.out.println("Test failed :  modifiers doesn't contain a modifier from BUTTON2 or BUTTON3 "+extraModifiers + " in "+ h.get("modifiers"));
                    throw new RuntimeException("Test failed :  modifiers doesn't contain a modifier from BUTTON2 or BUTTON3 "+extraModifiers + " in "+ h.get("modifiers"));
                }
            }
        }

        if (!extraModifiersButton3.equals("")){
            if (modifierElements.contains(extraModifiersButton3)){
                modifierElements.remove(extraModifiersButton3);
            } else {
                System.out.println("Test failed :  modifiers doesn't contain a modifier from BUTTON2 or BUTTON3 "+extraModifiersButton3 + " in "+ h.get("modifiers"));
                throw new RuntimeException("Test failed :  modifiers doesn't contain a modifier from BUTTON2 or BUTTON3 "+extraModifiersButton3 + " in "+ h.get("modifiers"));
            }
        }

        //the length of vector should now be zero
        if (!modifierElements.isEmpty()){
            System.out.println("Test failed :  there is some more elements in modifiers that shouldn't be there: "+h.get("modifiers"));
            throw new RuntimeException("Test failed :  there is some more elements in modifiers that shouldn't be there: "+h.get("modifiers"));
        }
    }

    public static void checkExtModifiersOnReleaseClick(int testModifier, HashMap h, int button){
        String ethalon = "";
        switch (testModifier){
            case SHIFT:{
                ethalon = "Shift+";
                break;
            }
            case ALT:{
                ethalon = "Alt+";
                break;
            }
            case CTRL:{
                ethalon = "Ctrl+";
                break;
            }
            default: {
                if (h.get("extModifiers") != null) {
                    System.out.println("Test failed :  Released. extModifiers != null but no modifiers keys are pressed");
                    throw new RuntimeException("Test failed :  Released. extModifiers != null but no modifiers keys are pressed");
                } else {
                    //no modifiers
                    return;
                }
            }
        }
        if (h.get("extModifiers").equals(ethalon)) {
            System.out.println("Test failed :  Released. extModifiers = "+ h.get("extModifiers") +" instead of : "+ethalon);
            throw new RuntimeException("Test failed :  Released. extModifiers = "+ h.get("extModifiers") +" instead of : "+ethalon);
        }
    }

    public static void checkReleasedModifiersTest(int testModifier, MouseEvent event){
        int [] curStandardModifiers = getStandardArray(testModifier);
        int [] curStandardExModifiers = getStandardExArray(testModifier);
        //        int index = (button - 4)*3 + 1;
        int button = event.getButton();
        int modifiers = event.getModifiers();
        int modifiersEx = event.getModifiersEx();
        int index = (button - 1)*3 + 1;
        dumpValues(button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]);
        if (modifiers != curStandardModifiers[index]){
            if (debug){
                System.out.println("Test failed :  Released. modifiers != modifiersStandard");
            } else {
                throw new RuntimeException("Test failed :  Released. modifiers != modifiersStandard");
            }
        }
        if (modifiersEx != curStandardExModifiers[index]){
            if (debug){
                System.out.println("Test failed :  Released. modifiersEx != curStandardExModifiers");
            } else {
                throw new RuntimeException("Test failed :  Released. modifiersEx != curStandardExModifiers");
            }
        }
        HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString());
        System.out.println(event.paramString());
        checkButton(paramStringElements, button);
        checkModifiers(testModifier, paramStringElements, button);
        checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button);
    }

    public static void checkClickedModifiersTest(int testModifier, MouseEvent event){
        int [] curStandardModifiers = getStandardArray(testModifier);
        int [] curStandardExModifiers = getStandardExArray(testModifier);
        //        int index = (button - 4)*3 + 2;
        int button = event.getButton();
        int modifiers = event.getModifiers();
        int modifiersEx = event.getModifiersEx();
        int index = (button - 1)*3 + 2;
        dumpValues(button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]);
        if (modifiers != curStandardModifiers[index]){
            if (debug){
                System.out.println("Test failed :  Clicked. modifiers != modifiersStandard");
            } else {
                throw new RuntimeException("Test failed :  Clicked. modifiers != modifiersStandard");
            }
        }
        if (modifiersEx != curStandardExModifiers[index]){
            if (debug){
                System.out.println("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
            } else {
                throw new RuntimeException("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
            }
        }
        HashMap <String, String> paramStringElements = tokenizeParamString(event.paramString());
        checkButton(paramStringElements, button);
        checkModifiers(testModifier, paramStringElements, button);
        checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button);
    }
    /*======================================================================*/

    public static HashMap<String, String> tokenizeParamString(String param){
        HashMap <String, String> params = new HashMap<String, String>();
        StringTokenizer st = new StringTokenizer(param, ",=");
        while (st.hasMoreTokens()){
            String tmp = st.nextToken();
//            System.out.println("PARSER : "+tmp);
            if (tmp.equals("button") ||
                    tmp.equals("modifiers") ||
                    tmp.equals("extModifiers")) {
                params.put(tmp, st.nextToken());
            }
        }
        return params;
    }

    public static Vector<String> tokenizeModifiers(String modifierList){
        Vector<String> modifiers = new Vector<String>();
        StringTokenizer st = new StringTokenizer(modifierList, "+");
        while (st.hasMoreTokens()){
            String tmp = st.nextToken();
            modifiers.addElement(tmp);
            System.out.println("MODIFIER PARSER : "+tmp);
        }
        return modifiers;
    }


    //test BUTTON1, 2 and 3 without any modifiers keys
    public static void  testPlainButtons(){
        System.out.println("Testing buttons without modifiers.");
        f.addMouseListener(adapterTest1);
        for (int button : mouseButtons){
            robot.mousePress(button);
            robot.delay(100);
            robot.mouseRelease(button);
        }
        robot.delay(1000);
        f.removeMouseListener(adapterTest1);
    }

    //test BUTTON1, 2 and 3 with SHIFT key
    public static void  testButtonsWithShift(){
        System.out.println("Testing buttons with SHIFT modifier.");
        f.addMouseListener(adapterTest2);

        for (int button : mouseButtons){
            robot.keyPress(KeyEvent.VK_SHIFT);
            robot.mousePress(button);
            robot.delay(100);
            robot.mouseRelease(button);
            robot.keyRelease(KeyEvent.VK_SHIFT);
        }
        robot.delay(1000);
        f.removeMouseListener(adapterTest2);
    }

    //test BUTTON1, 2 and 3 with CTRL key
    public static void  testButtonsWithControl(){
        System.out.println("Testing buttons with CONTROL modifier.");
        f.addMouseListener(adapterTest3);
        for (int button : mouseButtons){
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.mousePress(button);
            robot.delay(100);
            robot.mouseRelease(button);
            robot.keyRelease(KeyEvent.VK_CONTROL);
        }
        robot.delay(1000);
        f.removeMouseListener(adapterTest3);
    }

    //test BUTTON1, 2 and 3 with ALT key
    public static void  testButtonsWithAlt(){
        System.out.println("Testing buttons with ALT modifier.");
        f.addMouseListener(adapterTest4);
        for (int button : mouseButtons){
            robot.keyPress(KeyEvent.VK_ALT);
            robot.mousePress(button);
            robot.delay(100);
            robot.mouseRelease(button);
            robot.keyRelease(KeyEvent.VK_ALT);
        }
        robot.delay(1000);
        f.removeMouseListener(adapterTest4);
    }

    public static void initParams(String []s){
        if (s.length != 3){
            autorun = true;
            debug = false;
            testModifier = NONE;
        } else {
            autorun = Boolean.valueOf(s[0]);
            debug = Boolean.valueOf(s[1]);

            if (s[2].equals("NONE")){
                testModifier = NONE;
            }
            if (s[2].equals("SHIFT")){
                testModifier = SHIFT;
            }
            if (s[2].equals("CTRL")){
                testModifier = CTRL;
            }
            if (s[2].equals("ALT")){
                testModifier = ALT;
            }
        }
        System.out.println("Autorun : " +autorun);
        System.out.println("Debug mode : " +debug);
        System.out.println("Modifier to verify : " + testModifier);
    }

    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("                   ModifiersEx = "+ modifiersEx + " standardEx = "+ modifiersExStandard);
    }

    private static int[] getStandardExArray(int testModifier) {
        int [] curStandardExModifiers;
        switch (testModifier){
            case SHIFT:
                curStandardExModifiers = modifiersExStandardTestSHIFT;
                break;
            case CTRL:
                curStandardExModifiers = modifiersExStandardTestCTRL;
                break;
            case ALT:
                curStandardExModifiers = modifiersExStandardTestALT;
                break;
            default: //NONE by default
                curStandardExModifiers = modifiersExStandardTestNONE;
        }
        return curStandardExModifiers;
    }

    private static int[] getStandardArray(int testModifier) {
        int [] curStandardModifiers;
        switch (testModifier){
            case SHIFT:
                curStandardModifiers = modifiersStandardTestSHIFT;
                break;
            case CTRL:
                curStandardModifiers = modifiersStandardTestCTRL;
                break;
            case ALT:
                curStandardModifiers = modifiersStandardTestALT;
                break;
            default: //NONE by default
                curStandardModifiers = modifiersStandardTestNONE;
        }
        return curStandardModifiers;
    }

}


/* A class that invoke appropriate verification
 * routine with current modifier.
 */
class CheckingModifierAdapter extends MouseAdapter{
    int modifier;
    public CheckingModifierAdapter(int modifier){
        this.modifier = modifier;
    }

    public void mousePressed(MouseEvent e) {
        System.out.println("PRESSED "+e);
        if (e.getButton() > MouseEvent.BUTTON3) {
            System.out.println("Extra button affected. Skip.");
        } else {
            MouseModifiersUnitTest_Standard.checkPressedModifiersTest(modifier, e); // e.getButton(), e.getModifiers(), e.getModifiersEx(),
        }
    }
    public void mouseReleased(MouseEvent e) {
        System.out.println("RELEASED "+e);
        if (e.getButton() > MouseEvent.BUTTON3) {
            System.out.println("Extra button affected. Skip.");
        } else {
            MouseModifiersUnitTest_Standard.checkReleasedModifiersTest(modifier, e); // e.getButton(), e.getModifiers(), e.getModifiersEx()
        }
    }
    public void mouseClicked(MouseEvent e) {
        System.out.println("CLICKED "+e);
        if (e.getButton() > MouseEvent.BUTTON3) {
            System.out.println("Extra button affected. Skip.");
        } else {
            MouseModifiersUnitTest_Standard.checkClickedModifiersTest(modifier, e); //e.getButton(), e.getModifiers(), e.getModifiersEx()
        }
    }
}