|
44 | 44 | import java.io.File; |
45 | 45 | import java.io.IOException; |
46 | 46 | import java.lang.reflect.InvocationTargetException; |
| 47 | +import java.nio.file.Paths; |
47 | 48 | import java.util.ArrayList; |
48 | 49 | import java.util.Arrays; |
49 | 50 | import java.util.Collection; |
|
165 | 166 | */ |
166 | 167 | public final class PassFailJFrame { |
167 | 168 |
|
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. */ |
169 | 173 | private static final long TEST_TIMEOUT = 5; |
| 174 | + |
| 175 | + /** A default number of rows for displaying the test instructions. */ |
170 | 176 | private static final int ROWS = 10; |
| 177 | + /** A default number of columns for displaying the test instructions. */ |
171 | 178 | private static final int COLUMNS = 40; |
172 | 179 |
|
173 | 180 | /** |
174 | 181 | * Prefix for the user-provided failure reason. |
175 | 182 | */ |
176 | 183 | private static final String FAILURE_REASON = "Failure Reason:\n"; |
177 | 184 | /** |
178 | | - * The failure reason message when the user didn't provide one. |
| 185 | + * The failure reason message when the user doesn't provide one. |
179 | 186 | */ |
180 | 187 | private static final String EMPTY_REASON = "(no reason provided)"; |
181 | 188 |
|
@@ -1506,9 +1513,41 @@ public PassFailJFrame build() throws InterruptedException, |
1506 | 1513 | return new PassFailJFrame(this); |
1507 | 1514 | } |
1508 | 1515 |
|
| 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 | + */ |
1509 | 1548 | private void validate() { |
1510 | 1549 | if (title == null) { |
1511 | | - title = TITLE; |
| 1550 | + title = getTestFileNamePrefix() + TITLE; |
1512 | 1551 | } |
1513 | 1552 |
|
1514 | 1553 | if (instructions == null || instructions.isEmpty()) { |
|
0 commit comments