Waiting for workspace in SWTBotTest [message #533257] |
Wed, 12 May 2010 14:30  |
Eclipse User |
|
|
|
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 15:27  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03248 seconds