"AWT Robot" or "Posting AWT Events to an EventQueue"

15 views
Skip to first unread message

david amiel

unread,
May 13, 2008, 8:30:14 AM5/13/08
to easytesting
With some of my test "posting awt events to an EventQueue" doesn't
work:

my code:
robot = RobotFixture.robotWithNewAwtHierarchy();
robot.settings().eventMode(EventMode.AWT);
windows = new FrameFixture( robot,getMainFrame());

windows.menuItem(new GenericTypeMatcher<JMenu>() {
@Override
protected boolean isMatching(JMenu button) {
return "Test".equals(button.getText());
}
}).doubleClick();


When i used "robot = RobotFixture.robotWithCurrentAwtHierarchy()" it
works.


Do you have any idea?


Failure Trace :

org.fest.swing.exception.ComponentLookupException: Unable to find
component using matcher
client.MenuTest$1@22e177.

Component hierarchy:

jide.DefaultMainFrame[name='frame0', title='test', enabled=true,
visible=true, showing=true]

at
org.fest.swing.core.BasicComponentFinder.componentNotFound(BasicComponentFinder.java:
184)
at
org.fest.swing.core.BasicComponentFinder.find(BasicComponentFinder.java:
169)
at
org.fest.swing.core.BasicComponentFinder.find(BasicComponentFinder.java:
158)
at
org.fest.swing.core.BasicComponentFinder.find(BasicComponentFinder.java:
153)
at org.fest.swing.fixture.ContainerFixture.find(ContainerFixture.java:
826)
at
org.fest.swing.fixture.ContainerFixture.menuItem(ContainerFixture.java:
363)
at client.testDemoScreen(MenuTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
81)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)

Alex Ruiz

unread,
May 13, 2008, 10:33:53 AM5/13/08
to easyt...@googlegroups.com
Hi David,

I don't think the problem is in the "event posting". It seems that the problem is in 'robotWithNewAwtHierarchy'. I'm going to file a bug. Can you please post the code of the frame you are testing? That would help us a lot! :)

Thanks!
-Alex

david amiel

unread,
May 13, 2008, 11:09:41 AM5/13/08
to easytesting
It's quite complicated for me to post this test because its testing a
quite big application.

But i will try to repeat this bug in a test application and will send
you my code (ASAP).

Thanks,

On 13 mai, 16:33, "Alex Ruiz" <alex.ruiz...@gmail.com> wrote:
> Hi David,
>
> I don't think the problem is in the "event posting". It seems that the
> problem is in 'robotWithNewAwtHierarchy'. I'm going to file a bug. Can you
> please post the code of the frame you are testing? That would help us a lot!
> :)
>
> Thanks!
> -Alex
>

Alex Ruiz

unread,
May 13, 2008, 12:47:46 PM5/13/08
to easyt...@googlegroups.com
Many thanks David! I'll try to reproduce the bug on my computer too.

Regards,
-Alex

david amiel

unread,
May 23, 2008, 8:43:34 AM5/23/08
to easytesting
Sorry i cant reproduce this bug in a quick example.

But if you made some try you will see that there is some strange
comportment with "robotWithNewAwtHierarchy" ...

In fact, it's a blocking problem for me because i launch my test on a
VM windows and just posting awt events to an EventQueue works.

I cant understand why sometime it cant see that there is a hierarchy
of components ; it just see the main frame. (cf log first message)

Thanks,

On 13 mai, 18:47, "Alex Ruiz" <alex.ruiz...@gmail.com> wrote:
> Many thanks David! I'll try to reproduce the bug on my computer too.
>
> Regards,
> -Alex
>

Alex Ruiz

unread,
Jun 16, 2008, 3:49:27 PM6/16/08
to easyt...@googlegroups.com
Hi Daniel,

I started to work on this issue and I don't think it is a bug (at least so far.)

What I think it is going on is that you instantiate the frame before creating the robot using 'robotWithNewAWTHierarchy'. That robot will only see GUI components created after it. In your code I see a call to 'getMainFrame()', but I don't know if you are instantiating the frame there or if it is only a getter to an already instantiated frame.

Thanks,
-Alex
Reply all
Reply to author
Forward
0 new messages