jdk/test/javax/swing/SwingUtilities/7170657/bug7170657.java
author serb
Mon, 16 Jul 2012 14:04:03 +0400
changeset 13238 b045f9da27b2
child 21596 0e3a39f29dbc
permissions -rw-r--r--
7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List Reviewed-by: rupashka
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13238
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     1
/*
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     4
 *
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    10
 *
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    15
 * accompanied this code).
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    16
 *
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    20
 *
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    23
 * questions.
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    24
 */
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    25
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    26
import java.awt.Frame;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    27
import java.awt.event.InputEvent;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    28
import java.awt.event.MouseEvent;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    29
import java.awt.event.MouseWheelEvent;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    30
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    31
import javax.swing.SwingUtilities;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    32
import javax.swing.event.MenuDragMouseEvent;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    33
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    34
/**
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    35
 * @test
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    36
 * @bug 7170657
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    37
 * @author Sergey Bylokhov
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    38
 */
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    39
public final class bug7170657 {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    40
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    41
    private static boolean FAILED;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    42
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    43
    public static void main(final String[] args) {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    44
        final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    45
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    46
        Frame f = new Frame();
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    47
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    48
        MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    49
                                             1, 1, 1);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    50
        MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1,
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    51
                                                 true, null, null);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    52
        MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true,
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    53
                                       MouseEvent.NOBUTTON);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    54
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    55
        test(f, mwe);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    56
        test(f, mdme);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    57
        test(f, me);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    58
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    59
        if (FAILED) {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    60
            throw new RuntimeException("Wrong mouse event");
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    61
        }
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    62
    }
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    63
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    64
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    65
    private static void test(final Frame frame, final MouseEvent me) {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    66
        MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    67
        if (me.getModifiersEx() != newme.getModifiersEx()
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    68
                || me.getModifiers() != newme.getModifiers()) {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    69
            fail(me, newme);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    70
        }
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    71
    }
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    72
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    73
    private static void fail(final MouseEvent exp, final MouseEvent act) {
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    74
        System.err.println("Expected: " + exp);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    75
        System.err.println("Actual: " + act);
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    76
        FAILED = true;
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    77
    }
b045f9da27b2 7170657: [macosx] There seems to be no keyboard/mouse action to select non-contiguous items in List
serb
parents:
diff changeset
    78
}