Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » WizardDialog waitCursor null when #stopped called(Import project wizard can't be SWTBot-tested?)
WizardDialog waitCursor null when #stopped called [message #1121285] Mon, 30 September 2013 13:08 Go to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
We've made minor changes to WizardProjectImportPage (Import existing projects into workspace) and I'm getting an error but only when running as an SWTBot Test, i.e. it works manually. I'm not sure if it's the changes I've made or a bug in SWTBot.

WizardProjectImportPage#createProjects creates a new WorkspaceModifyOperation (implements IRunnableWithProgress) and passes it to WizardDialog to run and use it's progress monitor via:

  getContainer().run(true, true, op);


...then in WiardDialog.run():
  ...
  ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
  lockedUI=false;
}
finally
{
  ...
  stopped(state);


...then when WizardDialog#stopped is called I'm getting a NullPointerException when it does:
waitCursor.dispose();


I've tried debugging with no success. It seems that SWTBot has messed with the cursor somehow.
Any ideas?

Craig

[Updated on: Mon, 30 September 2013 19:33]

Report message to a moderator

Re: WizardDialog waitCursor null when #stopped called [message #1121451 is a reply to message #1121285] Mon, 30 September 2013 16:32 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 771
Registered: July 2009
Location: Grenoble, France
Senior Member
On 09/30/2013 03:08 PM, Craig Foote wrote:
> We've made minor changes to WizardProjectImportPage (Import existing
> projects into workspace) and I'm getting an error but only when running
> as an SWTBot Test, i.e. it works manually. I'm not sure if it's the
> changes I've made or a bug in SWTBot.

How do you run SWTBot tests? From IDE, Headless with command-line, with
Tycho...?
Did you make sure the test is not running inside UI Thread?

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: WizardDialog waitCursor null when #stopped called [message #1121517 is a reply to message #1121451] Mon, 30 September 2013 18:01 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
Thanks for responding Mickael. I'm running through the IDE (Run as... SWTBot Test) and through tycho.

I created a similar test for the original "Import existing projects into workspace" wizard and it passes fine so it must be my code Sad
Again, I didn't change much, I just changed copy destination, and it runs without SWTBot. So it's back to the drawing board - I'll try to refactor so that it passes under SWTBot.

If I find what went wrong and it might be of use to someone I'll post back here.

Craig
icon8.gif  Re: WizardDialog waitCursor null when #stopped called [message #1121558 is a reply to message #1121517] Mon, 30 September 2013 19:05 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
I spoke too soon.

Testing the original "Import existing projects into workspace" wizard fails as well.

In SWTBot:
1) Right-click in Project Explorer and select "Import existing projects in Workspace" wizard
2) Enter location where I have a folder with a .project file (e.g. Desktop).
3) Click Refresh button. The project should appear in the list and be selected.
3) Select "Copy projects into workspace" radio button.
4) Press Finish.

The dialog stays open and an error is reported in console:

NullPointerException at org.eclipse.jface.wizard.WizardDialog.stopped(line 1316)

I'm using Indigo and SWTBot-2.10.

Craig
Re: WizardDialog waitCursor null when #stopped called [message #1122314 is a reply to message #1121558] Tue, 01 October 2013 12:39 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
Sorry, just saw your question about not running in UI thread. I know tycho is set up to useUIHarness=true and runInUIThread=false. As for the the SWTBot run config, I see no mention of what thread it's using but I think the default for SWTBot is non-ui thread right? Also, I have another test that works that does not set the "Import existing project into Workspace" wizard "Copy into workspace" radio (it links). It's able to close the dialog which I think would be a problem if I were in UI thread.

Also, I think I probably misspoke when I said I'm running Indigo. I'm targeting indigo (my target platform has 3.7.2 eclipse jars) but I'm developing in kepler.

Craig

[Updated on: Tue, 01 October 2013 13:23]

Report message to a moderator

Re: WizardDialog waitCursor null when #stopped called [message #1122375 is a reply to message #1122314] Tue, 01 October 2013 13:52 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 771
Registered: July 2009
Location: Grenoble, France
Senior Member
On 10/01/2013 02:39 PM, Craig Foote wrote:
> Sorry, just saw your question about not running in UI thread.
[...]
> I'm running through the IDE (Run as... SWTBot Test) and through tycho.

So it means you're not running in UIThread (Run as SWTBot test is always
out of UI Thread). That's a first good point.

> Also, I think I probably misspoke when I said I'm running Indigo. I'm
> targeting indigo (my target platform has 3.7.2 eclipse jars) but I'm
> developing in kepler.

The most important is the version you target (Indigo then).

> I'm using Indigo and SWTBot-2.10.

What is SWTBot 2.10 ? Is it 2.1.0 ?


About your specific problem, I can't help you much. Do you wait for
feedback from UI (using SWTBot.waitFor or waitUntil) ? It's possible
that if you don't do that, SWTBot goes too fast for the normal wizard
behavior and can get in corner-cases that aren't supported by UI.
SWTBot methods are asynchronous and don't wait for the handlers to have
performed, so you sometimes need to slow it down by waiting for feedback
after an action.

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: WizardDialog waitCursor null when #stopped called [message #1122563 is a reply to message #1122375] Tue, 01 October 2013 18:04 Go to previous message
Craig Foote is currently offline Craig FooteFriend
Messages: 195
Registered: July 2009
Senior Member
Yes, sorry, I'm using SWTBot-2.1.0, not 2.10. I see 2.1.1 is out; I looked at its release notes but didn't see anything related to this.

I do use waitWhile and waitUntil a lot. I've been using SWTBot for awhile now and really like the API. Throwing in a Condition now and again is pretty simple and usually makes sense. In this case I get the Finish button and invoke its click() then I have a condition that waits until the dialog closes before progressing (I get all the shells and cycle through their titles to be sure). The problem is that it never gets to its close{}. Upon performFinish() several RunnableWithProgress classes are run, updating the dialog's ProgressMonitor, writing to disk, and cycling through waitCursors. Then, when all are done, the waitCursor is again disposed and nulled but this dispose() causes the NPE. I don't see how but I think maybe not running in the UI thread is interfering with the waitCursor such that it gets nulled (or not even created) before the last RunnableWithProgress completes. I tried wrapping the finishButton.click() in a UIThreadRunnable but got the same result. Of course running the whole test in UI thread won't work because dialogs can't then be closed.

Interestingly, running the same test without checking the "Copy project into workspace" radio button works fine. It does only half the work and uses fewer RunnableWithProgress classes as when copying though so that may account for it somehow.

Testing the stock wizard is pretty straightforward. I can't imagine tests can be written that vary very much that might reveal a path that completes. So I'm convinced its not testable as is. Not sure who's at fault, eclipse or SWTBot, but probably neither. Maybe in eclipse 4.x it's different. Anyway, I've marked that test @Ignore and will have to move on. Thanks very much for your help, at least I don't think it's anything I'm doing wrong now.

Craig
Previous Topic:250 EUR to win for the best SWTBot logo!
Next Topic:Target Platform configuration problem
Goto Forum:
  


Current Time: Sat Dec 20 18:51:14 GMT 2014

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

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