Skip to content

Conversation

DamonGuy
Copy link
Contributor

@DamonGuy DamonGuy commented Aug 27, 2025

Some useful methods (click, glide, waitForIdle, type) in ExtendedRobot should be migrated into Robot itself so that ExtendedRobot can be removed in the future. The tests using these ExtendedRobot methods will be handled separately.


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
  • Change requires CSR request JDK-8349593 to be approved

Issues

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

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26969

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 27, 2025

👋 Welcome back dnguyen! 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 Aug 27, 2025

❗ 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 Aug 27, 2025

@DamonGuy 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 client [email protected] rfr Pull request is ready for review labels Aug 27, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 27, 2025

Webrevs

@justin-curtis-lu
Copy link
Member

Since you are handling the tests in a separate PR, should the JBS issue be labeled with noreg-doc?

public void click(int buttons) {
mousePress(buttons);
waitForIdle(20);
mouseRelease(buttons);
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to call ***release methods in the finally block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this necessary? Would I have to account for accidentally releasing any buttons that should still be pressed by calling mouseRelease(buttons) in a finally block if some exception is thrown during mousePress?

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Aug 29, 2025
@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Aug 29, 2025
@DamonGuy DamonGuy requested review from liach and mrserb September 3, 2025 23:19

/**
* A convenience method that simulates clicking a mouse button by calling {@code mousePress}, {@code mouseRelease},
* and {@code waitForIdle}. Invokes {@code waitForIdle} with a default delay of 20 milliseconds after
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
* and {@code waitForIdle}. Invokes {@code waitForIdle} with a default delay of 20 milliseconds after
* and {@code waitForIdle}. Invokes {@code waitForIdle} with a default delay of {@value #DEFAULT_STEP_DELAY} milliseconds after

This renders 20 as a link that links to the constant that users can use.

* steps from its current location to the destination coordinates.
*
* @implSpec Invokes {@link #mouseMove(int, int) mouseMove} with a default
* {@link #DEFAULT_STEP_LENGTH step-length} and {@link #DEFAULT_STEP_DELAY step-delay}.
Copy link
Member

Choose a reason for hiding this comment

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

You can use:

     * @implSpec Invokes {@link #mouseMove(int, int) mouseMove} with a step-length
     * of {@value #DEFAULT_STEP_LENGTH} and a step-delay of {@value #DEFAULT_STEP_DELAY}.

Renders like:

Invokes mouseMove with a step-length of 2 and a a step-delay of 20.

Same for other sites.

*/
public synchronized void type(int keycode) {
keyPress(keycode);
waitForIdle(20);
Copy link
Member

Choose a reason for hiding this comment

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

Should this use DEFAULT_STEP_DELAY too?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the code this is based on (ExtendedRobot.java) it was called DEFAULT_SPEED and used by click and type as well as glide
As 'named' now, DEFAULT_STEP_DELAY is only appropriate for glide(..). There's no "stepping" here.

And yet click(..) uses it (internally)

so long as we don't document the name DEFAULT_STEP_DELAY on click() or type() it isn't critical.
I see a number of choices

  • Use literal 20 here and in click
  • Use DEFAULT_STEP_DELAY here and in click - do not document
  • Add a new (private) DEFAULT_DELAY - and use it in both cases
  • Add a new public DEFAULT_DELAY - and use it in both cases and document it
  • Rename DEFAULT_STEP_DELAY to DEFAULT_DELAY - and use it in click and type as well as glide

I'm inclined to go with the last of these - CSR will need to be revised.
But if we don't do that one now, it will be awkward to do later.
Thoughts ?

PS I can see the potential need for an overload of click() and type() which accepts an alternate delay but I don't propose it here, I just note that for click() it would not be possible for the default click() to just accept a delay since that would clash with click(int buttons).

Copy link
Member

Choose a reason for hiding this comment

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

I recommend revising the CSR. Since the CSR already has reviewers, once it is updated, it can be directly finalized for re-approval. Just describe the changes in a comment, and it should proceed smoothly.

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

Successfully merging this pull request may close these issues.

5 participants