This is the mail archive of the mailing list for the Mauve project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tweaking default java.awt.Robot settings

David Herron wrote:
[resending because the mailing list thingy told me I had to use only plain text messages...]

Hmmm.. here's the meat of the test

public void runTest(int code, char chr)
KeyEvent e = new KeyEvent(f, KeyEvent.KEY_PRESSED, 0, 0, code, chr, KeyEvent.KEY_LOCATION_STANDARD);
r.mouseMove(60, 60);

   h.check(key, (int) chr);

I don't understand this. If you're going to create a Java event why use Robot, or vice versa...?

The test was done this way to determine if the right key was pressed. See the inner class (myFrame) which has 1 function (keyDown) which sets a variable (key) to the key that was pressed.

While it might be incorrect, I am unsure how else we can determine that the correct key was pressed without dispatching an event.


It appears h.check is in gnu.testlet.TestHarness and that it simply does an immediate check with no waiting. The dispatchEvent call is going to cause the listener to fire regardless of what's happening using Robot.

This looks like an incorrect test, and what I'd recommend is:-

a) ditch the two lines saying KeyEvent / dispatchEvent ... they are completely subverting the intent of the test

b) insert some code so the runTest method waits for the listener to be triggered. Such as a wait and notify type of semaphor.

c) I don't know how the test guarantees runTest executes on the event dispatch thread. Is the EDT as important to classpath as it is to Sun's Swing?

- David Herron

Steve McKayâ wrote:
So would you recommend I ignore the test, delete it, add a comment, ...?


On 9/24/07, David Herron <> wrote:
Steve McKayâ wrote:
Hi All,

I've noticed that at least some of the tests using java.awt.Robot are
non-deterministic due to lags is the underlying window system. The
java.awt.Component.keyPressTest, for example, fails some of the time
(on linux, windows, linux+wine, ...). It looks like enabling
autoWaitForIdle (waits for the awt EventQueue to be empty before
adding new events to the queue), and setting autoDelay (pauses for an
arbitrary period of time) to some magic number of millis well above
zero (I use 100) significantly reduces failures. Would anyone object
to configuring the Robot with settings like this by default? If no,
should the config mechanism be updated to allow tweaking these

I don't know what the classpath implementation of Robot looks like, but
I do know what Sun's Linux/Unix implementation looks like (having
written the original version).

Generally Robot has to request the OS or X11 to synthesize the event.
On Windows there's a direct API call, while on Unix/Linux there is a
child process which ends up calling XTEST extension methods.  In both
cases it means there is a nondeterministic delay due to the current
process scheduling characteristics of the given system.  In other words
it depends on an external entity, who Robot cannot coerce into
performing the request within a bounded set of time.

I think that means depending on Robot doing it's thing within a given
period of time is an invalid test.

Robot does not add events to EventQueue but it requests the OS to
synthesize an OS-level event.

- David Herron

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]