Skip to content

Commit 71f17d9

Browse files
committed
8293811: Provide a reason for PassFailJFrame.forceFail
Reviewed-by: mbaesken, shade Backport-of: 64b96e5cf57023a5d55b4392074e3922ac7c0534
1 parent 996c6f7 commit 71f17d9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

test/jdk/java/awt/regtesthelpers/PassFailJFrame.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class PassFailJFrame {
5656
private static final int ROWS = 10;
5757
private static final int COLUMNS = 40;
5858

59+
/**
60+
* Prefix for the user-provided failure reason.
61+
*/
62+
private static final String FAILURE_REASON = "Failure Reason:\n";
63+
5964
private static final List<Window> windowList = new ArrayList<>();
6065
private static final Timer timer = new Timer(0, null);
6166
private static final CountDownLatch latch = new CountDownLatch(1);
@@ -135,8 +140,8 @@ private static void createUI(String title, String instructions,
135140
long leftTime = tTimeout - (System.currentTimeMillis() - startTime);
136141
if ((leftTime < 0) || failed) {
137142
timer.stop();
138-
testFailedReason = "Failure Reason:\n"
139-
+ "Timeout User did not perform testing.";
143+
testFailedReason = FAILURE_REASON
144+
+ "Timeout User did not perform testing.";
140145
timeout = true;
141146
latch.countDown();
142147
}
@@ -166,8 +171,8 @@ private static void createUI(String title, String instructions,
166171
@Override
167172
public void windowClosing(WindowEvent e) {
168173
super.windowClosing(e);
169-
testFailedReason = "Failure Reason:\n"
170-
+ "User closed the instruction Frame";
174+
testFailedReason = FAILURE_REASON
175+
+ "User closed the instruction Frame";
171176
failed = true;
172177
latch.countDown();
173178
}
@@ -240,7 +245,7 @@ private static void getFailureReason() {
240245

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

@@ -403,9 +408,17 @@ public static void forcePass() {
403408
* Forcibly fail the test.
404409
*/
405410
public static void forceFail() {
411+
forceFail("forceFail called");
412+
}
413+
414+
/**
415+
* Forcibly fail the test and provide a reason.
416+
*
417+
* @param reason the reason why the test is failed
418+
*/
419+
public static void forceFail(String reason) {
406420
failed = true;
407-
testFailedReason = "Failure Reason:\n" +
408-
"forceFail called";
421+
testFailedReason = FAILURE_REASON + reason;
409422
latch.countDown();
410423
}
411424
}

0 commit comments

Comments
 (0)