|
|
|
|
Re: GEF GraphicalViewer within a dialog [message #559137 is a reply to message #559100] |
Wed, 15 September 2010 17:25 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
On 10-09-15 11:28 AM, Barry Dresdner wrote:
> Hi Mariot,
> I believe I now have the latest source - Revision 603. I found the
> SWTBotGefViewer class, so I believe I am on the right track. Now as I
> mentioned, my Gef Viewer is embedded within a dialog. I see method in
> SWTGefBot gefViewer, that takes the title of a workbench part as an
> argument. Is there another way to get the viewer? perhaps I am missing
> something here. Thanks again, Barry
You don't necessarily need to use the SWTGetBot#gefViewer method to use
a SWTBotGefViewer; these method are there to help when the viewer is
embedded in an editor or view. Even then, it's a best-effort attempt and
the editor or view must respect a certain contract for it to work
(namely, getAdapter(GraphicalViewer.class) must return the required
GraphicalViewer).
In your case, you need to find yourself the GraphicalViewer and
construct a new instance of SWTBotGefViewer. The hard part is getting
hold of the GraphicalViewer, because it is not a widget... and I mean,
really hard. The only solution I see requires you to modify the
application under test a little. You will need to attach the
GraphicalViewer as the data field of a widget. For example, let's say
you have a custom dialog, in its createContents() method you could do:
getShell().setData(graphicalViewer);
then, in your tests, you could do:
final SWTBotShell shell = bot.shell("");
GraphicalViewer graphicalViewer = syncExec(new Result<GraphicalViewer>()
{
public GraphicalViewer run()
{
return (GraphicalViewer) shell.widget.getData();
}
});
SWTBotGefViewer viewer = new SWTBotGefViewer(graphicalViewer);
If you can't modify your application or can't attach the viewer to a
widget, then I really have no clue how you could achieve it...
Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03694 seconds