RFR: 8296554: MouseLocationOnScreenTest sometime fails when system is busy [v2]
Kevin Rushforth
kcr at openjdk.org
Tue Apr 15 15:39:57 UTC 2025
On Tue, 15 Apr 2025 07:18:44 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:
>> tests/system/src/test/java/test/robot/javafx/scene/MouseLocationOnScreenTest.java line 123:
>>
>>> 121: try {
>>> 122: Util.sleep(DELAY_TIME);
>>> 123: Assertions.assertEquals(x, (int) robot.getMouseX());
>>
>> this works also, though I'd simply use `if`.
>>
>> A bigger question is why are we using `int` coordinates? Wouldn't it make the test depend on the scale (and also on the screen resolution and window position)?
>>
>> Should we instead use the double coordinates and `Assertions.equals(double, double, double)` ?
>
> I would recommend to use a for loop as below.
>
> private static int VALIDATE_COUNT = 3;
> static void validate(Robot robot, int x, int y) {
> for (int i = 0; i < VALIDATE_COUNT; i++) {
> Util.sleep(DELAY_TIME);
> if (x == (int)robot.getMouseX() &&
> y == (int)robot.getMouseY()) {
> break;
> }
> }
> Assertions.assertEquals(x, (int) robot.getMouseX());
> Assertions.assertEquals(y, (int) robot.getMouseY());
> }
Good idea. As a (minor) suggestion, I might loop "5" times before calling it a failure.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1772#discussion_r2044928480
More information about the openjfx-dev
mailing list