Skip to content

8150564: Migrate useful ExtendedRobot methods into awt.Robot #22044

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

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

Conversation

alisenchung
Copy link
Contributor

@alisenchung alisenchung commented Nov 12, 2024

Some useful methods in ExtendedRobot should be migrated into Robot itself so that ExtendedRobot can be removed in the future. The tests using ExtendedRobot for these migrated methods are changed to use only Robot (removing unnecessary building of ExtendedRobot).


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)
  • Change requires a CSR request matching fixVersion 26 to be approved (needs to be created)

Issue

  • JDK-8150564: Migrate useful ExtendedRobot methods into awt.Robot (Enhancement - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22044

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 12, 2024

👋 Welcome back achung! 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 Nov 12, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Nov 12, 2024

@alisenchung this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8150564
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch rfr Pull request is ready for review labels Nov 12, 2024
@openjdk
Copy link

openjdk bot commented Nov 12, 2024

@alisenchung 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.

@mlbridge
Copy link

mlbridge bot commented Nov 12, 2024

@prrace
Copy link
Contributor

prrace commented Nov 13, 2024

Please resolve the merge conflict.

@prrace
Copy link
Contributor

prrace commented Nov 13, 2024

/csr

@prrace
Copy link
Contributor

prrace commented Nov 13, 2024

/reviewers reviewers 2

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Nov 13, 2024
@openjdk
Copy link

openjdk bot commented Nov 13, 2024

@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@alisenchung please create a CSR request for issue JDK-8150564 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Nov 13, 2024

@prrace Usage: /reviewers <n> [<role>] where <n> is the number of required reviewers. If role is set, the reviewers need to have that project role. If omitted, role defaults to authors.

@prrace
Copy link
Contributor

prrace commented Nov 13, 2024

/reviewers 2 reviewers

@openjdk
Copy link

openjdk bot commented Nov 13, 2024

@prrace
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Nov 15, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

Expand wild imports here and in other tests wherever applicable.

Copy link
Contributor Author

@alisenchung alisenchung Nov 26, 2024

Choose a reason for hiding this comment

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

out of scope of this change, i won't be changing any tests here outside of stuff relating to ExtendedRobot

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Dec 3, 2024
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Dec 3, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 25, 2024

@alisenchung This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 22, 2025

@alisenchung This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Jan 22, 2025
@alisenchung
Copy link
Contributor Author

/open

@openjdk openjdk bot reopened this Jan 28, 2025
@openjdk
Copy link

openjdk bot commented Jan 28, 2025

@alisenchung This pull request is now open

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Feb 6, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Feb 6, 2025
@@ -126,6 +126,17 @@ public class Robot {

private DirectColorModel screenCapCM = null;

/**
* Default 20 milliseconds delay for mouse {@code click} and
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Default 20 milliseconds delay for mouse {@code click} and
* Default delay for mouse {@code click} and

There is no need to specify the exact value in the documentation, in case of something it will be much easier to change it later on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Be aware that values of static fields are automatically documented.
eg see
(https://docs.oracle.com/en/java/javase/21/docs/api/constant-values.html#java.awt.Font.BOLD)

And an app really could use knowing what the default is.
And these defaults have been battle-tested in ExtendedRobot

public static final int DEFAULT_DELAY = 20;

/**
* Default 2 pixel step length for mouse {@code glide}.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Default 2 pixel step length for mouse {@code glide}.
* Default pixel step length for mouse {@code glide}.

Same here

Comment on lines +789 to +792
* A convenience method that simulates clicking a mouse button by calling {@code mousePress}
* and {@code mouseRelease}. Invokes {@code waitForIdle} with a default {@link #DEFAULT_DELAY delay} after
* {@code mousePress} and {@code mouseRelease} calls. For specifics on valid inputs please see
* {@link java.awt.Robot#mousePress(int)}.
Copy link
Member

Choose a reason for hiding this comment

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

It's discussable, and I may be wrong, but I'm not a fan of documentation that is very specific about its implementation.
I prefer the one that was before in the ExtendedRobot.

Clicks mouse button(s) by calling {@link #mousePress(int)} and {@link #mouseRelease(int)} methods

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the concern but in this case it is more or less explanation of what the method does. Perhaps it can be adjusted or made in to an apiNote or whatever is best.

*/
@Override
public synchronized void waitForIdle() {
waitForIdle(syncDelay);
Copy link
Member

Choose a reason for hiding this comment

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

This waitForIdle(500) is no longer called by tests(as it uses regular java.awt.Robot#waitForIdle(), so I assume you have verified that automated testing looks good. (I haven't gone through all the tests yet)

/**
* Default 2 pixel step length for mouse {@code glide}.
*/
public static final int DEFAULT_STEP_LENGTH = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to make the DEFAULT_DELAY and DEFAULT_STEP_LENGTH configurable?

Copy link
Contributor

Choose a reason for hiding this comment

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

glide has over-rides step length

stepNum++) {
x += tDx;
y += tDy;
mouseMove((int)x, (int)y);
Copy link
Member

Choose a reason for hiding this comment

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

mouseMove can throw an IllegalThreadStateException under certain circumstances.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes should be added to all glide API methods

* @see #glide(int, int, int, int, int, int)
* @since 25
*/
public void glide(int x, int y) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the public void glide(Point dest) and public void glide(Point src, Point dest) added, it may be convenient in some cases.

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've taken a look at all the tests running glide and very few of them actually used glide(Point dest) and glide(Point src, Point dest) so I decided to remove them from them from the migration

@@ -48,7 +49,6 @@
@summary Test Component.paintAll() method
@author [email protected]: area=awt.component
@library /lib/client/
Copy link
Member

Choose a reason for hiding this comment

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

It's not needed anymore, is it?

Suggested change
@library /lib/client/

* @see #type(int)
* @see java.awt.event.KeyEvent
*/
public void type(char c) {
Copy link
Member

Choose a reason for hiding this comment

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

Those type(char... are not migrated also.

At least one test uses it:

https://github.com/alisenchung/jdk/blob/8150564/test/jdk/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucentWindowClick.java#L178

With your change, it now calls type(int) directly, which has a different implementation.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 25, 2025

@alisenchung This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 22, 2025

@alisenchung This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Apr 22, 2025
@alisenchung
Copy link
Contributor Author

/open

@openjdk openjdk bot reopened this May 7, 2025
@openjdk
Copy link

openjdk bot commented May 7, 2025

@alisenchung This pull request is now open

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 10, 2025

@alisenchung This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] csr Pull request needs approved CSR before integration rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

4 participants