How can I override the buildMatcher for SWTWidgets

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

How can I override the buildMatcher for SWTWidgets

Postby jyotisaxena » Mon Nov 15, 2010 5:47 am

Hi,
I have two combos in the properties view. To extract the desired one, I need to override the buildMatcher Method. But I guess the ISWTWidgetMatcher class has restricted access, Even if i try to suppress that warning, I get the error while running the code:

com.windowtester.runtime.swt.internal.widgets.SWTUIException: Exception occurred on the SWT UI Thread
at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.run(SWTUIExecutor.java:103)
at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:126)
at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:105)
at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder.doFindAll(SWTWidgetFinder.java:106)
at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder.findAll(SWTWidgetFinder.java:100)

PS: The view doesn't have the label associated with the combo box, hence I couldn't use the default matcher.
I tried the steps suggested on the URL:
http://code.google.com/javadevtools/win ... tomLocator
But got the error on the return type of the buildMatcher function as it expects ISWTWidgetMatcher as opposed to IWidgetMatcher.

Thanks for your support.
jyotisaxena
 
Posts: 12
Joined: Mon Nov 08, 2010 11:04 am

Re: How can I override the buildMatcher for SWTWidgets

Postby keertip » Tue Nov 16, 2010 10:18 am

Have you tried using an index to specify the combo?
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: How can I override the buildMatcher for SWTWidgets

Postby keertip » Wed Nov 17, 2010 8:45 am

The steps defined in
http://code.google.com/javadevtools/win ... tomLocator

does return a IWidgetMatcher. You can use the MatcherAdapter to change your builderMatcher to a ISWTWidgetMatcher.

Code: Select all
import com.windowtester.runtime.locator.IWidgetMatcher;
import com.windowtester.runtime.swt.internal.widgets.ISWTWidgetMatcher;
import com.windowtester.runtime.swt.internal.widgets.ISWTWidgetReference;

@SuppressWarnings("rawtypes")
public class MatcherAdapter implements ISWTWidgetMatcher {

  private final IWidgetMatcher matcher;

  public MatcherAdapter(IWidgetMatcher matcher) {
    this.matcher = matcher;
  }

  @SuppressWarnings("unchecked")
  public final boolean matches(ISWTWidgetReference<?> ref) {
    return matcher.matches(ref.getWidget());
  }
}

keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: How can I override the buildMatcher for SWTWidgets

Postby jyotisaxena » Wed Nov 17, 2010 12:06 pm

Thank you very much, it helped.
jyotisaxena
 
Posts: 12
Joined: Mon Nov 08, 2010 11:04 am

Re: How can I override the buildMatcher for SWTWidgets

Postby keertip » Thu Nov 18, 2010 9:22 am

Great! Glad that it worked for you.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron