public void testPageChangeListening() {
    pageChanged = false;
    pageChangingFired = false;

    IPageChangedListener changedListener =
        new IPageChangedListener() {
          @Override
          public void pageChanged(PageChangedEvent event) {
            pageChanged = true;
          }
        };

    IPageChangingListener changingListener =
        new IPageChangingListener() {
          @Override
          public void handlePageChanging(PageChangingEvent event) {
            assertEquals("Page should not have changed yet", false, pageChanged);
            pageChangingFired = true;
          }
        };

    // test that listener notifies us of page change
    dialog.addPageChangedListener(changedListener);
    dialog.addPageChangingListener(changingListener); // assert is in the listener
    assertEquals("Page change notified unintentially", false, pageChanged);
    // change to page 2
    dialog.nextPressed();
    assertEquals("Wasn't notified of page change", true, pageChanged);
    assertEquals("Wasn't notified of page changing", true, pageChangingFired);

    dialog.removePageChangingListener(
        changingListener); // if not removed, its assert will fail on next nextPressed()
    // change to page 2
    dialog.nextPressed();

    // test with listener removed
    pageChanged = false;
    dialog.removePageChangedListener(changedListener);
    // change to page 3
    dialog.nextPressed();
    assertEquals("Page change notified unintentially", false, pageChanged);
  }
  public void testShowPage() {
    // move to page 3
    dialog.nextPressed();
    dialog.nextPressed();
    assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage());

    // showPage() back to page 1
    dialog.showPage(wizard.page1);

    assertSame("Wizard.showPage() set wrong page", wizard.page1, dialog.getCurrentPage());

    // TODO Next test fails due to bug #249369
    //		assertEquals("Back button should be disabled on first page", false,
    // dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());
  }
  public void testPageChanging() {
    // initially on first page
    assertSame("Wizard started on wrong page", wizard.page1, dialog.getCurrentPage());
    assertEquals(
        "Back button should be disabled on first page", false, dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());

    // move to middle page 2
    dialog.nextPressed();
    assertSame("Wizard.nextPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
    assertEquals(
        "Back button should be enabled on middle page", true, dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be enabled on middle page", true, dialog.getNextButton().getEnabled());

    // test that can't complete by inserting bad value to be validated
    wizard.page2.textInputField.setText(TheTestWizardPage.BAD_TEXT_FIELD_CONTENTS);
    assertEquals(
        "Finish should be disabled when bad field value",
        false,
        dialog.getFinishedButton().getEnabled());
    assertEquals("Cancel should always be enabled", true, dialog.getCancelButton().getEnabled());

    // test that can complete by inserting good value to be validated
    wizard.page2.textInputField.setText(TheTestWizardPage.GOOD_TEXT_FIELD_CONTENTS);
    assertEquals(
        "Finish should be enabled when good field value",
        true,
        dialog.getFinishedButton().getEnabled());

    // move to last page 3
    dialog.nextPressed();
    assertSame("Wizard.nextPressed() set wrong page", wizard.page3, dialog.getCurrentPage());
    assertEquals(
        "Back button should be enabled on last page", true, dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be disenabled on last page",
        false,
        dialog.getNextButton().getEnabled());

    // move back to page 2
    dialog.backPressed();
    assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
    assertEquals(
        "Back button should be enabled on middle page", true, dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be enabled on middle page", true, dialog.getNextButton().getEnabled());

    // move back to page 1
    dialog.backPressed();
    assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage());
    assertEquals(
        "Back button should be disabled on first page", false, dialog.getBackButton().getEnabled());
    assertEquals(
        "Next button should be enabled on first page", true, dialog.getNextButton().getEnabled());

    // move Next to page 2
    dialog.buttonPressed(IDialogConstants.NEXT_ID);
    assertSame("Wizard.backPressed() set wrong page", wizard.page2, dialog.getCurrentPage());
    // move Back to page 1
    dialog.buttonPressed(IDialogConstants.BACK_ID);
    assertSame("Wizard.backPressed() set wrong page", wizard.page1, dialog.getCurrentPage());
  }