Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock
SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #910769] Mon, 10 September 2012 11:20 Go to next message
kanarupan kularatnarajah is currently offline kanarupan kularatnarajahFriend
Messages: 8
Registered: June 2012
Junior Member
I'm trying to automate the swtbot ui testing for an eclipse plugin, with maven.

The particular eclipse plugin has a custom control which is extended from org.eclipse.ui.forms.MasterDetailsBlock.

This custom control contains a org.eclipse.swt.widgets.Tree.

I'm using org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.5" and org.eclipse.swtbot.swt.finder;bundle-version="2.0.5".

SWTBot couldn't find any tree when I attempt to search as follows,

SWTBotTree tree = bot.tree(); for (SWTBotTreeItem treeItem : tree.getAllItems()) {}

I tried with (which is working for org.eclipse.ui.forms.widgets.FormText),
MasterDetailsBlock masterDetailsBlock=bot.widget(widgetOfType(MasterDetailsBlock.class));

But following syntax error was shown by the eclipse (3.7.2).

'Multiple markers at this line - Bound mismatch: The generic method widgetOfType(Class) of type WidgetMatcherFactory is not applicable for the arguments (Class). The inferred type MasterDetailsBlock is not a valid substitute for the bounded parameter - Bound mismatch: The generic method widget(Matcher) of type SWTBotFactory is not applicable for the arguments (Matcher). The inferred type MasterDetailsBlock is not a valid substitute for the bounded parameter '

Please suggest me any workaround or solution to this issue.

Does SWTBot support to test org.eclipse.ui.forms.MasterDetailsBlock components? In the negative case how to contribute that facility?

Thanks in advance.
Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #911215 is a reply to message #910769] Tue, 11 September 2012 07:33 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 09/10/2012 01:20 PM, kanarupan kularatnarajah wrote:
> I tried with (which is working for
org.eclipse.ui.forms.widgets.FormText),
> MasterDetailsBlock
> masterDetailsBlock=bot.widget(widgetOfType(MasterDetailsBlock.class));
> Does SWTBot support to test org.eclipse.ui.forms.MasterDetailsBlock
> components?

The method "widgetOfType" signature is:
<T extends org.eclipse.swt.widgets.Widget> org.hamcrest.Matcher<T>
inUIThread(org.hamcrest.Matcher<?> matcher)
As you can see, it expects the argument T to extend
"org.eclipse.swt.widgets.Widget". A MasterDetailsBlock is not a Widget,
it's more a kind of Factory or Controller. You can't access it with
SWTBot APIs.

> In the negative case how to contribute that facility?

It does not make sense to support this in SWTBot since a
MasterDetailsBlock is not a UI component, it's a logical one.
Instead, you can seek into the details part using regular SWTBot APIs,
just as if there were no MasterDetails in your editor.


--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #911754 is a reply to message #911215] Wed, 12 September 2012 09:01 Go to previous messageGo to next message
kanarupan kularatnarajah is currently offline kanarupan kularatnarajahFriend
Messages: 8
Registered: June 2012
Junior Member
Thanks for the reply Mickael..!!

Of course, I'm a beginner and am trying test/access a component via SWTBot. The responsible class, which extends MastersDetailsBlock uses org.eclipse.ui.forms.widgets.FormToolkit to create a section-> composite-> tree.

(only relevant lines of code are given below)

Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);

Composite client = toolkit.createComposite(section, SWT.WRAP);

tree = toolkit.createTree(client, SWT.NULL);

EclipseSpy View could locate the tree as follows.
Location:
//Shell/-1//Composite/4//Composite/0//Composite/6//Composite/0//Composite/0//CTabFolder/0//ScrolledForm/1//Form/0//LayoutComposite/1//MasterDetailsBlock$MDSashForm/0//Section/0//LayoutComposite/2//Tree/0

I could access to the section and composite but not the tree.
I have tried as follows.

SWTBotTree tree = bot.tree();
for (SWTBotTreeItem treeItem : tree.getAllItems()) {}



and alternatively



final Tree tree1 = bot.widget(widgetOfType(Tree.class));
asyncExec(new VoidResult() {
public void run() {
for (TreeItem treeItem : tree1.getItems()) {
if(treeItem.getText().contains("myDataService.dbs")) {
tree1.select(treeItem);

}
}
}


Neither of them couldn't find any trees.

I also tried the composite.getChildern()and tried to get the class name of each of them. Tree class wasn't there.

Is it a concern with the creation of the tree (as mentioned at the beginning)??
How to trace the tree component?
Why couldn't swtbot find the tree while the eclipse_spy could?
Is there any other available control tracking tools?

Thanks in adavance.


Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #912221 is a reply to message #910769] Thu, 13 September 2012 06:45 Go to previous messageGo to next message
kanarupan kularatnarajah is currently offline kanarupan kularatnarajahFriend
Messages: 8
Registered: June 2012
Junior Member
hi,
Sorry for previous post which off the head.
I could simply access the tree as follows and able to select the TreeItem. But couldn't work with
its context menu.

bot.cTabItem("xxxx").activate();
SWTBotEditor swtBotEditor = bot.activeEditor();
SWTBotTreeItem node = swtBotEditor.bot().tree()
.getTreeItem("yyyy)");
node.setFocus();

node.select().contextMenu("zzzzz").click(); //error


An error occurs and relevant section is as follows.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.contextMenu(AbstractSWTBot.java:460)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem.contextMenu(SWTBotTreeItem.java:553)
......


Anyway, I could do the same simulation inside Package Explorer and close projects.

I found the responsible code segment is "menuFinder.findMenus(matcher).get(0)".

Does it mean it couldn't find any menuItems?
Please help?
Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #912416 is a reply to message #911754] Thu, 13 September 2012 14:34 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

> Is it a concern with the creation of the tree (as mentioned at the
> beginning)??

I don't think so.


> Why couldn't swtbot find the tree while the eclipse_spy could?
> Is there any other available control tracking tools?

Is the view or part or the shell that contains the Tree active when
looking for bot? If not, you should retrieve it with SWTBot API, and use
setFocus() or activate() on it to ensure bot will look in the right
piece of UI.

--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #912418 is a reply to message #912221] Thu, 13 September 2012 14:39 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 09/13/2012 08:45 AM, kanarupan kularatnarajah wrote:
> hi,
> Sorry for previous post which off the head.
> I could simply access the tree as follows and able to select the
> TreeItem.

Glad it works better now

> But couldn't work with its context menu.
>
> Anyway, I could do the same simulation inside Package Explorer and close
> projects.

Are you using Eclipse 4? It appears that SWTBot has some issues with
menus in Eclipse 4. See:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388306
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384621

Maybe your issue is related to one of this issue. If you have time to
investigate and try contributed patches, you're very welcome.
Please add you use-case/thoughts/feedback/patches to the relevant
issues, and create new issues if necessary.

--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: SWTBot testing controls which extend org.eclipse.ui.forms.MasterDetailsBlock [message #912765 is a reply to message #912418] Fri, 14 September 2012 06:28 Go to previous message
kanarupan kularatnarajah is currently offline kanarupan kularatnarajahFriend
Messages: 8
Registered: June 2012
Junior Member
hi,
thanks for the reply.
I referred this forum [1] and used 'ContextMenuHelper'to solve my context-menu issue.

Can you please suggest me some good (deep) references regarding swtbot threads?

Thanks in advance.

[1] http://www.eclipse.org/forums/index.php/t/11863/

Previous Topic:getting NoClassDefFound on resetWorkbench()
Next Topic:Contrbute to SWTBot using Gerrit
Goto Forum:
  


Current Time: Sat Apr 20 03:32:43 GMT 2024

Powered by FUDForum. Page generated in 0.03242 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top