Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8255916: [macos] javax/swing/JInternalFrame/6647340/bug6647340.java t…
Browse files Browse the repository at this point in the history
…imed out

Reviewed-by: serb
  • Loading branch information
prsadhuk committed Nov 11, 2020
1 parent 8638cd9 commit 35284e4
Showing 1 changed file with 43 additions and 54 deletions.
97 changes: 43 additions & 54 deletions test/jdk/javax/swing/JInternalFrame/6647340/bug6647340.java
Expand Up @@ -26,9 +26,6 @@
* @bug 6647340
* @summary Checks that iconified internal frame follows
* the main frame borders properly.
* @author Mikhail Lapshin
* @library /lib/client/
* @build ExtendedRobot
* @run main bug6647340
*/

Expand All @@ -38,22 +35,22 @@

public class bug6647340 {
private JFrame frame;
private Point location;
private volatile Point location;
private volatile Point iconloc;
private JInternalFrame jif;
private static ExtendedRobot robot = createRobot();
private static Robot robot;

public static void main(String[] args) throws Exception {
robot = new Robot();
final bug6647340 test = new bug6647340();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test.setupUI();
}
});
SwingUtilities.invokeAndWait(() -> test.setupUI());
robot.waitForIdle();
robot.delay(1000);
test.test();
} finally {
if (test.frame != null) {
test.frame.dispose();
SwingUtilities.invokeAndWait(() -> test.frame.dispose());
}
}
}
Expand All @@ -77,77 +74,69 @@ private void setupUI() {
}

private void test() throws Exception {
sync();
test1();
sync();

robot.waitForIdle();
robot.delay(500);
check1();
sync();
robot.waitForIdle();

test2();
sync();
robot.waitForIdle();
robot.delay(500);
check2();
}

private void test1() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
setIcon(true);
location = jif.getDesktopIcon().getLocation();
Dimension size = frame.getSize();
frame.setSize(size.width + 100, size.height + 100);
}
SwingUtilities.invokeAndWait(() -> {
setIcon(true);
location = jif.getDesktopIcon().getLocation();
Dimension size = frame.getSize();
frame.setSize(size.width + 100, size.height + 100);
});
}

private void test2() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
setIcon(false);
}
SwingUtilities.invokeAndWait(() -> {
setIcon(false);
});
sync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Dimension size = frame.getSize();
frame.setSize(size.width - 100, size.height - 100);
}
robot.waitForIdle();
robot.delay(500);

SwingUtilities.invokeAndWait(() -> {
Dimension size = frame.getSize();
frame.setSize(size.width - 100, size.height - 100);
});
sync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
setIcon(true);
}
robot.waitForIdle();
robot.delay(500);

SwingUtilities.invokeAndWait(() -> {
setIcon(true);
});
}

private void check1() {
if (!jif.getDesktopIcon().getLocation().equals(location)) {
private void check1() throws Exception {
SwingUtilities.invokeAndWait(() -> {
iconloc = jif.getDesktopIcon().getLocation();
});
if (!iconloc.equals(location)) {
System.out.println("First test passed");
} else {
throw new RuntimeException("Icon isn't shifted with the frame bounds");
}
}

private void check2() {
if (jif.getDesktopIcon().getLocation().equals(location)) {
private void check2() throws Exception {
SwingUtilities.invokeAndWait(() -> {
iconloc = jif.getDesktopIcon().getLocation();
});
if (iconloc.equals(location)) {
System.out.println("Second test passed");
} else {
throw new RuntimeException("Icon isn't located near the frame bottom");
}
}

private static void sync() {
robot.waitForIdle();
}
private static ExtendedRobot createRobot() {
try {
ExtendedRobot robot = new ExtendedRobot();
return robot;
}catch(Exception ex) {
ex.printStackTrace();
throw new Error("Unexpected Failure");
}
}

private void setIcon(boolean b) {
try {
jif.setIcon(b);
Expand Down

0 comments on commit 35284e4

Please sign in to comment.