Skip to content

Commit 4701b8e

Browse files
author
duke
committed
Backport 3762ec3978bfe9910929ab22aaf238e9f4c84630
1 parent da87df7 commit 4701b8e

File tree

1 file changed

+139
-57
lines changed

1 file changed

+139
-57
lines changed

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

Lines changed: 139 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -208,90 +208,172 @@ public final class PassFailJFrame {
208208

209209
public enum Position {HORIZONTAL, VERTICAL, TOP_LEFT_CORNER}
210210

211-
public PassFailJFrame(String instructions) throws InterruptedException,
212-
InvocationTargetException {
211+
/**
212+
* Constructs a frame which displays test instructions and
213+
* the <i>Pass</i> / <i>Fail</i> buttons with the given instructions, and
214+
* the default timeout of {@value #TEST_TIMEOUT} minutes,
215+
* the default title of {@value #TITLE} and
216+
* the default values of {@value #ROWS} and {@value #COLUMNS}
217+
* for rows and columns.
218+
* <p>
219+
* See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
220+
* more details.
221+
*
222+
* @param instructions the instructions for the tester
223+
*
224+
* @throws InterruptedException if the current thread is interrupted
225+
* while waiting for EDT to finish creating UI components
226+
* @throws InvocationTargetException if an exception is thrown while
227+
* creating UI components on EDT
228+
*/
229+
public PassFailJFrame(String instructions)
230+
throws InterruptedException, InvocationTargetException {
213231
this(instructions, TEST_TIMEOUT);
214232
}
215233

216-
public PassFailJFrame(String instructions, long testTimeOut) throws
217-
InterruptedException, InvocationTargetException {
234+
/**
235+
* Constructs a frame which displays test instructions and
236+
* the <i>Pass</i> / <i>Fail</i> buttons
237+
* with the given instructions and timeout as well as
238+
* the default title of {@value #TITLE}
239+
* and the default values of {@value #ROWS} and {@value #COLUMNS}
240+
* for rows and columns.
241+
* <p>
242+
* See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
243+
* more details.
244+
*
245+
* @param instructions the instructions for the tester
246+
* @param testTimeOut the test timeout in minutes
247+
*
248+
* @throws InterruptedException if the current thread is interrupted
249+
* while waiting for EDT to finish creating UI components
250+
* @throws InvocationTargetException if an exception is thrown while
251+
* creating UI components on EDT
252+
*/
253+
public PassFailJFrame(String instructions, long testTimeOut)
254+
throws InterruptedException, InvocationTargetException {
218255
this(TITLE, instructions, testTimeOut);
219256
}
220257

258+
/**
259+
* Constructs a frame which displays test instructions and
260+
* the <i>Pass</i> / <i>Fail</i> buttons
261+
* with the given title, instructions and timeout as well as
262+
* the default values of {@value #ROWS} and {@value #COLUMNS}
263+
* for rows and columns.
264+
* The screenshot feature is not enabled, if you use this constructor.
265+
* <p>
266+
* See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
267+
* more details.
268+
*
269+
* @param title the title of the instruction frame
270+
* @param instructions the instructions for the tester
271+
* @param testTimeOut the test timeout in minutes
272+
*
273+
* @throws InterruptedException if the current thread is interrupted
274+
* while waiting for EDT to finish creating UI components
275+
* @throws InvocationTargetException if an exception is thrown while
276+
* creating UI components on EDT
277+
*/
221278
public PassFailJFrame(String title, String instructions,
222-
long testTimeOut) throws InterruptedException,
223-
InvocationTargetException {
279+
long testTimeOut)
280+
throws InterruptedException, InvocationTargetException {
224281
this(title, instructions, testTimeOut, ROWS, COLUMNS);
225282
}
226283

227284
/**
228-
* Constructs a JFrame with a given title & serves as test instructional
229-
* frame where the user follows the specified test instruction in order
230-
* to test the test case & mark the test pass or fail. If the expected
231-
* result is seen then the user click on the 'Pass' button else click
232-
* on the 'Fail' button and the reason for the failure should be
233-
* specified in the JDialog JTextArea.
285+
* Constructs a frame which displays test instructions and
286+
* the <i>Pass</i> / <i>Fail</i> buttons
287+
* with the given title, instructions, timeout, number of rows and columns.
288+
* The screenshot feature is not enabled, if you use this constructor.
289+
* <p>
290+
* See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
291+
* more details.
234292
*
235-
* @param title title of the Frame.
236-
* @param instructions the instruction for the tester on how to test
237-
* and what is expected (pass) and what is not
238-
* expected (fail).
239-
* @param testTimeOut test timeout where time is specified in minutes.
240-
* @param rows number of visible rows of the JTextArea where the
241-
* instruction is show.
242-
* @param columns Number of columns of the instructional
243-
* JTextArea
244-
* @throws InterruptedException exception thrown when thread is
245-
* interrupted
293+
* @param title the title of the instruction frame
294+
* @param instructions the instructions for the tester
295+
* @param testTimeOut the test timeout in minutes
296+
* @param rows the number of rows for the text component
297+
* which displays test instructions
298+
* @param columns the number of columns for the text component
299+
* which displays test instructions
300+
*
301+
* @throws InterruptedException if the current thread is interrupted
302+
* while waiting for EDT to finish creating UI components
246303
* @throws InvocationTargetException if an exception is thrown while
247-
* creating the test instruction frame on
248-
* EDT
304+
* creating UI components on EDT
249305
*/
250-
public PassFailJFrame(String title, String instructions, long testTimeOut,
251-
int rows, int columns) throws InterruptedException,
252-
InvocationTargetException {
306+
public PassFailJFrame(String title, String instructions,
307+
long testTimeOut,
308+
int rows, int columns)
309+
throws InterruptedException, InvocationTargetException {
253310
this(title, instructions, testTimeOut, rows, columns, false);
254311
}
255312

256313
/**
257-
* Constructs a JFrame with a given title & serves as test instructional
258-
* frame where the user follows the specified test instruction in order
259-
* to test the test case & mark the test pass or fail. If the expected
260-
* result is seen then the user click on the 'Pass' button else click
261-
* on the 'Fail' button and the reason for the failure should be
262-
* specified in the JDialog JTextArea.
314+
* Constructs a frame which displays test instructions and
315+
* the <i>Pass</i> / <i>Fail</i> buttons
316+
* as well as supporting UI components with the given title, instructions,
317+
* timeout, number of rows and columns,
318+
* and screen capture functionality.
319+
* All the UI components are created on the EDT, so it is safe to call
320+
* the constructor on the main thread.
263321
* <p>
264-
* The test instruction frame also provides a way for the tester to take
265-
* a screenshot (full screen or individual frame) if this feature
266-
* is enabled by passing {@code true} as {@code enableScreenCapture}
267-
* parameter.
322+
* After you create a test UI window, register the window using
323+
* {@link #addTestWindow(Window) addTestWindow} for disposal, and
324+
* position it close to the instruction frame using
325+
* {@link #positionTestWindow(Window, Position) positionTestWindow}.
326+
* As the last step, make your test UI window visible.
327+
* <p>
328+
* Call the {@link #awaitAndCheck() awaitAndCheck} method on the instance
329+
* of {@code PassFailJFrame} when you set up the testing environment.
330+
* <p>
331+
* If the tester clicks the <i>Fail</i> button, a dialog prompting for
332+
* a description of the problem is displayed, and then an exception
333+
* is thrown which fails the test.
334+
* If the tester clicks the <i>Pass</i> button, the test completes
335+
* successfully.
336+
* If the timeout occurs or the instruction frame is closed,
337+
* the test fails.
338+
* <p>
339+
* The {@code rows} and {@code columns} parameters control
340+
* the size of a text component which displays the instructions.
341+
* The preferred size of the instructions is calculated by
342+
* creating {@code new JTextArea(rows, columns)}.
343+
* <p>
344+
* If you enable screenshots by setting the {@code screenCapture}
345+
* parameter to {@code true}, a <i>Screenshot</i> button is added.
346+
* Clicking the <i>Screenshot</i> button takes screenshots of
347+
* all the monitors or all the windows registered with
348+
* {@code PassFailJFrame}.
268349
*
269-
* @param title title of the Frame.
270-
* @param instructions the instruction for the tester on how to test
271-
* and what is expected (pass) and what is not
272-
* expected (fail).
273-
* @param testTimeOut test timeout where time is specified in minutes.
274-
* @param rows number of visible rows of the JTextArea where the
275-
* instruction is show.
276-
* @param columns Number of columns of the instructional
277-
* JTextArea
278-
* @param enableScreenCapture if set to true, 'Capture Screen' button & its
279-
* associated UIs are added to test instruction
280-
* frame
281-
* @throws InterruptedException exception thrown when thread is
282-
* interrupted
350+
* @param title the title of the instruction frame
351+
* @param instructions the instructions for the tester
352+
* @param testTimeOut the test timeout in minutes
353+
* @param rows the number of rows for the text component
354+
* which displays test instructions
355+
* @param columns the number of columns for the text component
356+
* which displays test instructions
357+
* @param screenCapture if set to {@code true}, enables screen capture
358+
* functionality
359+
*
360+
* @throws InterruptedException if the current thread is interrupted
361+
* while waiting for EDT to finish creating UI components
283362
* @throws InvocationTargetException if an exception is thrown while
284-
* creating the test instruction frame on
285-
* EDT
363+
* creating UI components on EDT
364+
*
365+
* @see JTextArea#JTextArea(int,int) JTextArea(int rows, int columns)
366+
* @see Builder Builder
286367
*/
287-
public PassFailJFrame(String title, String instructions, long testTimeOut,
368+
public PassFailJFrame(String title, String instructions,
369+
long testTimeOut,
288370
int rows, int columns,
289-
boolean enableScreenCapture)
371+
boolean screenCapture)
290372
throws InterruptedException, InvocationTargetException {
291373
invokeOnEDT(() -> createUI(title, instructions,
292374
testTimeOut,
293375
rows, columns,
294-
enableScreenCapture));
376+
screenCapture));
295377
}
296378

297379
/**

0 commit comments

Comments
 (0)