Skip to content

Commit

Permalink
extract logFrameBounds, instructions update
Browse files Browse the repository at this point in the history
  • Loading branch information
azvegint committed Mar 13, 2024
1 parent c09f494 commit 2c90d8e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/jdk/java/awt/Frame/GetBoundsResizeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* questions.
*/

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.Button;
import java.awt.Frame;
import java.awt.EventQueue;
import java.awt.Robot;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/*
* @test
Expand All @@ -43,8 +43,10 @@ public class GetBoundsResizeTest {
Its original bounds should be printed in the text area below.
1. Resize the test window using the upper left corner.
2. Press the button to print the result of getBounds() to the terminal.
3. If getBounds() prints the correct values for the window, click Pass,
otherwise click Fail.
3. Previously, a window could report an incorrect position on the
screen after resizing the window in this way.
If getBounds() prints the appropriate values for the window,
click Pass, otherwise click Fail.
""";

private static JTextArea textArea;
Expand All @@ -63,16 +65,15 @@ public static void main(String[] args) throws Exception {
return new JScrollPane(textArea);
})
.testUI(GetBoundsResizeTest::getFrame)
.rows(7)
.rows((int) (INSTRUCTIONS.lines().count() + 2))
.columns(40)
.build();

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

EventQueue.invokeAndWait(() ->
textArea.append("Original Frame.getBounds() = %s\n"
.formatted(frame.getBounds())));
logFrameBounds("Original Frame.getBounds() = %s\n"));

passFailJFrame.awaitAndCheck();
}
Expand All @@ -82,12 +83,15 @@ private static Frame getFrame() {

Button button = new Button("Press");
button.addActionListener((e) ->
textArea.append("Current Frame.getBounds() = %s\n"
.formatted(frame.getBounds())));
logFrameBounds("Current Frame.getBounds() = %s\n"));

frame.add(button);
frame.pack();

return frame;
}

private static void logFrameBounds(String format) {
textArea.append(format.formatted(frame.getBounds()));
}
}

0 comments on commit 2c90d8e

Please sign in to comment.