Skip to content

Commit

Permalink
Fixes #30: Close the dialog if test fails
Browse files Browse the repository at this point in the history
The individual checks in this class do "button.getShell().dispose();"
to close the dialog when an assertion fails. That closes the UI
resources, but it does not dispose the non-UI resources/references.

In this particular case when
UIComparePreferencesAuto.testCompareViewersPref failed, it left
org.eclipse.jface.preference.PreferenceNode.page
set to the now disposed General preference page. So when a later
test tries to open the dialog, the test fails due to disposed widget
error.

By calling dialog.close() it makes sure that
org.eclipse.jface.preference.PreferenceNode.disposeResources()
is called, which releases the reference in PreferenceNode.page
  • Loading branch information
jonahgraham authored and iloveeclipse committed Apr 26, 2022
1 parent d93628b commit 95c9174
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ public static void assertDialogTexts(Dialog dialog) {
dialog.open();
Shell shell = dialog.getShell();
UITestCase.processEvents();
verifyCompositeText(shell);
dialog.close();
// close "verify results" dialog, it makes other tests unhappy
_verifyDialog.buttonPressed(IDialogConstants.YES_ID);
try {
verifyCompositeText(shell);
} finally {
dialog.close();
// close "verify results" dialog, it makes other tests unhappy
_verifyDialog.buttonPressed(IDialogConstants.YES_ID);
}
}

/**
Expand Down

0 comments on commit 95c9174

Please sign in to comment.