Path: blob/master/test/jdk/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java
41153 views
/*1* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @key headful26* @bug 817195227* @summary Tests that getMousePosition() returns null for obscured component.28* @author Dmitry Markov29* @library ../../regtesthelpers30* @build Util31* @run main ObscuredFrameTest32*/3334import java.awt.*;3536import test.java.awt.regtesthelpers.Util;3738public class ObscuredFrameTest {39public static void main(String[] args) {40Robot robot = Util.createRobot();4142Frame frame = new Frame("Obscured Frame");43frame.setSize(200, 200);44frame.setLocationRelativeTo(null);45Button button = new Button("Button");46frame.add(button);4748Dialog dialog = new Dialog(frame, "Visible Dialog", false);49dialog.setSize(200, 200);50dialog.setLocationRelativeTo(null);51dialog.setVisible(true);5253frame.setVisible(true);5455Util.waitForIdle(robot);5657Util.pointOnComp(button, robot);58Util.waitForIdle(robot);5960try {61if (button.getMousePosition() != null) {62throw new RuntimeException("Test Failed! Mouse position is not null for obscured component.");63}64} finally {65frame.dispose();66dialog.dispose();67}68}69}70717273