usage of SWTWidgetReference

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

usage of SWTWidgetReference

Postby jcoulomb » Mon Feb 21, 2011 8:17 am

Hi,

I'm currently rewriting some of our test methods from WT 3.8 to WT 6.0.

It seems that click method on SWT locators uses a new SWTWidgetReference class, which implements IWidgetLocator, instead of the old one which extends in addition SWTWidgetLocator.

The hierarchy tree :

Code: Select all
-> IWidgetLocator
     -> SWTWidgetLocator
          -> com.windowtester.runtime.swt.locator.SWTWidgetReference (the old one, inner class of SWTWidgetLocator)
     -> IWidgetReference
          ->ISWTWidgetReference
               -> com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference (the new one)


For my needs, I use the findAll method (returning IWidgetLocator[]) to get every locators of a given class and i filter this list.
The IWidgetLocator of interest is then adapted using the following method to get a usable SWTWidgetLocator : SWTWidgetLocator.adapt().
The SWTWidgetLocator is needed if the locator is used as a parent in another locator.

In WT 6.0 this method seems obsolete since it returns a SWTWidgetReference (old version) which is no longer clickable (return a ClassCastException, WT try to cast it with the new class)

Code: Select all
public static SWTWidgetLocator adapt(IWidgetLocator parent)
    {
        if(parent instanceof IWidgetReference)
            return new SWTWidgetReference((IWidgetReference)parent); //the old one : an inner class of SWTWidgetLocator
        if(parent instanceof SWTWidgetLocator)
            return (SWTWidgetLocator)parent;
        else
            return null;
    }


I have the solution to use directly the IWidgetLocator without adapting it.
It's usable in click method, but not as a parent in a SWTWidgetLocator. The new reference can't be casted in a SWTWidgetLocator, since it no longer extends it.

Do you have an idea on how can i use a SWTWidgetReference as a parent in a SWTWidgetLocator ?

Josselin
jcoulomb
 
Posts: 3
Joined: Mon Feb 21, 2011 6:58 am

Re: usage of SWTWidgetReference

Postby jcoulomb » Mon Feb 28, 2011 2:30 am

A little up for my issue. I need a solution or a workaround for this please.
jcoulomb
 
Posts: 3
Joined: Mon Feb 21, 2011 6:58 am

Re: usage of SWTWidgetReference

Postby keertip » Tue Mar 29, 2011 7:45 am

Could you post the test code that used to work previously and now does not?
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