Skip to content

Commit 1da8997

Browse files
author
duke
committed
Backport 4ba170c
1 parent 83aab07 commit 1da8997

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.io.File;
4545
import java.io.IOException;
4646
import java.lang.reflect.InvocationTargetException;
47+
import java.nio.file.Paths;
4748
import java.util.ArrayList;
4849
import java.util.Arrays;
4950
import java.util.Collection;
@@ -165,17 +166,23 @@
165166
*/
166167
public final class PassFailJFrame {
167168

168-
private static final String TITLE = "Test Instruction Frame";
169+
/** A default title for the instruction frame. */
170+
private static final String TITLE = "Test Instructions";
171+
172+
/** A default test timeout. */
169173
private static final long TEST_TIMEOUT = 5;
174+
175+
/** A default number of rows for displaying the test instructions. */
170176
private static final int ROWS = 10;
177+
/** A default number of columns for displaying the test instructions. */
171178
private static final int COLUMNS = 40;
172179

173180
/**
174181
* Prefix for the user-provided failure reason.
175182
*/
176183
private static final String FAILURE_REASON = "Failure Reason:\n";
177184
/**
178-
* The failure reason message when the user didn't provide one.
185+
* The failure reason message when the user doesn't provide one.
179186
*/
180187
private static final String EMPTY_REASON = "(no reason provided)";
181188

@@ -1506,9 +1513,41 @@ public PassFailJFrame build() throws InterruptedException,
15061513
return new PassFailJFrame(this);
15071514
}
15081515

1516+
/**
1517+
* Returns the file name of the test, if the {@code test.file} property
1518+
* is defined, concatenated with {@code " - "} which serves as a prefix
1519+
* to the default instruction frame title;
1520+
* or an empty string if the {@code test.file} property is not defined.
1521+
*
1522+
* @return the prefix to the default title:
1523+
* either the file name of the test or an empty string
1524+
*
1525+
* @see <a href="https://openjdk.org/jtreg/tag-spec.html#testvars">jtreg
1526+
* test-specific system properties and environment variables</a>
1527+
*/
1528+
private static String getTestFileNamePrefix() {
1529+
String testFile = System.getProperty("test.file");
1530+
if (testFile == null) {
1531+
return "";
1532+
}
1533+
1534+
return Paths.get(testFile).getFileName().toString()
1535+
+ " - ";
1536+
}
1537+
1538+
/**
1539+
* Validates the state of the builder and
1540+
* expands parameters that have no assigned values
1541+
* to their default values.
1542+
*
1543+
* @throws IllegalStateException if no instructions are provided,
1544+
* or if {@code PositionWindows} implementation is
1545+
* provided but neither window creator nor
1546+
* test window list are set
1547+
*/
15091548
private void validate() {
15101549
if (title == null) {
1511-
title = TITLE;
1550+
title = getTestFileNamePrefix() + TITLE;
15121551
}
15131552

15141553
if (instructions == null || instructions.isEmpty()) {

0 commit comments

Comments
 (0)