Path: blob/master/test/jdk/java/awt/Mixing/AWT_Mixing/JInternalFrameMoveOverlapping.java
41152 views
/*1* Copyright (c) 2014, 2016, 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.Point;24import java.awt.Robot;25import java.awt.event.InputEvent;26import java.awt.event.MouseAdapter;27import java.awt.event.MouseEvent;28import javax.swing.JButton;29import javax.swing.JDesktopPane;30import javax.swing.JFrame;31import javax.swing.JInternalFrame;32import test.java.awt.regtesthelpers.Util;3334/**35* AWT/Swing overlapping test for {@link javax.swing.JInternalFrame } component during move.36* <p>See <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=6985399">CR6768230</a> for details and base class for test info.37*/38/*39* @test40* @key headful41* @bug 698539942* @summary Overlapping test for javax.swing.JScrollPane43* @author [email protected]: area=awt.mixing44* @library /java/awt/patchlib ../../regtesthelpers45* @modules java.desktop/sun.awt46* java.desktop/java.awt.peer47* @build java.desktop/java.awt.Helper48* @build Util49* @run main JInternalFrameMoveOverlapping50*/51public class JInternalFrameMoveOverlapping extends OverlappingTestBase {5253private boolean lwClicked = true;54private Point locTopFrame;55private Point locTarget;5657protected boolean performTest() {58// run robot59Robot robot = Util.createRobot();60robot.setAutoDelay(ROBOT_DELAY);6162robot.mouseMove(locTopFrame.x + 25, locTopFrame.y + 25);63robot.mousePress(InputEvent.BUTTON1_MASK);64try {65Thread.sleep(500);66} catch (InterruptedException ex) {67}68robot.mouseMove(locTopFrame.x + (locTarget.x - locTopFrame.x)/2, locTopFrame.y + (locTarget.y - locTopFrame.y)/2);69try {70Thread.sleep(500);71} catch (InterruptedException ex) {72}73robot.mouseMove(locTarget.x, locTarget.y);74try {75Thread.sleep(500);76} catch (InterruptedException ex) {77}78robot.mouseRelease(InputEvent.BUTTON1_MASK);7980clickAndBlink(robot, locTarget);8182return lwClicked;83}8485//static {debugClassName = "Choice";}8687@Override88protected void prepareControls() {899091JDesktopPane desktopPane = new JDesktopPane();9293JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);94bottomFrame.setSize(220, 220);95super.propagateAWTControls(bottomFrame);96desktopPane.add(bottomFrame);97bottomFrame.setVisible(true);9899JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);100topFrame.setSize(200, 200);101topFrame.add(new JButton("LW Button") {102103{104addMouseListener(new MouseAdapter() {105106@Override107public void mouseClicked(MouseEvent e) {108lwClicked = true;109}110});111}112});113desktopPane.add(topFrame);114topFrame.setVisible(true);115116JFrame frame = new JFrame("Test Window");117frame.setSize(300, 300);118frame.setContentPane(desktopPane);119frame.setVisible(true);120121locTopFrame = topFrame.getLocationOnScreen();122locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);123}124125// this strange plumbing stuff is required due to "Standard Test Machinery" in base class126public static void main(String args[]) throws InterruptedException {127instance = new JInternalFrameMoveOverlapping();128OverlappingTestBase.doMain(args);129}130}131132133