Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mixing/AWT_Mixing/JGlassPaneInternalFrameOverlapping.java
47626 views
/*1* Copyright (c) 2014, 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*/2223import java.awt.BorderLayout;24import java.awt.Color;25import java.awt.Container;26import java.awt.Point;27import java.awt.Robot;28import java.awt.event.MouseAdapter;29import java.awt.event.MouseEvent;30import javax.swing.JFrame;31import javax.swing.JInternalFrame;32import javax.swing.SwingUtilities;33import test.java.awt.regtesthelpers.Util;3435/**36* AWT/Swing overlapping test with JInternalFrame being put in GlassPane.37* See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and38* <a href="https://bugs.openjdk.java.net/browse/JDK-6985776">JDK-6985776</a>.39* <p>See base class for details.40*/41/*42@test43@bug 6637655 698577644@summary Overlapping test for javax.swing.JScrollPane45@author [email protected]: area=awt.mixing46@library ../../regtesthelpers47@build Util48@run main JGlassPaneInternalFrameOverlapping49*/50public class JGlassPaneInternalFrameOverlapping extends OverlappingTestBase {5152private boolean lwClicked = true;53private Point lLoc;54private Point lLoc2;55private JInternalFrame internalFrame;5657protected boolean performTest() {58try {59SwingUtilities.invokeAndWait(new Runnable() {60public void run() {61lLoc = internalFrame.getContentPane().getLocationOnScreen();62lLoc2 = lLoc.getLocation();63lLoc2.translate(0, internalFrame.getContentPane().getHeight() + 10);64}65});66} catch (Exception e) {67e.printStackTrace();68throw new RuntimeException("Where is internal frame?");69}70// run robot71Robot robot = Util.createRobot();72robot.setAutoDelay(ROBOT_DELAY);7374clickAndBlink(robot, lLoc);7576Color c = robot.getPixelColor(lLoc2.x, lLoc2.y);77robot.mouseMove(lLoc2.x, lLoc2.y);78if (!c.equals(AWT_BACKGROUND_COLOR) &&79currentAwtControl.getClass() != java.awt.Scrollbar.class &&80currentAwtControl.getClass() != java.awt.Choice.class) {81fail("The HW component did not pass pixel color check and is not drawn correctly");82}8384return lwClicked;85}8687// {debugClassName = "Choice";}8889@Override90protected void prepareControls() {91JFrame frame = new JFrame("Glass Pane children test");92frame.setLayout(null);9394Container contentPane = frame.getContentPane();95contentPane.setLayout(new BorderLayout());96super.propagateAWTControls(contentPane);9798Container glassPane = (Container) frame.getRootPane().getGlassPane();99glassPane.setVisible(true);100glassPane.setLayout(null);101102internalFrame = new JInternalFrame("Internal Frame", true);103internalFrame.setBounds(50, 0, 200, 100);104internalFrame.setVisible(true);105glassPane.add(internalFrame);106107internalFrame.addMouseListener(new MouseAdapter() {108109@Override110public void mouseClicked(MouseEvent e) {111lwClicked = true;112}113});114115frame.setSize(300, 180);116frame.setLocationRelativeTo(null);117frame.setVisible(true);118}119120// this strange plumbing stuff is required due to "Standard Test Machinery" in base class121public static void main(String args[]) throws InterruptedException {122if (System.getProperty("os.name").toLowerCase().contains("os x")) {123System.out.println("Aqua L&F ignores setting color to component. Test passes on Mac OS X.");124return;125}126instance = new JGlassPaneInternalFrameOverlapping();127OverlappingTestBase.doMain(args);128}129}130131132