jdk/test/java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.java
author yan
Tue, 24 Jun 2014 12:27:37 +0400
changeset 25210 d2224e06e44f
permissions -rw-r--r--
7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed Reviewed-by: anthony, pchelko Contributed-by: Andrei Eremeev <andrei.eremeev@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25210
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     1
/*
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     2
 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     4
 *
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     8
 *
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    13
 * accompanied this code).
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    14
 *
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    18
 *
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    21
 * questions.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    22
 */
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    23
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    24
/*
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    25
  test
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    26
  @bug 6200670
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    27
  @summary MouseMoved events are triggered by Choice when mouse is moved outside the component, XToolkit
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    28
  @library ../../regtesthelpers/
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    29
  @author andrei.dmitriev area=choice
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    30
  @build Util
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    31
  @run applet PopdownGeneratesMouseEvents.html
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    32
*/
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    33
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    34
import test.java.awt.regtesthelpers.Util;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    35
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    36
import java.applet.Applet;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    37
import java.awt.*;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    38
import java.awt.event.*;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    39
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    40
public class PopdownGeneratesMouseEvents extends Applet {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    41
    private volatile Robot robot;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    42
    private final Choice choice1 = new Choice();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    43
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    44
    private volatile MouseMotionHandler mmh;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    45
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    46
    public void init() {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    47
        for (int i = 1; i < 10; i++) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    48
            choice1.add("item-0" + i);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    49
        }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    50
        choice1.setForeground(Color.RED);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    51
        choice1.setBackground(Color.RED);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    52
        mmh = new MouseMotionHandler();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    53
        choice1.addMouseMotionListener(mmh);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    54
        Button b1 = new Button("FirstButton");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    55
        Button b2 = new Button("SecondButton");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    56
        add(b1);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    57
        add(choice1);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    58
        add(b2);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    59
        setLayout (new FlowLayout());
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    60
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    61
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    62
    public void start() {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    63
        setSize(300, 200);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    64
        setVisible(true);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    65
        validate();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    66
        String toolkit = Toolkit.getDefaultToolkit().getClass().getName();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    67
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    68
        /*
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    69
         * Choice should not generate MouseEvents outside of Choice
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    70
         * Test for XAWT only.
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    71
         */
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    72
        try{
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    73
            robot = new Robot();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    74
            robot.setAutoWaitForIdle(true);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    75
            robot.setAutoDelay(50);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    76
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    77
            if (toolkit.equals("sun.awt.X11.XToolkit")) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    78
                testMouseMoveOutside();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    79
            } else {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    80
                System.out.println("This test is for XToolkit only. Now using "
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    81
                                        + toolkit + ". Automatically passed.");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    82
                return;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    83
            }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    84
        } catch (Throwable e) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    85
            throw new RuntimeException("Test failed. Exception thrown: " + e);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    86
        }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    87
        System.out.println("Passed : Choice should not generate MouseEvents outside of Choice.");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    88
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    89
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    90
    private void testMouseMoveOutside() {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    91
        waitForIdle();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    92
        Point pt = choice1.getLocationOnScreen();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    93
        robot.mouseMove(pt.x + choice1.getWidth() / 2, pt.y + choice1.getHeight() / 2);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    94
        waitForIdle();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    95
        robot.mousePress(InputEvent.BUTTON1_MASK);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    96
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    97
        waitForIdle();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    98
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
    99
        Color color = robot.getPixelColor(pt.x + choice1.getWidth() / 2,
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   100
                                          pt.y + 3 * choice1.getHeight());
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   101
        if (!color.equals(Color.RED)) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   102
            throw new RuntimeException("Choice wasn't opened with LEFTMOUSE button");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   103
        }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   104
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   105
        pt = getLocationOnScreen();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   106
        robot.mouseMove(pt.x + getWidth() * 2, pt.y + getHeight() * 2);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   107
        mmh.testStarted = true;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   108
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   109
        int x0 = pt.x + getWidth() * 3 / 2;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   110
        int y0 = pt.y + getHeight() * 3 / 2;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   111
        int x1 = pt.x + getWidth() * 2;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   112
        int y1 = pt.y + getHeight() * 2;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   113
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   114
        Util.mouseMove(robot, new Point(x0, y0), new Point(x1, y0));
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   115
        Util.mouseMove(robot, new Point(x1, y0), new Point(x1, y1));
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   116
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   117
        waitForIdle();
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   118
        //close opened choice
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   119
        robot.keyPress(KeyEvent.VK_ESCAPE);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   120
        robot.keyRelease(KeyEvent.VK_ESCAPE);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   121
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   122
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   123
    private void waitForIdle() {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   124
        Util.waitForIdle(robot);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   125
        robot.delay(500);
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   126
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   127
}
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   128
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   129
class MouseMotionHandler extends MouseMotionAdapter {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   130
    public volatile boolean testStarted;
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   131
    public void mouseMoved(MouseEvent ke) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   132
        if (testStarted) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   133
            throw new RuntimeException("Test failed: Choice generated MouseMove events while moving mouse outside of Choice");
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   134
        }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   135
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   136
    public void mouseDragged(MouseEvent ke) {
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   137
    }
d2224e06e44f 7112454: TEST_BUG: java/awt/Choice/PopdownGeneratesMouseEvents/PopdownGeneratesMouseEvents.html failed
yan
parents:
diff changeset
   138
}