8293811: Provide a reason for PassFailJFrame.forceFail
Reviewed-by: honkar, jdv
This commit is contained in:
parent
f91762f56e
commit
64b96e5cf5
test/jdk
@ -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);
|
||||
@ -135,8 +140,8 @@ public class PassFailJFrame {
|
||||
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();
|
||||
}
|
||||
@ -166,8 +171,8 @@ public class PassFailJFrame {
|
||||
@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();
|
||||
}
|
||||
@ -240,7 +245,7 @@ public class PassFailJFrame {
|
||||
|
||||
JButton okButton = new JButton("OK");
|
||||
okButton.addActionListener((ae) -> {
|
||||
testFailedReason = "Failure Reason:\n" + jTextArea.getText();
|
||||
testFailedReason = FAILURE_REASON + jTextArea.getText();
|
||||
dialog.setVisible(false);
|
||||
});
|
||||
|
||||
@ -403,9 +408,17 @@ public class PassFailJFrame {
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ import javax.swing.WindowConstants;
|
||||
public class PrintAllPagesTest {
|
||||
static JFrame f;
|
||||
static JTable table;
|
||||
static volatile boolean ret = false;
|
||||
|
||||
static final String INSTRUCTIONS = """
|
||||
Note: You must have a printer installed for this test.
|
||||
@ -71,13 +70,15 @@ public class PrintAllPagesTest {
|
||||
// Arrange the test instruction frame and test frame side by side
|
||||
PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
|
||||
f.setVisible(true);
|
||||
|
||||
boolean ret;
|
||||
try {
|
||||
ret = table.print();
|
||||
} catch (PrinterException ex) {
|
||||
ret = false;
|
||||
}
|
||||
if (!ret) {
|
||||
throw new RuntimeException("Printing cancelled/failed");
|
||||
PassFailJFrame.forceFail("Printing cancelled/failed");
|
||||
}
|
||||
});
|
||||
passFailJFrame.awaitAndCheck();
|
||||
@ -108,6 +109,6 @@ public class PrintAllPagesTest {
|
||||
|
||||
f = new JFrame("Table test");
|
||||
f.add(scrollpane);
|
||||
f.setSize(1000, 800);
|
||||
f.setSize(500, 400);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user