Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Waiting for workspace in SWTBotTest
Waiting for workspace in SWTBotTest [message #533257] Wed, 12 May 2010 18:30 Go to next message
Markus Oley is currently offline Markus Oley
Messages: 253
Registered: July 2009
Location: Germany
Senior Member
Hi to all,

I want to implement a test, which shall wait for a rebuild and a refresh of a workspace.
I tried by looking at the Progress-View and checking if the "No operations to display at this time"-textfield is availabe,
but it's available even if workspace at work.

Do you have a simple solution for this issue?

Greetings
Markus
Re: Waiting for workspace in SWTBotTest [message #533267 is a reply to message #533257] Wed, 12 May 2010 19:27 Go to previous message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
You can add write an ICondition that hooks in a IResourceChangeListener
that waits on a IResourceChangeEvent#POST_BUILD.

Be sure to remove the listener or your listener in a finally block or
else eclipse will slow down, and you may be leaking memory.

You'd use the classes like this:

condition = new WaitForBuildCondition();
condition.addListener();
try{
bot.waitForCondition(condition, timeout);
} finally {
condition.removeListener();
}

class WaitForBuildCondition extends DefaultCondition {
bolean done = false;

WaitForBuildCondition(){
myResourceChangeListener = new MyResourceChangeListener(this);
this.workspace = ResourcesPlugin.getWorkspace();
}

boolean test() {
return done;
}

void done() {
this.done = true;
}

void removeListener(){
workspace.removeResourceChangeListener(myResourceChangeListe ner);
}

void addListener(){
workspace.addResourceChangeListener(myResourceChangeListener );
}
}

class MyResourceChangeListener implements IResourceChangeListener {
MyResourceChangeListener(condition){
this.condition = condition;
}
void resourceChanged(event){
if (event.getBuildKind() == IResourceChangeListener.POST_BUILD)
condition.done();
}
}



--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot


On 5/12/10 11:30 AM, Markus Oley wrote:
> Hi to all,
> I want to implement a test, which shall wait for a rebuild and a refresh
> of a workspace. I tried by looking at the Progress-View and checking if
> the "No operations to display at this time"-textfield is availabe, but
> it's available even if workspace at work.
> Do you have a simple solution for this issue?
>
> Greetings
> Markus
Previous Topic:Login Check in SWTBOT Against RCP
Next Topic:How to access UI item from running application
Goto Forum:
  


Current Time: Fri Oct 24 16:16:16 GMT 2014

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

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