use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6711682 method main.
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point l = table.getLocationOnScreen();
int h = table.getRowHeight();
for (int i = 0; i < 3; i++) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
// Without pressing F2 the last table's cell
// reported <code>false</code> value
// note that I can't press it inside the for loop
// because it doesn't reproduce the bug
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);
for (int i = 0; i < 3; i++) {
if (!Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is not selected");
}
}
for (int i = 2; i >= 0; i--) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);
for (int i = 0; i < 3; i++) {
if (Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is selected");
}
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7171812 method main.
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
setupGUI();
}
});
toolkit.realSync();
Robot robot = new Robot();
robot.setAutoDelay(10);
robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
for (int offset = 5; offset < scrollPane.getHeight() - 20; offset++) {
robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + offset);
}
for (int offset = 5; offset < 195; offset++) {
robot.mouseMove(scrollPane.getLocationOnScreen().x + offset, scrollPane.getLocationOnScreen().y + scrollPane.getHeight() - 20);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (scrollPane.getViewport().getViewPosition().getY() < 30) {
throw new RuntimeException("Incorrect view position.");
}
;
}
});
} catch (java.lang.reflect.InvocationTargetException ite) {
throw new RuntimeException("Test failed, scroll on drag doesn't work!");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class DragWindowOutOfFrameTest method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return getCenterPoint(label);
}
});
robot.mouseMove(pointToClick.x, pointToClick.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) {
throw new RuntimeException("Wrong number mouse Entered/Exited events on Drag Window!");
}
Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
label.addMouseListener(new LabelMouseListener());
button.addMouseListener(new ButtonMouseListener());
return getCenterPoint(button);
}
});
robot.mouseMove(450, pointToClick.y);
toolkit.realSync();
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
throw new RuntimeException("Wrong number Mouse Entered/Exited events on label!");
}
robot.mouseMove(450, pointToDrag.y);
toolkit.realSync();
if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
throw new RuntimeException("Wrong number Mouse Entered/Exited events on label!");
}
if (buttonMouseEnteredCount != 0 && buttonMouseExitedCount != 0) {
throw new RuntimeException("Wrong number Mouse Entered/Exited events on button!");
}
robot.mouseMove(pointToDrag.y, pointToDrag.y);
toolkit.realSync();
if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) {
throw new RuntimeException("Wrong number Mouse Entered/Exited events on button!");
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (labelMouseReleasedCount != 1) {
throw new RuntimeException("No MouseReleased event on label!");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class DragWindowTest method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return getCenterPoint(label);
}
});
robot.mouseMove(pointToClick.x, pointToClick.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (dragWindowMouseEnteredCount != 1) {
throw new RuntimeException("No MouseEntered event on Drag Window!");
}
Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
button.addMouseListener(new ButtonMouseListener());
return getCenterPoint(button);
}
});
robot.mouseMove(pointToDrag.x, pointToDrag.y);
toolkit.realSync();
if (buttonMouseEnteredCount != 0) {
throw new RuntimeException("Extra MouseEntered event on button!");
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (labelMouseReleasedCount != 1) {
throw new RuntimeException("No MouseReleased event on label!");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4654927 method main.
public static void main(String[] args) throws Exception {
String systemLAF = UIManager.getSystemLookAndFeelClassName();
// the test is not applicable to Motif L&F
if (systemLAF.endsWith("MotifLookAndFeel")) {
return;
}
UIManager.setLookAndFeel(systemLAF);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(10);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowUI();
}
});
toolkit.realSync();
// test mouse press
Point point = Util.getCenterPoint(menu);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
point = Util.getCenterPoint(menuItem);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
}
// test mouse drag
point = Util.getCenterPoint(menu);
robot.mouseMove(point.x, point.y);
Point menuLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return menu.getLocationOnScreen();
}
});
Point itemLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return menuItem.getLocationOnScreen();
}
});
int x0 = menuLocation.x + 10;
int y0 = menuLocation.y + 10;
int x1 = itemLocation.x + 10;
int y1 = itemLocation.y + 10;
// close menu
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
robot.mousePress(InputEvent.BUTTON1_MASK);
Util.glide(robot, x0, y0, x1, y1);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
if (!isMenuItemShowing()) {
throw new RuntimeException("Popup is unexpectedly closed");
}
}
Aggregations