Question about Form section with windowtester

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

Question about Form section with windowtester

Postby scshah » Thu Jan 17, 2008 11:47 am

I have been trying to recognize section(org.eclipse.ui.forms.widgets.Section). Below is my code

Object objFound = null;
SWTWidgetLocator widget=new SWTWidgetLocator(org.eclipse.ui.forms.widgets.Section.class);
IWidgetLocator[] Items= ui.findAll(widget);

for (IWidgetLocator loc : Items) {
objFound = ((IWidgetReference)loc).getWidget();
System.out.println("mywidget: " + objFound;}

Now my problem is that I got Section (mywidget: Section {}) as result, but it doesn't print name of section, How do I get it and iterate controls inside it? Can please somebody help me out?

Thanks
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Fri Jan 18, 2008 10:43 am

Could you get this from the section's getText() or getDescription() method? Note, you need to be sure to call this on the UI thread...

How about something like this?

Code: Select all
static String getText(final Section section) {
   final String[] text = new String[1];
   Display.getDefault().syncExec(new Runnable() {
      public void run() {
         text[0] = section.getText(); //or try getDescription();
      }
   });
   return text[0];
}


Have you tried the SectionLocator for this? It should be able to find sections with specified text... For instance:

Code: Select all
IWidgetLocator[] Items= ui.findAll(new SectionLocator(myText));


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

Re: Question about Form section with windowtester

Postby scshah » Sat Jan 19, 2008 10:55 pm

Hi Phil,

Thanks a lot for your help.Now I can get section name.

Now I am facing other problem. I tried to get all controls under section.My section has text and lable. I can get section, text and label with following code.

SWTWidgetLocator widget=new SWTWidgetLocator(Label.class); (Same for text)

but I want to verify that those controls and text are under particular section. So I tried below code:

SWTWidgetLocator widget=new SWTWidgetLocator(Label.class,new SWTWidgetLocator(Composite.class,new SWTWidgetLocator(org.eclipse.ui.forms.widgets.Section.class,"Java Details")));

But i found no widget. so what's wrong in it? Or what code should I use?

So as conclusion, I am able to get controls individually, but I want to verify that those are under their particular section I think hierarchy is like section->composite->text/label. so can you please guide me?

Thanks a lot again.
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Sun Jan 20, 2008 8:28 am

Interesting... The locator looks good at first glance. Have you tried recording against the section labels? What happens if you click them in a recording session do they get found?

(I'm guessing not.)

And what about this variation?:

Code: Select all
new SWTWidgetLocator(Label.class,new SWTWidgetLocator(Composite.class, new SectionLocator("Java Details"));
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Question about Form section with windowtester

Postby scshah » Sun Jan 20, 2008 12:35 pm

Yes Phil, You are right. I am not able to record it.

For this variation
new SWTWidgetLocator(Label.class,new SWTWidgetLocator(Composite.class, new SectionLocator("mysection"));

I can not able to get SectionLocator.. It's under com.windowtester.runtime.swt.locator? I am able to get other locators under this, but not sectionlocator. Am I doing something wrong?

Thanks
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Tue Jan 22, 2008 8:15 am

Have you tried a recent beta? SectionLocator was added since the last official release...

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

Re: Question about Form section with windowtester

Postby scshah » Tue Jan 22, 2008 10:11 am

Thanks Phil, I will try for that, but inbetween can you please give more details about Display.getDefault().syncExec(new Runnable() {}), I read it in windowtester but still not much clear about it.
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Tue Jan 22, 2008 11:19 am

You need to be careful to only access widget state on the UI thread and that call ensures it. For a bit more, see this FAQ entry:

http://downloads.instantiations.com/Win ... test_state
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Question about Form section with windowtester

Postby scshah » Fri Jan 25, 2008 12:13 pm

Hi Phil,

I tried ->new SWTWidgetLocator(Label.class,new SWTWidgetLocator(Composite.class, new SectionLocator("mysection")); but it's not working.
I also tried below :
SWTWidgetLocator widget=new SWTWidgetLocator(org.eclipse.ui.forms.widgets.Section.class);
IWidgetLocator[] treeItem= ui.findAll(widget);

//
for (IWidgetLocator loc : treeItem) {
objFound = ((IWidgetReference)loc).getWidget();
System.out.println("children" + objFound);
getText(objFound);
}

public static void getText(final Object obj) {

final String[] text = new String[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
Control[] c1= ((org.eclipse.ui.forms.widgets.Section)obj).getChildren();
for (Control c: c1)
{//so i get below
Twistie {}
Label {"section name"}
LayoutComposite {}

if (c.getClass()==org.eclipse.ui.forms.widgets.Twistie.class)
{
Control[] c2= ((org.eclipse.ui.forms.widgets.Twistie)c).getChildren();
for (Control c3:c2)
{
System.out.println("Section twist part " + c3);
}
}
}
}
});
}
If i tried Twistie, I get nothing. so what should I do now? what part contain controls from Twistie and layoutcomposite?
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby scshah » Fri Jan 25, 2008 1:09 pm

Hi Phil,

Below is heirarchy where text and label are in section:

[Section {}<HC|11831314>]->(invisible)
[Twistie {}<HC|5341750>]->(invisible)
[Label {"section name"}<HC|20700084>]->(invisible)
[LayoutComposite {}<HC|13975680>]->(invisible)
[GPropertyGroup {}<HC|8231970>]->(invisible)
[Label {Label name}<HC|9800920>]->(invisible)
[Text {}<HC|5358717>]->(invisible)

but somehow i cant access Layoutcompoiste? can you please guid me?
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Fri Jan 25, 2008 1:26 pm

Aha... It appears that those widgets are invisible. Only *visible* widgets are accessible. Do they "look" visible? Perhaps that part of the form needs to be revealed?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Question about Form section with windowtester

Postby scshah » Fri Jan 25, 2008 2:22 pm

Hi Phil, yes they are visible.. even section is also visible. I can see it while i run it.. and this section is expandable
scshah
 
Posts: 19
Joined: Fri Jan 11, 2008 3:52 pm

Re: Question about Form section with windowtester

Postby Phil Quitslund » Fri Jan 25, 2008 3:33 pm

Hmmmm... We'll need to dig a bit deeper.

Could you submit a bug report?:

wintest-support@instantiations.com

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