Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
azvegint committed Sep 25, 2023
1 parent ff3f23e commit d5f7164
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
12 changes: 5 additions & 7 deletions test/jdk/java/awt/Frame/FrameRepackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class FrameRepackTest {
The menubar has one menu, labelled 'Flip'.
The menu has two items, labelled 'visible' and 'not visible'.
The frame also contains a red panel that contains two line labels,
' This panel is always displayed' and ' it is a test'.
'This panel is always displayed' and 'it is a test'.
If you select the menu item 'Flip->visible', then another panel is
added below the red panel.
Expand All @@ -61,7 +61,7 @@ public class FrameRepackTest {
You can repeatedly add and remove the second panel in this way.
After such an addition or removal, the frame's location on the screen
should not have changed, while the size changes to accommodate
should not change, while the size changes to accommodate
either just the red panel or both the red and the blue panels.
If you resize the frame larger, the red panel remains at the
Expand Down Expand Up @@ -113,7 +113,6 @@ public FrameRepack() {
// create the options
Menu flip = new Menu("Flip");
MenuItem mi;
flip.addSeparator();
mi = new MenuItem("visible");
mi.addActionListener(this);
flip.add(mi);
Expand All @@ -130,8 +129,8 @@ public FrameRepack() {
Panel north = new Panel();
north.setBackground(Color.red);
north.setLayout(new BorderLayout(2, 2));
north.add("North", new Label(" This panel is always displayed"));
north.add("Center", new Label(" it is a test "));
north.add("North", new Label("This panel is always displayed"));
north.add("Center", new Label("it is a test"));
north.setSize(200, 200);
add("North", north);

Expand Down Expand Up @@ -161,16 +160,15 @@ public FrameRepack() {
pack();
}

@Override
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() instanceof MenuItem) {
if (evt.getActionCommand().equals("visible")) {
south.setVisible(true);
pack();
setVisible(true);
} else if (evt.getActionCommand().equals("not visible")) {
south.setVisible(false);
pack();
setVisible(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public class FrameResizeTest_1 {
private static final String INSTRUCTIONS = """
To the right of this frame is an all-white 200x200 frame.
This is actually a white canvas component of the frame.
This is actually a white canvas component in the frame.
The frame itself is red.
The red should never show.
In particular, after you resize the frame, you should see all white and no red.
(During very fast window resizing, red color may appear briefly,
which is not a failure.)
Upon test completion, click Pass or Fail appropriately.
""";
Expand All @@ -55,7 +57,7 @@ public static void main(String[] args) throws Exception {
.title("FrameResizeTest_1 Instructions")
.instructions(INSTRUCTIONS)
.testTimeOut(5)
.rows(9)
.rows(12)
.columns(45)
.build();

Expand Down
16 changes: 8 additions & 8 deletions test/jdk/java/awt/Frame/FrameResizeTest/FrameResizeTest_2.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ class FrameResize_2 extends Frame {
FrameResize_2() {
super("FrameResize_2");

setLayout( new GridBagLayout() );
setLayout(new GridBagLayout());

GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;

Container dumbc = new DumbC();
add( dumbc, c );
Container dumbContainer = new DumbContainer();
add(dumbContainer, c);

Panel dump = new DumbPanel();
add( dump, c );
Panel dumbPanel = new DumbPanel();
add(dumbPanel, c);

setSize( new Dimension( 300, 300));
setSize(300, 300);
}
}

Expand All @@ -115,8 +115,8 @@ public void paint(Graphics g) {
}
}

class DumbC extends Container {
public DumbC() {
class DumbContainer extends Container {
public DumbContainer() {
setLayout(new BorderLayout());
add("Center", new Fake("dumbc", Color.red));
}
Expand Down
11 changes: 7 additions & 4 deletions test/jdk/java/awt/Frame/WindowMoveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/*
* @test
Expand All @@ -53,7 +54,9 @@ public static void main(String[] args) throws Exception {
EventQueue.invokeAndWait(() ->
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)));

WindowMove.latch.await();
if (!WindowMove.latch.await(10, TimeUnit.SECONDS)) {
throw new RuntimeException("Test timeout.");
}

if (WindowMove.failMessage != null) {
throw new RuntimeException(WindowMove.failMessage);
Expand All @@ -66,7 +69,7 @@ class WindowMove extends Frame implements WindowListener {
new Rectangle(100, 100, 300, 300);

static CountDownLatch latch = new CountDownLatch(1);
static volatile String failMessage = null;
static String failMessage = null;

private boolean layoutCheck;
private boolean visibleCheck;
Expand All @@ -92,7 +95,7 @@ public WindowMove() {
if (checkBounds()) {
visibleCheck = true;
}
System.out.println("setVisible bounds: " + getBounds());
System.out.println("setVisible bounds: " + getBounds());
}

private boolean checkBounds() {
Expand All @@ -105,7 +108,7 @@ public void checkResult() {
&& openedCheck
&& closingCheck
&& closedCheck) {
System.out.println("Test passed");
System.out.println("Test passed.");
} else {
failMessage = """
Some of the checks failed:
Expand Down

0 comments on commit d5f7164

Please sign in to comment.