jjnair / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Fix "enterText" in RobotFixture to raise "key released" events #245

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Marc Johen found a bug in "enterText" and provides a solution! :)

Details at:
http://groups.google.com/group/easytesting/browse_frm/thread/ea13f176c541ddb2?hl
=en

Original issue reported on code.google.com by Alex.Rui...@gmail.com on 2 Dec 2008 at 2:23

GoogleCodeExporter commented 8 years ago
Forgot to finish the summary :P

Original comment by Alex.Rui...@gmail.com on 2 Dec 2008 at 2:23

GoogleCodeExporter commented 8 years ago
I see, you already wrote a method for that :-)

It does seem to work like this:

  /** {@inheritDoc} */
  public void enterText(String text) {
    if (isEmpty(text)) return;
    for (char character : text.toCharArray()) {
        int keycode = KeyStrokeMap.keyStrokeFor(character).getKeyCode();
        int modifiers = KeyStrokeMap.keyStrokeFor(character).getModifiers
();
        keyPressAndRelease(keycode,modifiers);
        waitForIdle();
    }
  }

Running the test becomes a bit! slower though, which is not much of a
suprise
and may also be partly because of my databinding implementation.

Also I noticed that the KeyStrokeMap remains empty if not in an en-
locale, it
may be better default-behaviour if at least filling with the values
for en.

Greetings
Marc 

Original comment by goo...@johnen.biz on 4 Dec 2008 at 11:31

GoogleCodeExporter commented 8 years ago
Thanks Marc! I filed issue 250 to take care of KeyStrokeMap for non-en locales.

Original comment by Alex.Rui...@gmail.com on 5 Dec 2008 at 7:29

GoogleCodeExporter commented 8 years ago
Hi Marc,

Actually your implementation is the same as the current one. I suspect that the
source of the problem was issue 250. Once I fixed that one, the test for issue 
245
passed without changing the implementation of "enterText".

Here is the test case for issue 245:
http://code.google.com/p/fest/source/browse/trunk/fest/fest-swing/src/test/java/
org/fest/swing/core/Bug245_EnterTextNotRaisingKeyReleaseEventTest.java

Thanks,
-Alex

Original comment by Alex.Rui...@gmail.com on 5 Dec 2008 at 7:54