1

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

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Whimusical
  • 6,401
  • 11
  • 62
  • 105

2 Answers2

1

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

Community
  • 1
  • 1
David Kroukamp
  • 36,155
  • 13
  • 81
  • 138
  • 1
    Im not sure that would be a good option given that I will have to execute it outside Java scope and I need the robot switching between input-ready and not mode. But certainly it is a very interesting info also outside scope of the question and it is also a beggining which I can rely if nothing else can be done from Java to inside Java programatically. Thanks!! – Whimusical Jul 30 '12 at 19:45
  • @user1352530 Its a pleasure, please see my edit it might prove fruitful :) – David Kroukamp Jul 30 '12 at 19:53
0

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

Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68