Skip to content

Commit

Permalink
swtbot: Make cancel test more robust
Browse files Browse the repository at this point in the history
The import dialog might close too fast and then the cancel button is
not available anymore. This happens sometimes in CI. To make the
test more robust detect that case and continue the test execution.

Signed-off-by: Bernd Hufmann <[email protected]>
  • Loading branch information
bhufmann committed Feb 9, 2024
1 parent 5fbf01f commit 8a6f1b4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
Expand All @@ -43,6 +44,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.eclipse.tracecompass.ctf.core.tests.shared.LttngTraceGenerator;
import org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests.TmfRemoteUISWTBotTestPlugin;
import org.eclipse.tracecompass.tmf.ui.dialog.TmfFileDialogFactory;
Expand Down Expand Up @@ -635,8 +637,11 @@ public void test_8_14() {
SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
fBot.comboBox().setSelection("TestAllRecursive");
fBot.button("Next >").click();
fBot.button("Finish").click();
fBot.button("Cancel").click();
try {
fBot.button("Cancel").click();
} catch (WidgetNotFoundException | TimeoutException e) {
// shell closed too fast due to timing... ignore
}
fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
WaitUtils.waitForJobs();

Expand Down

0 comments on commit 8a6f1b4

Please sign in to comment.