jdk/test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Disable.java
author serb
Tue, 12 Nov 2013 20:24:25 +0400
changeset 21596 0e3a39f29dbc
parent 1962 6c293d33645b
child 23010 6dadb192ad81
permissions -rw-r--r--
8027696: Incorrect copyright header in the tests Reviewed-by: alanb, malenkov, mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21596
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     1
/*
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     2
 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     4
 *
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     7
 * published by the Free Software Foundation.
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     8
 *
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    13
 * accompanied this code).
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    14
 *
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    18
 *
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    21
 * questions.
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    22
 */
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 1962
diff changeset
    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 sun.awt.enableExtraMouseButtons = false consumes extra events
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/othervm -Dsun.awt.enableExtraMouseButtons=false ToolkitPropertyTest_Disable
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
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    35
// Testcase 1: set to FALSE and check
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    36
// Testcase 2: set to FALSE and check that extra events are not coming
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    37
//                              check that standard events are coming
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
public class ToolkitPropertyTest_Disable extends Frame {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    40
    static boolean propValue;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    41
    static Robot robot;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    42
    static int [] buttonsPressed;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    43
    static int [] buttonsReleased;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    44
    static int [] buttonsClicked;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    45
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    46
    static boolean lessThenFourButtons;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    47
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    48
    public static void main(String []s){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    49
        propValue = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons"));
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    50
        buttonsPressed = new int [MouseInfo.getNumberOfButtons()];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    51
        buttonsReleased = new int [MouseInfo.getNumberOfButtons()];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    52
        buttonsClicked = new int [MouseInfo.getNumberOfButtons()];
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    53
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    54
        ToolkitPropertyTest_Disable frame = new ToolkitPropertyTest_Disable();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    55
        frame.setSize(300, 300);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    56
        frame.setVisible(true);
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
        MouseAdapter ma1 = new MouseAdapter() {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    59
                public void mousePressed(MouseEvent e) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    60
                    buttonsPressed[e.getButton() - 1] += 1;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    61
                    System.out.println("PRESSED "+e);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    62
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    63
                public void mouseReleased(MouseEvent e) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    64
                    buttonsReleased[e.getButton() - 1] += 1;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    65
                    System.out.println("RELEASED "+e);
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 void mouseClicked(MouseEvent e) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    68
                    buttonsClicked[e.getButton() - 1] += 1;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    69
                    System.out.println("CLICKED "+e);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    70
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    71
            };
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    72
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    73
        try {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    74
            robot = new Robot();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    75
            robot.delay(1000);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    76
            robot.mouseMove(frame.getLocationOnScreen().x + frame.getWidth()/2, frame.getLocationOnScreen().y + frame.getHeight()/2);
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
            System.out.println("Property = " + propValue);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    79
            testCase0();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    80
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    81
            testCase1();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    82
            System.out.println("Number Of Buttons = "+ MouseInfo.getNumberOfButtons());
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    83
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    84
            lessThenFourButtons = (MouseInfo.getNumberOfButtons() <= 3);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    85
            if ( !lessThenFourButtons ) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    86
                frame.addMouseListener(ma1);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    87
                testCase2();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    88
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    89
        } catch (Exception e){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    90
            e.printStackTrace();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    91
//            throw new RuntimeException(e);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    92
        } finally {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    93
//            frame.removeMouseListener(ma1);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    94
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    95
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    96
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    97
    public static void testCase0(){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    98
        if (propValue){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
    99
            throw new RuntimeException("TEST FAILED (0): System property sun.awt.enableExtraMouseButtons = " + propValue);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   100
        }
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
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   103
    public static void testCase1(){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   104
        if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() == true){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   105
            throw new RuntimeException("TEST FAILED (1): setting to FALSE. Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() = " + Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled());
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
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   109
    public static void testCase2(){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   110
        emptyArrays();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   111
        int [] buttonMasks = new int[MouseInfo.getNumberOfButtons()]; // = InputEvent.getButtonDownMasks();
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   112
        for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   113
            buttonMasks[i] = InputEvent.getMaskForButton(i+1);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   114
            System.out.println("TEST: "+buttonMasks[i]);
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
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   117
        for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   118
            System.out.println("button to press = " +(i+1) + " : value passed to robot = " +buttonMasks[i]);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   119
            try {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   120
                robot.mousePress(buttonMasks[i]);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   121
                robot.delay(70);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   122
                robot.mouseRelease(buttonMasks[i]);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   123
                robot.delay(200);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   124
                //no exception is thrown
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   125
                if (i >= 3) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   126
                    throw new RuntimeException("TESTCASE 2 FAILED : robot accepted the extra button " + (i+1) + " instead of throwing an exception.");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   127
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   128
            } catch (IllegalArgumentException e){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   129
                if (i >= 3) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   130
                    System.out.println("Passed: an exception caught for extra button.");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   131
                } else {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   132
                    throw new RuntimeException("TESTCASE 2 FAILED : exception happen on standard button.", e);
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
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   135
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   136
        robot.delay(2000);
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   137
        if (MouseInfo.getNumberOfButtons() < 3) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   138
            for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   139
                if (buttonsPressed[i] != 1 || buttonsReleased[i] != 1 || buttonsClicked[i] !=1 ) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   140
                    throw new RuntimeException("TESTCASE 2 FAILED : button " + (i+1) + " wasn't single pressed.");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   141
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   142
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   143
        } else {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   144
            for (int i = 0; i < 3; i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   145
                if (buttonsPressed[i] != 1 || buttonsReleased[i] != 1 || buttonsClicked[i] !=1 ) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   146
                    throw new RuntimeException("TESTCASE 2 FAILED : button " + (i+1) + " wasn't single pressed.");
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   147
                }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   148
            }
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
            for (int i = 3; i < MouseInfo.getNumberOfButtons(); i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   151
                if (buttonsPressed[i] != 0 || buttonsReleased[i] != 0 || buttonsClicked[i] != 0 ) {
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   152
                    throw new RuntimeException("TESTCASE 2 FAILED : button " + (i+1) + " was pressed.");
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
            }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   155
        }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   156
    }
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   157
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   158
    public static void emptyArrays(){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   159
        for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   160
            buttonsPressed[i] = 0;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   161
            buttonsReleased[i] = 0;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   162
            buttonsClicked[i] = 0;
6c293d33645b 6315717: Support for mouse with multiple scroll wheels and 4 or more buttons
dav
parents:
diff changeset
   163
        }
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
}