diff --git a/tmf/org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/remote/ui/swtbot/tests/fetch/FetchRemoteTracesTest.java b/tmf/org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/remote/ui/swtbot/tests/fetch/FetchRemoteTracesTest.java index 791bc18256..4eeeabc0a4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/remote/ui/swtbot/tests/fetch/FetchRemoteTracesTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.remote.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/remote/ui/swtbot/tests/fetch/FetchRemoteTracesTest.java @@ -32,8 +32,8 @@ import org.eclipse.core.runtime.QualifiedName; import org.eclipse.osgi.util.NLS; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; 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; @@ -44,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; @@ -80,7 +81,6 @@ public class FetchRemoteTracesTest { private static final String PASSWORD_SHELL_NAME = "Password Required"; private static final String PROFILE_NAME = "new profile"; private static final String PROFILES_LOCATION; - private static final String PROJECT_EXPLORER = "Project Explorer"; private static final String PROJECT_NAME = "Test"; private static final String SYSLOG_FILE_PATTERN = ".*syslog"; private static final String WILDCARD_PATTERN = ".*"; @@ -295,10 +295,7 @@ public void test_7_03() { */ @Test public void test_8_04() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); - + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); fBot.comboBox().setSelection("TestAllRecursive"); @@ -323,9 +320,7 @@ public void test_8_04() { */ @Test public void test_8_05() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -368,9 +363,7 @@ public void test_8_05() { */ @Test public void test_8_06() throws CoreException { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -419,9 +412,7 @@ public void test_8_06() throws CoreException { */ @Test public void test_8_07() throws CoreException { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -471,9 +462,7 @@ public void test_8_07() throws CoreException { */ @Test public void test_8_08() throws CoreException { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -518,9 +507,7 @@ public void test_8_08() throws CoreException { */ @Test public void test_8_09() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -545,9 +532,7 @@ public void test_8_09() { */ @Test public void test_8_10() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -572,9 +557,7 @@ public void test_8_10() { */ @Test public void test_8_11() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -599,9 +582,7 @@ public void test_8_11() { */ @Test public void test_8_12() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -625,9 +606,7 @@ public void test_8_12() { */ @Test public void test_8_13() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -652,16 +631,17 @@ public void test_8_13() { */ @Test public void test_8_14() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); 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(); @@ -673,9 +653,7 @@ public void test_8_14() { */ @Test public void test_8_15() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -700,9 +678,7 @@ public void test_8_15() { */ @Test public void test_9_01() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -723,9 +699,7 @@ public void test_9_01() { @Test @Ignore public void test_9_02() { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - projectExplorerBot.show(); - SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem tracesFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -839,10 +813,7 @@ public void testEditProfile() { } private static void testImport(Runnable selectionFunctor, Runnable verifyTracesFunctor) { - SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); - assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot); - projectExplorerBot.show(); - SWTBotTreeItem treeItem = getTracesFolderTreeItem(projectExplorerBot); + SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeItem.contextMenu(FETCH_COMMAND_NAME).click(); SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate(); @@ -994,12 +965,4 @@ private static void openRemoteProfilePreferences() { treeNode = treeNode.getNode("Remote Profiles"); treeNode.select(); } - - private static SWTBotTreeItem getTracesFolderTreeItem(SWTBotView projectExplorerBot) { - SWTBotTreeItem treeItem = projectExplorerBot.bot().tree().getTreeItem(PROJECT_NAME); - treeItem.select(); - treeItem.expand(); - return treeItem.getNode("Traces [0]"); - } - }