Skip to content

Commit de9ae1e

Browse files
Sonia Zaldana CallesPaul Hohensee
Sonia Zaldana Calles
authored and
Paul Hohensee
committedNov 1, 2023
8293811: Provide a reason for PassFailJFrame.forceFail
Reviewed-by: phh Backport-of: 64b96e5cf57023a5d55b4392074e3922ac7c0534
1 parent 32e63eb commit de9ae1e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed
 

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

+20-5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public class PassFailJFrame {
5151
private static final int ROWS = 10;
5252
private static final int COLUMNS = 40;
5353

54+
/**
55+
* Prefix for the user-provided failure reason.
56+
*/
57+
private static final String FAILURE_REASON = "Failure Reason:\n";
58+
5459
private static final List<Frame> frameList = new ArrayList<>();
5560
private static final Timer timer = new Timer(0, null);
5661
private static final CountDownLatch latch = new CountDownLatch(1);
@@ -130,8 +135,8 @@ private static void createUI(String title, String instructions,
130135
long leftTime = tTimeout - (System.currentTimeMillis() - startTime);
131136
if ((leftTime < 0) || failed) {
132137
timer.stop();
133-
testFailedReason = "Failure Reason:\n"
134-
+ "Timeout User did not perform testing.";
138+
testFailedReason = FAILURE_REASON
139+
+ "Timeout User did not perform testing.";
135140
timeout = true;
136141
latch.countDown();
137142
}
@@ -161,8 +166,8 @@ private static void createUI(String title, String instructions,
161166
@Override
162167
public void windowClosing(WindowEvent e) {
163168
super.windowClosing(e);
164-
testFailedReason = "Failure Reason:\n"
165-
+ "User closed the instruction Frame";
169+
testFailedReason = FAILURE_REASON
170+
+ "User closed the instruction Frame";
166171
failed = true;
167172
latch.countDown();
168173
}
@@ -236,7 +241,7 @@ private static void getFailureReason() {
236241

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

@@ -314,7 +319,17 @@ public static void forcePass() {
314319
* Forcibly fail the test.
315320
*/
316321
public static void forceFail() {
322+
forceFail("forceFail called");
323+
}
324+
325+
/**
326+
* Forcibly fail the test and provide a reason.
327+
*
328+
* @param reason the reason why the test is failed
329+
*/
330+
public static void forceFail(String reason) {
317331
failed = true;
332+
testFailedReason = FAILURE_REASON + reason;
318333
latch.countDown();
319334
}
320335
}

0 commit comments

Comments
 (0)
Please sign in to comment.