arduino / arduino/Arduino

Some unittests fail: Automated clicks miss their target

Open
#10,168 2 comments 0 reactions 0 assignees View on GitHub
Component: IDE Type: Bug
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

I've been working on making the test suite a bit more usable (Will submit PRs for that next). With some fixes, most of the tests now work fine on my system, *except* for some of the tests that spawn the GUI and try to click things.

What seems to happen, is that the coordinates for something to be clicked get messed up. E.g. instead of opening a menu, it clicks somewhere in the bar above the menu (not straight above, a bit too far to the left too), failing to open the menu and showing e.g.:

```
[junit] Clicking on menu item never showed a pop-up menu
[junit] org.fest.swing.exception.ActionFailedException: Clicking on menu item never showed a pop-up menu
[junit] at org.fest.swing.exception.ActionFailedException.actionFailure(ActionFailedException.java:33)
[junit] at org.fest.swing.driver.JMenuItemDriver.ensurePopupIsShowing(JMenuItemDriver.java:137)
[junit] at org.fest.swing.driver.JMenuItemDriver.click(JMenuItemDriver.java:73)
[junit] at org.fest.swing.driver.JMenuItemDriver.activateParentIfIsAMenu(JMenuItemDriver.java:97)
[junit] at org.fest.swing.driver.JMenuItemDriver.show(JMenuItemDriver.java:79)
[junit] at org.fest.swing.driver.JMenuItemDriver.click(JMenuItemDriver.java:71)
[junit] at org.fest.swing.fixture.JMenuItemFixture.click(JMenuItemFixture.java:84)
[junit] at processing.app.ReduceIndentWith1CharOnLastLineTest.shouldJustCloseTheDialog(ReduceIndentWith1CharOnLastLineTest.java:51)
[junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[junit] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[junit]
[junit] Test processing.app.ReduceIndentWith1CharOnLastLineTest FAILED
```

While waiting for the menu to open, the mouse pointer is somewhat locked in place (I can move it, but it immediately jumps back). It does only click once, it seems.

Normally, my system maximizes windows automatically. When I disable that, the behaviour changes and it clicks some distance to the left of the window, a bit lower than the menu bar, which seems quite random.

This is *probably* an issue caused by java, which sometimes already behaves weird on my system. When I open up a menu with the window maximized, it opens up over the menu bar rather than below it, and with the window not maximized, the menu pops up to the left of the window and too high. I've also seen in the past that the mouse pointer position does not match the currently highlighted menu item (you would have to move the mouse a bit further down and to the right to select an option).

I thought that updating the swing testing library might help. Currently the "fest" / "fest-swing" library is used, which seems to live here: https://github.com/alexruiz/fest-swing-1.x We use 1.2, and there is an 1.2.1, but that did not help. Also, this project has not seen any updates in 7 years.

I also found assertj, which seems to be a fork that has seen some more fixes and development (though the last commit on assertj-swing is also 3 years old). See https://github.com/joel-costigliola/assertj-swing and https://assertj.github.io/doc/ I started upgrading to this library to see if that helps, but ran into some compilation problems. I might try to finish that, but for now I needed to get on with other things.

At assertj-swing, I did find some other reports of related issues with clicking, sometimes caused by java 11 (which I have I think), multiple monitors (which I am not currently using) or GUI scaling (which I'm not using, this might be Win10-specific too). See https://github.com/joel-costigliola/assertj-swing/issues/160, https://github.com/joel-costigliola/assertj-swing/issues/158 and https://github.com/joel-costigliola/assertj-swing/issues/229.

All this was with Ubuntu 19.10, gnome 3.34 and java 11.0.7, have not tried any other environments.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the GUI failure in processing.app.ReduceIndentWith1CharOnLastLineTest.shouldJustCloseTheDialog under the reported Ubuntu 19.10, GNOME 3.34, and Java 11 environment. Inspect the fest/fest-swing 1.2 setup and the related AssertJ Swing reports mentioned in the issue; done means automated menu clicks consistently hit their targets and the affected tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.