How to test wizards extending AbstractWizard?
Hello,
One of my tests which are testing functionality of wizard (which extends AbstractWizard) are failing in 10.0.3 with NPE during AbstractWizard.getRootPane().registerKeyboardAction(). [whcih was passing in 9.0.4]
Here is flow that is causing NPE:
AbstractWizard.initWizard()
-> getRootPane()
->-> DialogWrapper.getRootPane()
->->-> DialogWrapperPeerImpl.getRootPane()
->->->-> HeadlessDialog.getRootPane() {wich returns null}
During construction of AbstractWizard(): DialogWrapperPeerImpl.createDialog() is called. This checks for headless mode of app (app.isUnitTestMode() || app.isHeadlessEnvironment() is the condition), if headless mode is true then returning HeadlessDailog. AbstractWizard.getRootPane() in-turn invokes HeadlessDialog.getRootPane() [which is hard-coded to return null], this is causing NPE.
Here is the code for createDialog():
private void createDialog(Window owner, boolean canBeParent) {
if (isHeadless()) {
myDialog = new HeadlessDialog();
return;
}
if (owner instanceof Frame) {
myDialog = new MyDialog((Frame)owner, myWrapper, myProject, myWindowFocusedCallback, myTypeAheadDone);
}
else {
myDialog = new MyDialog((Dialog)owner, myWrapper, myProject, myWindowFocusedCallback, myTypeAheadDone);
}
myDialog.setModal(true);
myCanBeParent = canBeParent;
}
Question:
Is there a way to test Wizards extending AbstractWizard using PlatformTestCase?
My plugin is creating a wizard which extends AbstractWizard. Tests for this plugin are creating a dummy window and are passing that dummy window to AbstractWizard constructor. I am creating a dummy window as given below:
dummyWindow = new Frame();
dummyWindow.setExtendedState(Frame.ICONIFIED);
dummyWindow.setFocusableWindowState(false); // try to stop the test from stealing focus
dummyWindow.setVisible(true);
Here is my earlier post related to this: http://devnet.jetbrains.com/thread/304151?tstart=0
Thanks,
Chandra
Please sign in to leave a comment.
Hello chandra,
I've pushed a fix that adds a null check around getRootPane(). We can backport
it to 10.5.1, but we don't plan to release any 10.0.x updates, so it won't
appear there.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Dmitry,
Thanks for the reply.
I think this is the patch: http://git.jetbrains.org/?p=idea/community.git;a=blobdiff;f=platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java;h=a495c52b84796f1fe3ef9dc77b461adb8e8f7e81;hp=e9c6eab32b8185e6058501505eb29560f5524ba2;hb=a3d9a48d7632716a6e1221df7b38a4e21b93742f;hpb=3c8fe33ba3228ebb7ed5568b21697ee643e84cac
I'll patch our intellij locally with these changes.
Thanks,
Chandra