Navigation Menu

Skip to content

Commit

Permalink
8293811: Provide a reason for PassFailJFrame.forceFail
Browse files Browse the repository at this point in the history
Reviewed-by: mbaesken, shade
Backport-of: 64b96e5cf57023a5d55b4392074e3922ac7c0534
  • Loading branch information
TheRealMDoerr committed Jul 4, 2023
1 parent 996c6f7 commit 71f17d9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
Expand Up @@ -56,6 +56,11 @@ public class PassFailJFrame {
private static final int ROWS = 10;
private static final int COLUMNS = 40;

/**
* Prefix for the user-provided failure reason.
*/
private static final String FAILURE_REASON = "Failure Reason:\n";

private static final List<Window> windowList = new ArrayList<>();
private static final Timer timer = new Timer(0, null);
private static final CountDownLatch latch = new CountDownLatch(1);
Expand Down Expand Up @@ -135,8 +140,8 @@ private static void createUI(String title, String instructions,
long leftTime = tTimeout - (System.currentTimeMillis() - startTime);
if ((leftTime < 0) || failed) {
timer.stop();
testFailedReason = "Failure Reason:\n"
+ "Timeout User did not perform testing.";
testFailedReason = FAILURE_REASON
+ "Timeout User did not perform testing.";
timeout = true;
latch.countDown();
}
Expand Down Expand Up @@ -166,8 +171,8 @@ private static void createUI(String title, String instructions,
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
testFailedReason = "Failure Reason:\n"
+ "User closed the instruction Frame";
testFailedReason = FAILURE_REASON
+ "User closed the instruction Frame";
failed = true;
latch.countDown();
}
Expand Down Expand Up @@ -240,7 +245,7 @@ private static void getFailureReason() {

JButton okButton = new JButton("OK");
okButton.addActionListener((ae) -> {
testFailedReason = "Failure Reason:\n" + jTextArea.getText();
testFailedReason = FAILURE_REASON + jTextArea.getText();
dialog.setVisible(false);
});

Expand Down Expand Up @@ -403,9 +408,17 @@ public static void forcePass() {
* Forcibly fail the test.
*/
public static void forceFail() {
forceFail("forceFail called");
}

/**
* Forcibly fail the test and provide a reason.
*
* @param reason the reason why the test is failed
*/
public static void forceFail(String reason) {
failed = true;
testFailedReason = "Failure Reason:\n" +
"forceFail called";
testFailedReason = FAILURE_REASON + reason;
latch.countDown();
}
}

1 comment on commit 71f17d9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.