< prev index next >
test/java/awt/MouseInfo/JContainerMousePositionTest.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 65,83 ****
contentPane.repaint();
});
robot.waitForIdle();
AtomicReference<Rectangle> frameBounds = new AtomicReference<>();
AtomicReference<Dimension> button1Size = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> {
frameBounds.set(frame1.getBounds());
button1Size.set(jButton1.getSize());
});
//point mouse to center of top-left Component (button1)
! robot.mouseMove(frameBounds.get().x + button1Size.get().width / 2,
! frameBounds.get().y + button1Size.get().height / 2);
AtomicReference<Point> pFalse = new AtomicReference<>();
AtomicReference<Point> pTrue = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> {
pFalse.set(frame1.getMousePosition(false));
--- 65,87 ----
contentPane.repaint();
});
robot.waitForIdle();
AtomicReference<Rectangle> frameBounds = new AtomicReference<>();
+ AtomicReference<Insets> frameInsets = new AtomicReference<>();
AtomicReference<Dimension> button1Size = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> {
frameBounds.set(frame1.getBounds());
+ frameInsets.set(frame1.getInsets());
button1Size.set(jButton1.getSize());
});
//point mouse to center of top-left Component (button1)
! robot.mouseMove(frameBounds.get().x + frameInsets.get().left +
! button1Size.get().width / 2,
! frameBounds.get().y + frameInsets.get().top +
! button1Size.get().height / 2);
AtomicReference<Point> pFalse = new AtomicReference<>();
AtomicReference<Point> pTrue = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> {
pFalse.set(frame1.getMousePosition(false));
*** 106,119 ****
throw new RuntimeException("Test failed: Container.getMousePosition(boolean) returned incorrect result outside Container");
}
System.out.println("Test stage completed: Container.getMousePosition(boolean) returned null result outside Container. Passed.");
//point mouse in place free from child components (right-botton component)
! robot.mouseMove(frameBounds.get().x + centerC4.get().x,
! frameBounds.get().y + centerC4.get().y);
! robot.delay(3000);
SwingUtilities.invokeAndWait(() -> {
pFalse.set(contentPane.getMousePosition(false));
pTrue.set(frame1.getMousePosition(true));
});
robot.waitForIdle();
--- 110,125 ----
throw new RuntimeException("Test failed: Container.getMousePosition(boolean) returned incorrect result outside Container");
}
System.out.println("Test stage completed: Container.getMousePosition(boolean) returned null result outside Container. Passed.");
//point mouse in place free from child components (right-botton component)
! robot.mouseMove(frameBounds.get().x + frameInsets.get().left +
! centerC4.get().x,
! frameBounds.get().y + frameInsets.get().top +
! centerC4.get().y);
! robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> {
pFalse.set(contentPane.getMousePosition(false));
pTrue.set(frame1.getMousePosition(true));
});
robot.waitForIdle();
*** 121,131 ****
if (pFalse.get() == null || pTrue.get() == null) {
throw new RuntimeException("Test failed: Container.getMousePosition(boolean) returned null result inside Container.");
}
System.out.println("Test stage completed: Container.getMousePosition(boolean) returned non-null results inside Container. Passed.");
! if (pTrue.get().x != centerC4.get().x || pTrue.get().y != centerC4.get().y) {
throw new RuntimeException("Test failed: Container.getMousePosition(true) returned incorrect result inside Container.");
}
System.out.println("Test stage completed: Container.getMousePosition(true) returned correct result inside Container. Passed.");
System.out.println("TEST PASSED");
--- 127,138 ----
if (pFalse.get() == null || pTrue.get() == null) {
throw new RuntimeException("Test failed: Container.getMousePosition(boolean) returned null result inside Container.");
}
System.out.println("Test stage completed: Container.getMousePosition(boolean) returned non-null results inside Container. Passed.");
! if (pTrue.get().x != frameInsets.get().left + centerC4.get().x ||
! pTrue.get().y != frameInsets.get().top + centerC4.get().y) {
throw new RuntimeException("Test failed: Container.getMousePosition(true) returned incorrect result inside Container.");
}
System.out.println("Test stage completed: Container.getMousePosition(true) returned correct result inside Container. Passed.");
System.out.println("TEST PASSED");
< prev index next >