Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Simulate mouse click on Zest Graph control.
Simulate mouse click on Zest Graph control. [message #29990] Tue, 24 March 2009 20:50 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 Go to previous message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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
Previous Topic:SwtBot 2 and RCP apps
Next Topic:how to access toggle button
Goto Forum:
  


Current Time: Fri Nov 08 23:19:46 GMT 2024

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

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

Back to the top