test/java/awt/Mixing/AWT_Mixing/JGlassPaneMoveOverlapping.java

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.BorderLayout;
  25 import java.awt.Color;
  26 import java.awt.Container;
  27 import java.awt.Point;
  28 import java.awt.Robot;
  29 import java.awt.event.InputEvent;
  30 import java.awt.event.MouseAdapter;
  31 import java.awt.event.MouseEvent;
  32 import javax.swing.JFrame;
  33 import javax.swing.JInternalFrame;
  34 import javax.swing.SwingUtilities;

  35 
  36 /**
  37  * AWT/Swing overlapping test with JInternalFrame being moved in GlassPane.
  38  * See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and
  39  * <a href="https://bugs.openjdk.java.net/browse/JDK-6981919">JDK-6981919</a>.
  40  * <p>See base class for details.
  41  */
  42 /*
  43 @test
  44 @bug 6637655 6981919
  45 @summary Overlapping test for javax.swing.JScrollPane
  46 @author sergey.grinev@oracle.com: area=awt.mixing


  47 @run main JGlassPaneMoveOverlapping
  48  */
  49 public class JGlassPaneMoveOverlapping extends OverlappingTestBase {
  50 
  51     private boolean lwClicked = true;
  52     private volatile Point lLoc;
  53     private volatile Point lLoc2;
  54 
  55     private JInternalFrame internalFrame;
  56     private JFrame frame = null;
  57     private volatile Point frameLoc;
  58 
  59     protected boolean performTest() {
  60 
  61         try {
  62             SwingUtilities.invokeAndWait(new Runnable() {
  63                 public void run() {
  64                     lLoc = internalFrame.getContentPane().getLocationOnScreen();
  65                     lLoc2 = lLoc.getLocation();
  66                     lLoc2.translate(0, internalFrame.getHeight());
  67                     frameLoc = frame.getLocationOnScreen();
  68                     frameLoc.translate(frame.getWidth()/2, 3);
  69                 }
  70             });
  71         } catch (Exception e) {
  72             e.printStackTrace();
  73             System.exit(1);
  74         }
  75 
  76         // run robot
  77         Robot robot = Util.createRobot();
  78         robot.setAutoDelay(ROBOT_DELAY);
  79 
  80         // force focus on JFrame (jtreg workaround)
  81         robot.mouseMove(frameLoc.x, frameLoc.y);
  82         Util.waitForIdle(robot);
  83         robot.mousePress(InputEvent.BUTTON1_MASK);
  84         robot.delay(50);
  85         robot.mouseRelease(InputEvent.BUTTON1_MASK);
  86         Util.waitForIdle(robot);
  87 
  88 
  89         //slow move
  90         robot.mouseMove(lLoc.x +  25, lLoc.y - 5);
  91         robot.mousePress(InputEvent.BUTTON1_MASK);
  92         robot.delay(100);
  93         robot.mouseMove(lLoc.x +  45, lLoc.y - 5);




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.BorderLayout;
  25 import java.awt.Color;
  26 import java.awt.Container;
  27 import java.awt.Point;
  28 import java.awt.Robot;
  29 import java.awt.event.InputEvent;
  30 import java.awt.event.MouseAdapter;
  31 import java.awt.event.MouseEvent;
  32 import javax.swing.JFrame;
  33 import javax.swing.JInternalFrame;
  34 import javax.swing.SwingUtilities;
  35 import test.java.awt.regtesthelpers.Util;
  36 
  37 /**
  38  * AWT/Swing overlapping test with JInternalFrame being moved in GlassPane.
  39  * See <a href="https://bugs.openjdk.java.net/browse/JDK-6637655">JDK-6637655</a> and
  40  * <a href="https://bugs.openjdk.java.net/browse/JDK-6981919">JDK-6981919</a>.
  41  * <p>See base class for details.
  42  */
  43 /*
  44 @test
  45 @bug 6637655 6981919
  46 @summary Overlapping test for javax.swing.JScrollPane
  47 @author sergey.grinev@oracle.com: area=awt.mixing
  48 @library ../../regtesthelpers
  49 @build Util
  50 @run main JGlassPaneMoveOverlapping
  51  */
  52 public class JGlassPaneMoveOverlapping extends OverlappingTestBase {
  53 
  54     private boolean lwClicked = true;
  55     private volatile Point lLoc;
  56     private volatile Point lLoc2;
  57 
  58     private JInternalFrame internalFrame;
  59     private JFrame frame = null;
  60     private volatile Point frameLoc;
  61 
  62     protected boolean performTest() {
  63 
  64         try {
  65             SwingUtilities.invokeAndWait(new Runnable() {
  66                 public void run() {
  67                     lLoc = internalFrame.getContentPane().getLocationOnScreen();
  68                     lLoc2 = lLoc.getLocation();
  69                     lLoc2.translate(0, internalFrame.getHeight());
  70                     frameLoc = frame.getLocationOnScreen();
  71                     frameLoc.translate(frame.getWidth()/2, 3);
  72                 }
  73             });
  74         } catch (Exception e) {
  75             e.printStackTrace();
  76             throw new RuntimeException("Where is internal frame?");
  77         }
  78 
  79         // run robot
  80         Robot robot = Util.createRobot();
  81         robot.setAutoDelay(ROBOT_DELAY);
  82 
  83         // force focus on JFrame (jtreg workaround)
  84         robot.mouseMove(frameLoc.x, frameLoc.y);
  85         Util.waitForIdle(robot);
  86         robot.mousePress(InputEvent.BUTTON1_MASK);
  87         robot.delay(50);
  88         robot.mouseRelease(InputEvent.BUTTON1_MASK);
  89         Util.waitForIdle(robot);
  90 
  91 
  92         //slow move
  93         robot.mouseMove(lLoc.x +  25, lLoc.y - 5);
  94         robot.mousePress(InputEvent.BUTTON1_MASK);
  95         robot.delay(100);
  96         robot.mouseMove(lLoc.x +  45, lLoc.y - 5);