J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | @test |
| 26 | @bug 6480024 |
| 27 | @library ../../../regtesthelpers |
| 28 | @build Util Sysout AbstractTest |
| 29 | @summary check that the wheel event is generated over the JFrame |
| 30 | @author Andrei Dmitriev: area=awt.event |
| 31 | @run main InfiniteRecursion_4 |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * InfiniteRecursion_4.java |
| 36 | * |
| 37 | * summary: create simple JFrame and check that the WheelEvent is generated over it. |
| 38 | */ |
| 39 | |
| 40 | import java.awt.*; |
| 41 | import java.awt.event.*; |
| 42 | import javax.swing.*; |
| 43 | import test.java.awt.regtesthelpers.Util; |
| 44 | import test.java.awt.regtesthelpers.AbstractTest; |
| 45 | import test.java.awt.regtesthelpers.Sysout; |
| 46 | |
| 47 | public class InfiniteRecursion_4 { |
| 48 | final static Robot robot = Util.createRobot(); |
| 49 | final static int MOVE_COUNT = 5; |
| 50 | static int actualEvents = 0; |
| 51 | |
| 52 | public static void main(String []s) |
| 53 | { |
| 54 | JFrame frame = new JFrame("A test frame"); |
| 55 | |
| 56 | frame.setSize(200, 200); |
| 57 | frame.addMouseWheelListener(new MouseWheelListener() { |
| 58 | public void mouseWheelMoved(MouseWheelEvent e) |
| 59 | { |
| 60 | System.out.println("Wheel moved on FRAME : "+e); |
| 61 | actualEvents++; |
| 62 | } |
| 63 | }); |
| 64 | |
| 65 | frame.setVisible(true); |
| 66 | |
| 67 | Util.waitForIdle(robot); |
| 68 | |
| 69 | Util.pointOnComp(frame, robot); |
| 70 | Util.waitForIdle(robot); |
| 71 | |
| 72 | for (int i = 0; i < MOVE_COUNT; i++){ |
| 73 | robot.mouseWheel(1); |
| 74 | robot.delay(10); |
| 75 | } |
| 76 | |
| 77 | for (int i = 0; i < MOVE_COUNT; i++){ |
| 78 | robot.mouseWheel(-1); |
| 79 | robot.delay(10); |
| 80 | } |
| 81 | |
| 82 | Util.waitForIdle(robot); |
| 83 | if (actualEvents != MOVE_COUNT * 2) { |
| 84 | AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents); |
| 85 | } |
| 86 | } |
| 87 | } |