JDK-8224055 : [macos] Robot does not take care about key modifiers properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9,10,11,12,13,14
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • CPU: generic
  • Submitted: 2019-05-16
  • Updated: 2023-10-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
The robot does not properly set/use key modifiers after JDK-8155740.

The issue became critical when one test presses/unpresses the META/SHIFT/etc keys, but the robot generate only the press event, this cause all possible weird results for the later tests.

For example every tests runs on macOS open lots of utility windows of terminal becaouse one test press Command key, and one another test try to press different keys which apparently became shortcuts(CMD+XXX), example one of the shortcut is CMD+H to hide the current test window(terminal became the focus window), and second is CMD+I to open utility window of the terminal.
Comments
To reproduce this bug, it is necessary to run these 3 tests in a row: java/awt/event/KeyEvent/KeyChar/KeyCharTest.java java/awt/event/KeyEvent/SwallowKeyEvents/SwallowKeyEvents.java java/awt/keyboard/AllKeyCode/AllKeyCode.java
17-05-2019

While I am working on this bug I' would like to blacklist these tests: JDK-8224152
17-05-2019

I have filed the bug to the Apple that an example on the link below does not work properly: https://developer.apple.com/documentation/coregraphics/1456564-cgeventcreatekeyboardevent?language=objc The answer is: "You have to post and give time for the event source to update to match state. Try put some delays between each CGEventPost. ...and the creation of subsequent events needs to be after those postings - the events inherit their flags at creation time." So we either need to add delays so the shift/meta key will modify the state before we will send the next event, or we can maintain the state of the "next events" itself, it is possible to set the key modifiers manually via CGEventSetFlags();
16-05-2019