From: Lillian Angel <langel@redhat.com>
To: "Steve McKay☄" <smckay@google.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 19:27:00 -0000 [thread overview]
Message-ID: <46F9613B.20704@redhat.com> (raw)
In-Reply-To: <4f2ee4520709251213q7e317229y95c93236dd74a01f@mail.gmail.com>
Steve McKayâ wrote:
>> While it might be incorrect, I am unsure how else we can determine that
>> the correct key was pressed without dispatching an event.
>>
>
> As I know understand it, when the Robot's keyPress is called, it
> should make a keypress happen on your desktop. So if the myFrame
> window has focus, a keyPress event would be generated, otherwise, if
> your editor is focused, it'll get the key press.
>
That's right. If these two lines...
KeyEvent e = new KeyEvent(f, KeyEvent.KEY_PRESSED, 0, 0, code, chr,
KeyEvent.KEY_LOCATION_STANDARD);
f.dispatchEvent(e);
...are removed, myFrame.keyDown is not called and therefore, this.key is
not set. As it seems, the Robot function keyPress is not dispatching the
event to the Component.
Lillian
> Does anyone know if Selenium uses Robot to do its poking and prodding?
>
> --steve
>
>
>> Lillian
>>
>>
>>> 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, ...?
>>>>
>>>> --steve
>>>>
>>>> On 9/24/07, David Herron <David.Herron@sun.com> 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
>>>>>> settings?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>
>
>
>
next prev parent reply other threads:[~2007-09-25 19:27 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 [this message]
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☄
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=46F9613B.20704@redhat.com \
--to=langel@redhat.com \
--cc=David.Herron@sun.com \
--cc=mauve-discuss@sources.redhat.com \
--cc=smckay@google.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).