Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java
38828 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* @bug 8169589 817190926* @summary Activating a dialog puts to back another dialog owned by the same frame27* @author Dmitry Markov28* @library ../../regtesthelpers29* @build Util30* @run main DialogAboveFrameTest31*/3233import java.awt.Color;34import java.awt.Dialog;35import java.awt.Frame;36import java.awt.Point;37import java.awt.Robot;3839import test.java.awt.regtesthelpers.Util;4041public class DialogAboveFrameTest {42public static void main(String[] args) {43Robot robot = Util.createRobot();4445Frame frame = new Frame("Frame");46frame.setBackground(Color.BLUE);47frame.setBounds(200, 50, 300, 300);48frame.setVisible(true);4950Dialog dialog1 = new Dialog(frame, "Dialog 1", false);51dialog1.setBackground(Color.RED);52dialog1.setBounds(100, 100, 200, 200);53dialog1.setVisible(true);5455Dialog dialog2 = new Dialog(frame, "Dialog 2", false);56dialog2.setBackground(Color.GREEN);57dialog2.setBounds(400, 100, 200, 200);58dialog2.setVisible(true);5960Util.waitForIdle(robot);6162Util.clickOnComp(dialog2, robot);63Util.waitForIdle(robot);6465Point point = dialog1.getLocationOnScreen();66int x = point.x + (int)(dialog1.getWidth() * 0.9);67int y = point.y + (int)(dialog1.getHeight() * 0.9);6869try {70if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {71throw new RuntimeException("Test FAILED: Dialog is behind the frame");72}73} finally {74frame.dispose();75dialog1.dispose();76dialog2.dispose();77}78}79}80818283