Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » when to use syncExec?
when to use syncExec? [message #635542] Wed, 27 October 2010 09:50 Go to next message
Aparna Argade is currently offline Aparna ArgadeFriend
Messages: 41
Registered: October 2010
I'm learning SWTBot and creating my first test to create a new project in our eclipse based product.
After clicking the menus for creating a new project, a dialog appears in which I give name of the project and click Finish. My SWTBOT test code is as:
public void testcreateNewProject() throws Exception {"File").menu("New").menu("Xtensa C/C++ Project").click();
SWTBotText prjName = bot.textInGroup("Project Name");

The new project gets created but with exception as:
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr
and so on..

I see that the widgets on the dialog are grey (they should be white) but the name gets typed and Finish gets clicked. While the progress bar is there on the screen, the test finishes.

I tried with UIThreadRunnable.syncExec but I don't inderstand which arg I need to give as the parameter to syncExec. Should I just just VoidResult? First of all, is it necessory to use syncExec in this case?
Please guide me when to use UIThreadRunnable.syncExec and also its args.
Where can I get detailed threading model architecture of SWTBOT?
Re: when to use syncExec? [message #636655 is a reply to message #635542] Tue, 02 November 2010 11:04 Go to previous message
Tim S is currently offline Tim SFriend
Messages: 7
Registered: August 2010
Junior Member
You definitely don't have to use syncExec or asyncExec. This will run your code in the UI thread and that is exactly what should not happen.

The only case in which you need to use these methods is when you're accessing SWT widgets directly, but that is highly discouraged unless you're extending SWTBot with your own classes (for instance to be able to test widgets that SWTBot doesn't know about).

About the exception you get, it's hard to say what causes it without knowing more about your project. It originates from some thread that accesses a widget that is already disposed. Possibly one of the widgets in the wizard. You may want to slow down SWTBot to see what's going on (see http:// eed_of_SWTBot_tests.3F).
Previous Topic:Howto: SWTHelloWorld with SWTBot?
Next Topic:SWT standalone newbie question
Goto Forum:

Current Time: Thu Apr 19 19:59:45 GMT 2018

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

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