Path: blob/master/test/jdk/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.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 8169589 817190927* @summary Activating a dialog puts to back another dialog owned by the same frame28* @author Dmitry Markov29* @library ../../regtesthelpers30* @build Util31* @run main DialogAboveFrameTest32*/3334import java.awt.Color;35import java.awt.Dialog;36import java.awt.Frame;37import java.awt.Point;38import java.awt.Robot;3940import test.java.awt.regtesthelpers.Util;4142public class DialogAboveFrameTest {43public static void main(String[] args) {44Robot robot = Util.createRobot();4546Frame frame = new Frame("Frame");47frame.setBackground(Color.BLUE);48frame.setBounds(200, 50, 300, 300);49frame.setVisible(true);5051Dialog dialog1 = new Dialog(frame, "Dialog 1", false);52dialog1.setBackground(Color.RED);53dialog1.setBounds(100, 100, 200, 200);54dialog1.setVisible(true);5556Dialog dialog2 = new Dialog(frame, "Dialog 2", false);57dialog2.setBackground(Color.GREEN);58dialog2.setBounds(400, 100, 200, 200);59dialog2.setVisible(true);6061Util.waitForIdle(robot);6263Util.clickOnComp(dialog2, robot);64Util.waitForIdle(robot);6566Point point = dialog1.getLocationOnScreen();67int x = point.x + (int)(dialog1.getWidth() * 0.9);68int y = point.y + (int)(dialog1.getHeight() * 0.9);6970try {71if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {72throw new RuntimeException("Test FAILED: Dialog is behind the frame");73}74} finally {75frame.dispose();76dialog1.dispose();77dialog2.dispose();78}79}80}81828384