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

2 comments
Comment actions Permalink

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.

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
---
Original message URL:
http://devnet.jetbrains.net/message/5303625#5303625


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.