8325851: Hide PassFailJFrame.Builder constructor

Reviewed-by: honkar, prr
This commit is contained in:
Alexey Ivanov 2024-03-14 10:57:30 +00:00
parent ad0f329493
commit 3b9255eb66
21 changed files with 124 additions and 228 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,7 +21,6 @@
* questions. * questions.
*/ */
import java.awt.EventQueue;
import java.awt.Frame; import java.awt.Frame;
/* /*
@ -44,25 +43,15 @@ public class DefaultSizeTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("DefaultSizeTest Instructions Frame") .title("DefaultSizeTest Instructions Frame")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(10) .rows(10)
.columns(45) .columns(45)
.testUI(() -> new Frame("DefaultSize"))
.screenCapture() .screenCapture()
.build(); .build()
.awaitAndCheck();
EventQueue.invokeAndWait(() -> {
Frame frame = new Frame("DefaultSize");
PassFailJFrame.addTestWindow(frame);
PassFailJFrame
.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -77,25 +77,15 @@ public class FrameRepackTest {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("FrameRepackTest Instructions") .title("FrameRepackTest Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(30) .rows(30)
.columns(45) .columns(45)
.build(); .testUI(FrameRepack::new)
.build()
EventQueue.invokeAndWait(() -> { .awaitAndCheck();
FrameRepack frame = new FrameRepack();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,6 @@
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Canvas; import java.awt.Canvas;
import java.awt.Color; import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Frame; import java.awt.Frame;
/* /*
@ -53,25 +52,15 @@ public class FrameResizeTest_1 {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("FrameResizeTest_1 Instructions") .title("FrameResizeTest_1 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(12) .rows(12)
.columns(45) .columns(45)
.build(); .testUI(FrameResize_1::new)
.build()
EventQueue.invokeAndWait(() -> { .awaitAndCheck();
FrameResize_1 frame = new FrameResize_1();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@ import java.awt.Canvas;
import java.awt.Color; import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
@ -57,25 +56,15 @@ public class FrameResizeTest_2 {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("FrameResizeTest_2 Instructions") .title("FrameResizeTest_2 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(10) .rows(10)
.columns(45) .columns(45)
.build(); .testUI(FrameResize_2::new)
.build()
EventQueue.invokeAndWait(() -> { .awaitAndCheck();
FrameResize_2 frame = new FrameResize_2();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,6 @@ import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Graphics; import java.awt.Graphics;
@ -49,32 +48,28 @@ public class LightweightCliprect {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("LightweightCliprect Instructions Frame") .title("LightweightCliprect Instructions Frame")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(10) .rows(10)
.columns(45) .columns(45)
.build(); .testUI(LightweightCliprect::createUI)
.build()
.awaitAndCheck();
}
EventQueue.invokeAndWait(() -> { private static Frame createUI() {
Frame frame = new Frame("DefaultSize"); Frame frame = new Frame("DefaultSize");
Container panel = new MyContainer(); Container panel = new MyContainer();
MyComponent c = new MyComponent(); MyComponent c = new MyComponent();
panel.add(c); panel.add(c);
frame.add(panel); frame.add(panel);
frame.setSize(400, 300); frame.setSize(400, 300);
PassFailJFrame.addTestWindow(frame); return frame;
PassFailJFrame
.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@ import java.awt.Menu;
import java.awt.MenuBar; import java.awt.MenuBar;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
/* /*
* @test * @test
@ -58,25 +57,15 @@ public class AddRemoveMenuBarTest_1 {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("AddRemoveMenuBarTest_1 Instructions") .title("AddRemoveMenuBarTest_1 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(18) .rows(18)
.columns(45) .columns(45)
.build(); .testUI(AddRemoveMenuBar_1::new)
.build()
SwingUtilities.invokeAndWait(() -> { .awaitAndCheck();
AddRemoveMenuBar_1 frame = new AddRemoveMenuBar_1();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@ import java.awt.Menu;
import java.awt.MenuBar; import java.awt.MenuBar;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
/* /*
* @test * @test
@ -54,25 +53,15 @@ public class AddRemoveMenuBarTest_2 {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("AddRemoveMenuBarTest_2 Instructions") .title("AddRemoveMenuBarTest_2 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(15) .rows(15)
.columns(45) .columns(45)
.build(); .testUI(AddRemoveMenuBar_2::new)
.build()
SwingUtilities.invokeAndWait(() -> { .awaitAndCheck();
AddRemoveMenuBar_2 frame = new AddRemoveMenuBar_2();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,7 +34,6 @@ import java.awt.TextField;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter; import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import javax.swing.SwingUtilities;
/* /*
* @test * @test
@ -76,25 +75,15 @@ public class AddRemoveMenuBarTest_3 {
Upon test completion, click Pass or Fail appropriately. Upon test completion, click Pass or Fail appropriately.
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("AddRemoveMenuBarTest_3 Instructions") .title("AddRemoveMenuBarTest_3 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(30) .rows(30)
.columns(38) .columns(38)
.build(); .testUI(AddRemoveMenuBar_3::new)
.build()
SwingUtilities.invokeAndWait(() -> { .awaitAndCheck();
AddRemoveMenuBar_3 frame = new AddRemoveMenuBar_3();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(null,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,6 @@ import java.awt.Frame;
import java.awt.Menu; import java.awt.Menu;
import java.awt.MenuBar; import java.awt.MenuBar;
import java.awt.MenuItem; import java.awt.MenuItem;
import javax.swing.SwingUtilities;
/* /*
* @test * @test
@ -61,25 +60,15 @@ public class AddRemoveMenuBarTest_4 {
"""; """;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("AddRemoveMenuBarTest_4 Instructions") .title("AddRemoveMenuBarTest_4 Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(18) .rows(18)
.columns(45) .columns(45)
.build(); .testUI(AddRemoveMenuBar_4::new)
.build()
SwingUtilities.invokeAndWait(() -> { .awaitAndCheck();
AddRemoveMenuBar_4 frame = new AddRemoveMenuBar_4();
PassFailJFrame.addTestWindow(frame);
PassFailJFrame.positionTestWindow(frame,
PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -85,7 +85,7 @@ public class TrayIconScalingTest {
System.out.println("SystemTray is not supported"); System.out.println("SystemTray is not supported");
return; return;
} }
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("TrayIcon Test Instructions") .title("TrayIcon Test Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(8) .testTimeOut(8)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -79,7 +79,7 @@ public class AcceleratorTest {
cmdHash.put(CMD[i], 0); cmdHash.put(CMD[i], 0);
} }
PassFailJFrame testFrame = new PassFailJFrame.Builder() PassFailJFrame testFrame = PassFailJFrame.builder()
.title("Test Instructions Frame") .title("Test Instructions Frame")
.instructions(instructions) .instructions(instructions)
.testTimeOut(10) .testTimeOut(10)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -372,7 +372,7 @@ public class PathHitTest {
} }
public static void doManual() throws Exception { public static void doManual() throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("PathHitTestManual Instructions") .title("PathHitTestManual Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -167,7 +167,7 @@ public class CustomPaper implements Pageable, Printable {
+ "Valid values: 4355514 or 4385157"); + "Valid values: 4355514 or 4385157");
}; };
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("CustomPaper Test Instructions") .title("CustomPaper Test Instructions")
.instructions(instructions) .instructions(instructions)
.testTimeOut(5) .testTimeOut(5)

View File

@ -1059,6 +1059,14 @@ public final class PassFailJFrame {
private Position position; private Position position;
/**
* A private constructor for the builder,
* it should not be created directly.
* Use {@code PassFailJFrame.builder()} method instead.
*/
private Builder() {
}
public Builder title(String title) { public Builder title(String title) {
this.title = title; this.title = title;
return this; return this;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,7 +54,7 @@ public class TestJComboBoxScreenMagnifier {
public static void main(String[] args) throws InterruptedException, public static void main(String[] args) throws InterruptedException,
InvocationTargetException { InvocationTargetException {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("JComboBox Screen Magnifier Test Instructions") .title("JComboBox Screen Magnifier Test Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)

View File

@ -24,7 +24,6 @@
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingUtilities;
/* /*
* @test * @test
@ -45,48 +44,43 @@ public class ComboPopupBug {
Click on Close and then click on JComboBox arrow button Click on Close and then click on JComboBox arrow button
to try to show combobox popup. to try to show combobox popup.
If IllegalStateException is thrown, test will automatically Fail If IllegalStateException is thrown, test will automatically Fail
otherwise click Pass. """; otherwise click Pass.""";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("ComboPopup Instructions") .title("ComboPopup Instructions")
.instructions(instructionsText) .instructions(instructionsText)
.testTimeOut(5) .testTimeOut(5)
.rows(10) .rows(10)
.columns(35) .columns(35)
.build(); .testUI(ComboPopupBug::createUI)
.build()
.awaitAndCheck();
}
SwingUtilities.invokeAndWait(() -> { private static JFrame createUI() {
JFrame frame = new JFrame("ComboPopup"); JFrame frame = new JFrame("ComboPopup");
JComboBox cb = new JComboBox(); JComboBox<String> cb = new JComboBox<>();
cb.setEditable(true); cb.setEditable(true);
cb.addItem("test"); cb.addItem("test");
cb.addItem("test2"); cb.addItem("test2");
cb.addItem("test3"); cb.addItem("test3");
frame.getContentPane().add(cb, "North");
JButton b = new JButton("Close"); JButton b = new JButton("Close");
b.addActionListener( b.addActionListener(
(e)->{ (e)->{
try { try {
Thread.sleep(3000); Thread.sleep(3000);
} } catch (Exception ignored) {
catch (Exception ex) {
} }
frame.setVisible(false); frame.setVisible(false);
}); });
frame.getContentPane().add(b, "South");
frame.setSize(200, 200);
PassFailJFrame.addTestWindow(frame); frame.getContentPane().add(cb, "North");
PassFailJFrame.positionTestWindow(frame, frame.getContentPane().add(b, "South");
PassFailJFrame.Position.HORIZONTAL); frame.setSize(200, 200);
frame.setVisible(true); return frame;
});
passFailJFrame.awaitAndCheck();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,7 +32,6 @@ import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
/* /*
@ -73,31 +72,26 @@ public class DefaultCloseOperation extends JPanel {
JComboBox<String> dialogCloseOp; JComboBox<String> dialogCloseOp;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame.builder()
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder()
.title("DefaultCloseOperation Manual Test") .title("DefaultCloseOperation Manual Test")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)
.rows(20) .rows(20)
.columns(70) .columns(50)
.build(); .testUI(DefaultCloseOperation::createUI)
.build()
.awaitAndCheck();
}
SwingUtilities.invokeAndWait(() -> { private static JFrame createUI() {
DefaultCloseOperation dco = new DefaultCloseOperation(); DefaultCloseOperation dco = new DefaultCloseOperation();
dco.init(); dco.init();
JFrame frame = new JFrame("DefaultCloseOperation"); JFrame frame = new JFrame("DefaultCloseOperation");
frame.add(dco); frame.add(dco);
frame.setSize(500,200); frame.setSize(500,200);
PassFailJFrame.addTestWindow(frame); return frame;
PassFailJFrame
.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
frame.setVisible(true);
});
passFailJFrame.awaitAndCheck();
} }
public void init() { public void init() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,7 +49,7 @@ public class TestJTabbedPaneArrowDirection {
private static JFrame frame; private static JFrame frame;
private static JTabbedPane tabPane; private static JTabbedPane tabPane;
private static final String INSTRUCTIONS = private static final String INSTRUCTIONS =
"1. Observe the arrows are ponting to left and right direction\n" + "1. Observe the arrows are pointing to left and right direction\n" +
" for tab placement set to TOP. Default tab placement is TOP.\n\n" + " for tab placement set to TOP. Default tab placement is TOP.\n\n" +
"2. Press BOTTOM to change the tab placement to bottom.\n\n" + "2. Press BOTTOM to change the tab placement to bottom.\n\n" +
"3. Observe arrows are pointing to the left and right direction.\n\n" + "3. Observe arrows are pointing to the left and right direction.\n\n" +
@ -57,7 +57,7 @@ public class TestJTabbedPaneArrowDirection {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("JTabbedPane Arrow Direction Test Instructions") .title("JTabbedPane Arrow Direction Test Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,7 +49,7 @@ public class bug4203039 {
locations but can dock on the NORTH and WEST"""; locations but can dock on the NORTH and WEST""";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("bug4203039 Instructions") .title("bug4203039 Instructions")
.instructions(instructionsText) .instructions(instructionsText)
.testTimeOut(5) .testTimeOut(5)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -38,9 +38,8 @@ import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import javax.swing.JViewport;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingUtilities; import javax.swing.JViewport;
public class MultimonVImage { public class MultimonVImage {
private static final String instructionsText = private static final String instructionsText =
@ -64,25 +63,20 @@ public class MultimonVImage {
" issue, try to use the same or similar video cards for each monitor."; " issue, try to use the same or similar video cards for each monitor.";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame.builder()
.title("MultimonVImage Instructions") .title("MultimonVImage Instructions")
.instructions(instructionsText) .instructions(instructionsText)
.testTimeOut(5) .testTimeOut(5)
.rows(25) .rows(25)
.columns(50) .columns(50)
.build(); .testUI(() -> {
AnimatingFrame af = new AnimatingFrame();
SwingUtilities.invokeAndWait(() -> { af.test();
AnimatingFrame af = new AnimatingFrame(); af.run();
af.test(); return af;
af.run(); })
.build()
PassFailJFrame.addTestWindow(af); .awaitAndCheck();
PassFailJFrame.positionTestWindow(af,
PassFailJFrame.Position.HORIZONTAL);
});
passFailJFrame.awaitAndCheck();
} }
} }
@ -164,9 +158,7 @@ class AnimatingFrame extends JFrame implements Runnable {
setContentPane(component); setContentPane(component);
component.setVisible(true); component.setVisible(true);
setLocationRelativeTo(null);
pack(); pack();
setVisible(true);
} }
public void test() { public void test() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -90,7 +90,7 @@ public class PaletteTester {
public static void main( String args[] ) throws Exception { public static void main( String args[] ) throws Exception {
PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() PassFailJFrame passFailJFrame = PassFailJFrame.builder()
.title("PaletteTester Instructions") .title("PaletteTester Instructions")
.instructions(INSTRUCTIONS) .instructions(INSTRUCTIONS)
.testTimeOut(5) .testTimeOut(5)