Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8353138: Screen capture for test TaskbarPositionTest.java, failure case #24286

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Renjithkannath
Copy link
Contributor

@Renjithkannath Renjithkannath commented Mar 28, 2025

Hi Reviewers,

Added screen capture in case of test failure using Robot.

Please review and let me know your suggestion if any.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8353138: Screen capture for test TaskbarPositionTest.java, failure case (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24286/head:pull/24286
$ git checkout pull/24286

Update a local copy of the PR:
$ git checkout pull/24286
$ git pull https://git.openjdk.org/jdk.git pull/24286/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24286

View PR using the GUI difftool:
$ git pr show -t 24286

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24286.diff

Using Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 28, 2025

👋 Welcome back rkannathpari! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 28, 2025

@Renjithkannath This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8353138: Screen capture for test TaskbarPositionTest.java, failure case

Reviewed-by: aivanov, serb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 106 new commits pushed to the master branch:

  • 1161b56: 8353053: (fs) Add support for UserDefinedFileAttributeView on AIX
  • a13e34d: 8353274: [PPC64] Bug related to -XX:+UseCompactObjectHeaders -XX:-UseSIGTRAP in JDK-8305895
  • 41d4a0d: 8352392: AIX: implement attach API v2 and streaming output
  • 1c2a553: 8327858: Improve spliterator and forEach for single-element immutable collections
  • a449aee: 8350704: Create tests to ensure the failure behavior of core reflection APIs
  • 57df89c: 8353684: [BACKOUT] j.u.l.Handler classes create deadlock risk via synchronized publish() method
  • ebcb9a8: 8349206: j.u.l.Handler classes create deadlock risk via synchronized publish() method
  • d894b78: 8353588: [REDO] DaCapo xalan performance with -XX:+UseObjectMonitorTable
  • db08726: 8352966: Opensource Several Font related tests - Batch 2
  • 6b7b324: 8351431: Type annotations on new class creation expressions can't be retrieved
  • ... and 96 more: https://git.openjdk.org/jdk/compare/f4428e89b7d9f00833a437f08fe0c0bbcec87a11...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mrserb, @aivanov-jdk) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 28, 2025
@openjdk
Copy link

openjdk bot commented Mar 28, 2025

@Renjithkannath The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Mar 28, 2025
@mlbridge
Copy link

mlbridge bot commented Mar 28, 2025

Webrevs

Copy link
Member

@myankelev myankelev left a comment

Choose a reason for hiding this comment

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

Just a few minor questions.

Also, it seems that the screenshot code is repeated all over the place. Wouldn't it make sense to make a utility/add it to an existing utility class for further use to standardise it and make it simpler to maintain in time? I know this is well beyond the scope of this ticket, but just thought to mention the idea 😃

        BufferedImage image = robot.createScreenCapture(bounds);
        try {
            ImageIO.write(image,"png", new File("Screenshot.png"));
        } catch (IOException e) {
...

@@ -74,6 +78,7 @@ public class TaskbarPositionTest implements ActionListener {
private static JFrame frame;
private static JPopupMenu popupMenu;
private static JPanel panel;
private static Robot robot;
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it would be better to have Robot initialisation in this way? IMO it will make the robot final, so there is no way to overwrite it in the future as well as it would be easier to debug and not be initialised in the main method of the class.

    private static final Robot robot;

    static {
        try {
            robot = new Robot();
        } catch (AWTException e) {
            throw new RuntimeException(e);
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since its a test, I didn't expect any override of this class in future, my intention is add this feature with minimal change.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Renjith.

If you call saveScreenCapture once in the main method as I suggest, you can pass robot to saveScreenCapture, in which case robot can remain local variable.

try {
ImageIO.write(image,"png", new File("Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it's the best idea to hide the error and just print it into stdout. Wouldn't it be better to just throw the error, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think its a good idea

  1. IOException was not the original intention of this test and its only for additional information
  2. If we throw the error we will miss the actual exception, potentially that was the next instruction.

Copy link
Member

@aivanov-jdk aivanov-jdk Apr 3, 2025

Choose a reason for hiding this comment

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

No, we don't care about IOException. It can occur only after the test already failed, and it's important to preserve the original exception.

@@ -74,6 +78,7 @@ public class TaskbarPositionTest implements ActionListener {
private static JFrame frame;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I don't think * @run main TaskbarPositionTest is needed. But it's fine as it is too, don't have any strong feelings

Copy link
Member

Choose a reason for hiding this comment

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

It may not work without explicit @run because the test contains @build tags.

@run is implied if there are no other commands, such as @compile or @build, but it's not the case in this test.

@@ -74,6 +78,7 @@ public class TaskbarPositionTest implements ActionListener {
private static JFrame frame;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: copyright year

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 2, 2025
try {
ImageIO.write(image,"png", new File("Screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

@aivanov-jdk aivanov-jdk Apr 3, 2025

Choose a reason for hiding this comment

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

No, we don't care about IOException. It can occur only after the test already failed, and it's important to preserve the original exception.

@@ -74,6 +78,7 @@ public class TaskbarPositionTest implements ActionListener {
private static JFrame frame;
private static JPopupMenu popupMenu;
private static JPanel panel;
private static Robot robot;
Copy link
Member

Choose a reason for hiding this comment

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

I agree with Renjith.

If you call saveScreenCapture once in the main method as I suggest, you can pass robot to saveScreenCapture, in which case robot can remain local variable.

@@ -74,6 +78,7 @@ public class TaskbarPositionTest implements ActionListener {
private static JFrame frame;
Copy link
Member

Choose a reason for hiding this comment

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

It may not work without explicit @run because the test contains @build tags.

@run is implied if there are no other commands, such as @compile or @build, but it's not the case in this test.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 3, 2025
Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

Looks good to me except for the redundant comment before saveScreenCapture.

I'd also move the saveScreenCapture method to the very bottom of the test because it's the least important piece of code.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 3, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 4, 2025
Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

I'd rather move it below the main method. But it's fine…

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

None yet

4 participants