Reputation: 6629
I have a testing FEST app which uses an AWT robot for simulating certain actions over a Swing interface. My problem is that it seems like moving the mouse pointer during the robot-test execution cancels some of the programatic actions, like pressing a column header. If you dont touch anything during execution, then cursor moves alone to the target and hits it.
Is there any way to block mouse user input for that app until test is finished?
Maybe not a block but a way to ignore events, force EDT finish or shielding robot would be appreciated of course
Upvotes: 1
Views: 1942
Reputation: 7989
If you are hardy to evolve with end-to-end tests using AWT robot, then try to separate tests to able to run only part that checks touched functionality while all bunch of end-to-end tests should run on build server.
Here is result of end-to-end testing by AWT robot for Swing application that completes on head-less build-server: http://travis-ci.org/#!/plokhotnyuk/calculator/jobs/1979904/L538
Upvotes: 0
Reputation: 36423
Maybe you could disable the keyboard and mouse using the native terminal commands. I.e cmd.exe for Windows and terminal for Linux (depending if application has to be portable just check os name and then run the correct command) however I'm not sure if this would render the Robot
useless. I think not though.
Windows:
cmd.exe /c %Homedrive%\windows\rundll32.exe mouse,disable
cmd.exe /c %Homedrive%\windows\rundll32.exe keyboard,disable
and for Linux see here
Addendum:
In my knowledge it is not possible in pure Java without using JNI to disable keyboard and mouse input from the user.
Here is a great link for the disbaling mouse and keyboard using JNI in Java: Java Global Keyboard / Mouse Hook - JNI
Upvotes: 1