On Tue, 3 Sep 2024 18:02:33 GMT, Harshitha Onkar <[email protected]> wrote:
> > Individual robot.delay() can be added after UI creation and when frame
> > state is changed to stabilize the test.
>
> You are still missing some delays. Please check the diff lines in the
> following code snippet.
>
> ```
> @@ -124,16 +125,15 @@ public void runTest() throws Exception {
>
> try {
> robot = new Robot();
> + robot.waitForIdle();
> + robot.delay(1000); // delay after UI creation
>
> if (focusGainedLatch.await(3, TimeUnit.SECONDS)) {
> System.out.println("Button focus gained...");
> } else {
> System.out.println("Button focus not gained...");
> throw new RuntimeException(
> "Can't gain focus on button even after waiting " +
> "too long..");
> }
>
> System.out.println("Getting initial button image..image1");
> @@ -142,16 +142,18 @@ public void runTest() throws Exception {
> // some platforms may not support maximize frame
> if (frame.getToolkit().isFrameStateSupported(
> JFrame.MAXIMIZED_BOTH)) {
> - robot.waitForIdle(); // unnecessary waitForIdle can be
> removed
> // maximize frame from normal size
> frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
> System.out.println("Frame is maximized");
> robot.waitForIdle();
> robot.delay(100);
>
> if (frame.getToolkit().isFrameStateSupported(JFrame.NORMAL))
> {
> System.out.println("Frame is back to normal");
> // resize from maximum size to normal
> frame.setExtendedState(JFrame.NORMAL);
> + robot.waitForIdle();
> + robot.delay(100); // please add these two lines after
> frame state is changed again.
>
> @@ -192,7 +194,7 @@ public void runTest() throws Exception {
> private BufferedImage getButtonImage() {
> try {
> robot.waitForIdle();
> - robot.delay(1000);
> + robot.delay(300); this can be reduced from 1000 to ~300-500ms
> based on testing.
> ```
Done.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20777#issuecomment-2327134209