J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2006 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 5028924 |
| 27 | @summary Always-on-top frame should be on top of Window. |
| 28 | @author Yuri.Nesterenko: area=awt.toplevel |
| 29 | @library ../../regtesthelpers |
| 30 | @build Util |
| 31 | @run main AlwaysOnTopEvenOfWindow |
| 32 | */ |
| 33 | |
| 34 | |
| 35 | import java.awt.*; |
| 36 | import java.awt.event.*; |
| 37 | import test.java.awt.regtesthelpers.Util; |
| 38 | |
| 39 | /** |
| 40 | * AlwaysOnTopEvenOfWindow.java |
| 41 | * Summary: tests that a Frame marked always-on-top actually is on top of |
| 42 | * a Window. |
| 43 | * Test fails in case of override-redirect Window (e.g. with JDK6.0); |
| 44 | */ |
| 45 | public class AlwaysOnTopEvenOfWindow { |
| 46 | static boolean clicked = false; |
| 47 | public static void main(String args[]) { |
| 48 | |
| 49 | Window win = new Window(null); |
| 50 | win.setBounds( 50,50, 300,50); |
| 51 | win.addMouseListener( new MouseAdapter() { |
| 52 | public void mouseClicked( MouseEvent me ) { |
| 53 | clicked = true; |
| 54 | } |
| 55 | }); |
| 56 | Frame frame = new Frame("top"); |
| 57 | frame.setBounds(100, 20, 50, 300); |
| 58 | frame.setAlwaysOnTop( true ); |
| 59 | |
| 60 | // position robot before show(): there may be point-to-focus; |
| 61 | Robot robot = Util.createRobot(); |
| 62 | robot.mouseMove(125, 75); |
| 63 | |
| 64 | frame.setVisible(true); |
| 65 | win.setVisible(true); |
| 66 | Util.waitForIdle(robot); |
| 67 | if(!frame.isAlwaysOnTopSupported()) { |
| 68 | // pass |
| 69 | return; |
| 70 | } |
| 71 | robot.mousePress(InputEvent.BUTTON1_MASK); |
| 72 | robot.delay(50); |
| 73 | robot.mouseRelease(InputEvent.BUTTON1_MASK); |
| 74 | Util.waitForIdle(robot); |
| 75 | if( clicked ) { |
| 76 | throw new RuntimeException("This part of Window should be invisible"); |
| 77 | } |
| 78 | |
| 79 | } |
| 80 | } |