Testing Swing components in an RCP app

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Testing Swing components in an RCP app

Postby Jacek » Mon Nov 24, 2008 11:21 am

Hi, we are looking at evaluating WindowTester Pro for our testing automation needs.

Is WindowTester Pro able to test Swing components embedded in an Eclipse RCP application (using the SWT/Swing bridge).

We have a large RCP that that was a port of an existing Swing app, so although all new composites are in SWT, there is a vast amount of Swing panels that need testing as well. We are looking for a common tool that can handle them both.

Thanks, Jacek
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Phil Quitslund » Tue Nov 25, 2008 2:31 pm

Hi there,

Our runtime supports Swing and SWT. However, our recorder does not recognize the bridge case and so will only see your interactions with the SWT components of your RCP. This means that a bit of hand-coding of the Swing interactions will be required. That being said, better bridge support is on our list of desired features so your input is valuable to us. If you'd like to work with us to improve our support, please send a mail to: wintest-support@instantiations.com.

Thanks!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Testing Swing components in an RCP app

Postby Jacek » Wed Nov 26, 2008 10:35 am

Email sent!
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Jacek » Mon Dec 01, 2008 7:24 am

OK, so I managed to get everything working, I see the regular ui.click() methods, etc.

However, I need to get a handle to the actual SWT control (so I can get a handle to its embedded Swing control). How do I do that?

All the code samples I see seem to use locator objects to send events to them...but how do I get a handle to the actual control on the screen to assert its properties?

P.S. BTW, your code samples link from the documentation is 404:
http://downloads.instantiations.com/Win ... l#snippets

Click on the API reference and you get 404:
http://downloads.instantiations.com/Win ... mmary.html
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Jacek » Mon Dec 01, 2008 12:19 pm

I am guessing that basically I need to be able to instantiate a Swing Locator object from within the SWT Test Case. Is this possible in any way?
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Jacek » Wed Dec 03, 2008 11:53 am

* bump *
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby keertip » Fri Dec 05, 2008 12:39 pm

What you need to access the Swing components is a Swing UI context. You can get this from the SWT context by doing the following:

Code: Select all

IUIContext uiSwing = (IUIContext) ui.getAdapter(UIContextSwing.class);



Then you can use the Swing locators, for eg

Code: Select all
uiSwing.click(new LabeledTextLocator("City: "));
uiSwing.enterText("Vermont");
      
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: Testing Swing components in an RCP app

Postby Jacek » Tue Dec 09, 2008 5:41 am

Ah, that's great. I will try this right away.
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Jacek » Tue Dec 09, 2008 2:30 pm

I have issue with the ViewLocator for the parent View (the one that contains the embedded Swing panels) throwing me a multiple Widget found exception for the particular ViewId (I get one view and two composites with the same ID...probably some internal implementation of the SWT_AWT bridge).

Code: Select all
com.windowtester.runtime.MultipleWidgetsFoundException: Multiple Widgets Found:
looking for
  ViewLocator [com.myapp.rcp.view.ConnectionManager]
and found:
  WidgetReference(ConnectionManagementView$1 {})
  WidgetReference(Composite {})
  WidgetReference(Composite {})


I tried to get around it to force it to find only my view, I was guessing I have to create a custom ViewLocator with a different build matcher, e.g.:
Code: Select all
ViewLocator cmView = new ViewLocator(ConnectionManagementView.ID) {
         @Override
         protected IWidgetMatcher buildMatcher() {
            return new ByNameClassMatcher(ConnectionManagementView.class.getName());
         }
};
ui.find(cmView);


but now I get a No Widget found exception....am I on the right track here?
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Jacek » Tue Dec 09, 2008 3:13 pm

Solved it, it was the "$1" of course attached to the class name...I have other issues related to getting the Swing context from that view, but that probably just requires digging more into the structure created by our SWT/Swing bridge...
Jacek
 
Posts: 13
Joined: Mon Nov 24, 2008 11:18 am

Re: Testing Swing components in an RCP app

Postby Phil Quitslund » Thu Dec 11, 2008 7:42 pm

Thanks for following up.

Let us know how it goes. (And please post any tidbits that would be useful to others.)

Thanks!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest