Simulate mouse click on Zest Graph control. [message #29990] |
Tue, 24 March 2009 20:50  |
Eclipse User |
|
|
|
Hello.
In my app under test I have a Zest GraphViewer that contains a Graph
control.
What would be the best way to simulate a simple mouse click on that control.
As SWTBot doesn't know about a Graph control, do I have to get the
correct Shell somehow, find the Graph control myself, find out the
correct coordinates and then post mouse events (to the display perhaps)?
I that the recommended way? If yes, are there any code snippets for that
task?
Perhaps it would be nice to have some helper methods for such a case in
the SWTBot API (but perhaps I just overlooked them). What do you think?
Best regards,
Kai
|
|
|
Re: Simulate mouse click on Zest Graph control. [message #30071 is a reply to message #29990] |
Tue, 24 March 2009 23:42  |
Eclipse User |
|
|
|
My solution for the below problem (if someone is interested):
List<?extends Widget> widgets =
bot.getFinder().findControls(WidgetMatcherFactory.widgetOfTy pe(Graph.class));
Control control = (Control) widgets.get(0));
control.getDisplay().syncExec(new Runnable(){
@Override
public void run() {
Event event = new Event();
event.type = SWT.MouseMove;
event.x = control.toDisplay(10, 10).x;
event.y = control.toDisplay(10, 10).y;
control.getDisplay().post(event);
event = new Event();
event.type = SWT.MouseDown;
event.button = 1;
control.getDisplay().post(event);
event = new Event();
event.type = SWT.MouseUp;
event.button = 1;
control.getDisplay().post(event);
}
});
Kai Schlamp schrieb:
> Hello.
>
> In my app under test I have a Zest GraphViewer that contains a Graph
> control.
> What would be the best way to simulate a simple mouse click on that
> control.
> As SWTBot doesn't know about a Graph control, do I have to get the
> correct Shell somehow, find the Graph control myself, find out the
> correct coordinates and then post mouse events (to the display perhaps)?
> I that the recommended way? If yes, are there any code snippets for that
> task?
> Perhaps it would be nice to have some helper methods for such a case in
> the SWTBot API (but perhaps I just overlooked them). What do you think?
>
> Best regards,
> Kai
|
|
|
Powered by
FUDForum. Page generated in 0.03249 seconds