From: "Steve McKay☄" <smckay@google.com>
To: "Thomas Fitzsimmons" <fitzsim@redhat.com>
Cc: "David Herron" <David.Herron@sun.com>, mauve-discuss@sources.redhat.com
Subject: Re: Tweaking default java.awt.Robot settings
Date: Tue, 25 Sep 2007 18:57:00 -0000 [thread overview]
Message-ID: <4f2ee4520709251156yde57b65tbb97032939ac75e6@mail.gmail.com> (raw)
In-Reply-To: <46F95466.7070700@redhat.com>
Hi Thomas,
> If Robot can't be counted on to do something within some time
> delay, is it also useless in non-test applications?
David's suggestion to use multi-threaded paradigms for dealing with
the issue seems pretty good to me. For example, we can block until a
window is ready to process events with code like this (only half baked
at this time):
// before running any tests
// show the window
f.setSize(200, 200);
f.show();
waitForWindow(); // blocks until the frame has responded to a
keypress events
....
class myFrame extends Frame {
public boolean keyDown(Event e, int i) {
synchronized(lock) { // lock is some explicit lock object
key = new Integer(e.key);
lock.notify();
}
return super.keyDown(e, i);
}
}
/**
* Blocks until the frame has responded to a keypress event.
*/
private void waitForWindow() {
synchronized(lock) {
while (key == null) {
r.keyPress(32); // send a key press event
r.keyRelease(32); // don't press the key forever
try {
// wait for a notify from the frame, or timeout in case the
// window missed the keypress event entirely
lock.wait(100);
}
catch (InterruptedException ie) {
// interrupted, if key is still null, we'll try again
}
}
}
}
The obvious downside is you have to deal with all the pitfalls of
multi-threaded code everytime you write the code.
--steve
> I've always wondered how the TCK certified AWT and Swing functionality. Does it
> use EventQueue-posting?
>
> Tom
>
>
--
Steve McKay <smckay@google.com>
next prev parent reply other threads:[~2007-09-25 18:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-24 20:31 Steve McKay☄
2007-09-24 20:50 ` David Herron
2007-09-24 21:22 ` Steve McKay☄
2007-09-24 21:41 ` David Herron
2007-09-25 18:33 ` Lillian Angel
2007-09-25 19:13 ` Steve McKay☄
2007-09-25 19:27 ` Lillian Angel
2007-09-25 19:37 ` Steve McKay☄
2007-09-25 19:45 ` Lillian Angel
2007-09-25 19:27 ` David Herron
2007-09-25 18:33 ` Thomas Fitzsimmons
2007-09-25 18:57 ` Steve McKay☄ [this message]
2007-09-25 19:58 ` Thomas Fitzsimmons
2007-09-25 20:28 ` Steve McKay☄
2007-10-04 0:43 ` Steve McKay☄
2007-10-04 13:04 ` Lillian Angel
2007-09-25 19:24 ` David Herron
2007-09-25 18:10 ` Thomas Fitzsimmons
2007-09-25 18:14 ` Steve McKay☄
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f2ee4520709251156yde57b65tbb97032939ac75e6@mail.gmail.com \
--to=smckay@google.com \
--cc=David.Herron@sun.com \
--cc=fitzsim@redhat.com \
--cc=mauve-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).