public void testEndingWithCancel() {
    assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage());

    // TheTestWizard's performFinish() sets DID_FINISH to true, ensure it was not called
    wizard.performCancel();
    assertEquals("Wizard finished but should not have", false, DID_FINISH);

    dialog.cancelPressed();
    assertEquals("Wizard performed finished but should not have", false, DID_FINISH);
  }
  public void testWizardDispose() {
    wizard.setThrowExceptionOnDispose(true);

    final boolean logged[] = new boolean[1];
    Policy.setLog(
        new ILogger() {
          @Override
          public void log(IStatus status) {
            logged[0] = true;
          }
        });
    Shell shell = dialog.getShell();
    dialog.close();

    assertTrue(logged[0]);

    shell.dispose();
  }
  public void testEndingWithFinish() {
    // test page count
    assertEquals("Wizard has wrong number of pages", NUM_PAGES, wizard.getPageCount());

    // test page name
    assertEquals(
        "WizardPage.getName() returned wrong name", wizard.page1Name, wizard.page1.getName());

    // test getPage()
    assertSame(
        "Wizard.getPage() returned wrong page", wizard.getPage(wizard.page1Name), wizard.page1);

    // test title
    wizard.setWindowTitle(WIZARD_TITLE);
    assertEquals("Wizard has wrong title", wizard.getWindowTitle(), WIZARD_TITLE);
    wizard.page1.setTitle(PAGE_TITLE);
    assertEquals("Wizard has wrong title", wizard.page1.getTitle(), PAGE_TITLE);

    // set+test color twice to ensure initial color didn't happen to be color1
    wizard.setTitleBarColor(color1);
    assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color1);
    wizard.setTitleBarColor(color2);
    assertEquals("Wizard has wrong title color", wizard.getTitleBarColor(), color2);

    // test on starting page
    assertSame("Wizard has wrong starting page", wizard.page1, wizard.getStartingPage());
    assertSame("Wizard not on starting page", wizard.page1, dialog.getCurrentPage());

    // test getMessage()
    assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage());
    wizard.page1.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
    assertEquals(
        "WizardPage error message set correctly",
        TheTestWizardPage.BAD_TEXT_FIELD_STATUS,
        wizard.page1.getErrorMessage());

    // test page completion
    wizard.page1.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
    assertEquals("Page should be completed", true, wizard.page1.canFlipToNextPage());
    // Setting good value should've cleared the error message
    assertSame("WizardPage error message should be null", null, wizard.page1.getErrorMessage());

    // test getNextPage() without page changes
    assertSame("WizardPage.getNexPage() wrong page", wizard.page2, wizard.page1.getNextPage());
    assertSame("Wizard.getNexPage() wrong page", wizard.page2, wizard.getNextPage(wizard.page1));
    assertSame(
        "WizardPage.getPreviousPage() wrong page", wizard.page1, wizard.page2.getPreviousPage());
    assertSame(
        "Wizard.getPreviousPage() wrong page", wizard.page1, wizard.getPreviousPage(wizard.page2));
    assertSame("WizardPage.getNexPage() wrong page", wizard.page3, wizard.page2.getNextPage());
    assertSame(
        "Wizard.getPreviousPage() wrong page", wizard.page2, wizard.getPreviousPage(wizard.page3));

    // test canFinish()
    wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
    assertEquals("Wizard should not be able to finish", false, wizard.canFinish());
    wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
    assertEquals("Wizard should be able to finish", true, wizard.canFinish());

    // test simulated Finish button hit
    // TheTestWizard's performFinish() sets DID_FINISH to true
    dialog.finishPressed();
    assertEquals("Wizard didn't perform finish", true, DID_FINISH);
  }