Skip to content

Commit

Permalink
8320113: [macos14] : ShapeNotSetSometimes.java fails intermittently o…
Browse files Browse the repository at this point in the history
…n macOS 14

Reviewed-by: dnguyen, azvegint, kizune
  • Loading branch information
Harshitha Onkar committed Jan 19, 2024
1 parent 8700de6 commit f1b7335
Showing 1 changed file with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,45 +21,50 @@
* questions.
*/

/*
@test
@key headful
@bug 6988428
@summary Tests whether shape is always set
@author anthony.petrov@oracle.com: area=awt.toplevel
@run main ShapeNotSetSometimes
*/


import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

/*
* @test
* @key headful
* @bug 6988428
* @summary Tests whether shape is always set
* @run main ShapeNotSetSometimes
*/

public class ShapeNotSetSometimes {

private Frame backgroundFrame;
private Frame window;
private static final Color BACKGROUND_COLOR = Color.GREEN;
private static final Color SHAPE_COLOR = Color.WHITE;

private Point[] pointsOutsideToCheck;
private Point[] shadedPointsToCheck;
private Point innerPoint;

private final Rectangle bounds = new Rectangle(220, 400, 300, 300);

private static Robot robot;
private static final Color BACKGROUND_COLOR = Color.GREEN;
private static final Color SHAPE_COLOR = Color.WHITE;

public ShapeNotSetSometimes() throws Exception {
EventQueue.invokeAndWait(this::initializeGUI);
robot.waitForIdle();
robot.delay(1000);
}

private void initializeGUI() {
Expand Down Expand Up @@ -124,7 +129,7 @@ public void paint(Graphics g) {
public static void main(String[] args) throws Exception {
robot = new Robot();

for(int i = 0; i < 50; i++) {
for (int i = 1; i <= 50; i++) {
System.out.println("Attempt " + i);
new ShapeNotSetSometimes().doTest();
}
Expand All @@ -136,7 +141,6 @@ private void doTest() throws Exception {

EventQueue.invokeAndWait(window::toFront);
robot.waitForIdle();

robot.delay(500);

try {
Expand Down Expand Up @@ -173,8 +177,8 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte
);

if (mustBeExpectedColor != expectedColor.equals(actualColor)) {
captureScreen();
System.out.printf("window.getX() = %3d, window.getY() = %3d\n", window.getX(), window.getY());

System.err.printf(
"Checking for transparency failed: point: %3d, %3d\n\tactual %s\n\texpected %s%s\n",
screenX,
Expand All @@ -185,4 +189,18 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte
throw new RuntimeException("Test failed. The shape has not been applied.");
}
}

private static void captureScreen() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenBounds = new Rectangle(0, 0, screenSize.width, screenSize.height);
try {
ImageIO.write(
robot.createScreenCapture(screenBounds),
"png",
new File("Screenshot.png")
);
} catch (IOException e) {
e.printStackTrace();
}
}
}

7 comments on commit f1b7335

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luchenlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f1b7335 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luchenlin the backport was successfully created on the branch backport-luchenlin-f1b73350 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f1b73350 from the openjdk/jdk repository.

The commit being backported was authored by Harshitha Onkar on 19 Jan 2024 and was reviewed by Damon Nguyen, Alexander Zvegintsev and Alexander Zuev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-luchenlin-f1b73350:backport-luchenlin-f1b73350
$ git checkout backport-luchenlin-f1b73350
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-luchenlin-f1b73350

@luchenlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@luchenlin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f1b7335 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luchenlin the backport was successfully created on the branch backport-luchenlin-f1b73350 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f1b73350 from the openjdk/jdk repository.

The commit being backported was authored by Harshitha Onkar on 19 Jan 2024 and was reviewed by Damon Nguyen, Alexander Zvegintsev and Alexander Zuev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-luchenlin-f1b73350:backport-luchenlin-f1b73350
$ git checkout backport-luchenlin-f1b73350
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-luchenlin-f1b73350

@openjdk
Copy link

@openjdk openjdk bot commented on f1b7335 Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luchenlin the backport was successfully created on the branch backport-luchenlin-f1b73350 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f1b73350 from the openjdk/jdk repository.

The commit being backported was authored by Harshitha Onkar on 19 Jan 2024 and was reviewed by Damon Nguyen, Alexander Zvegintsev and Alexander Zuev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev.git backport-luchenlin-f1b73350:backport-luchenlin-f1b73350
$ git checkout backport-luchenlin-f1b73350
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev.git backport-luchenlin-f1b73350

Please sign in to comment.