Skip to content

Commit

Permalink
swtbot: Use SWTBotUtils for selecting the Trace folder
Browse files Browse the repository at this point in the history
This utility is used in many other tests and it is more robust. It
omits the suffix that indicates the number of traces in project.

This should fix intermittent failures happening in CI.

Signed-off-by: Bernd Hufmann <[email protected]>
  • Loading branch information
bhufmann committed Feb 9, 2024
1 parent fd85241 commit 423ea7c
Showing 1 changed file with 15 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
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.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
Expand Down Expand Up @@ -80,7 +79,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 = ".*";
Expand Down Expand Up @@ -295,10 +293,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");
Expand All @@ -323,9 +318,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();
Expand Down Expand Up @@ -368,9 +361,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();
Expand Down Expand Up @@ -419,9 +410,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();
Expand Down Expand Up @@ -471,9 +460,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();
Expand Down Expand Up @@ -518,9 +505,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();
Expand All @@ -545,9 +530,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();
Expand All @@ -572,9 +555,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();
Expand All @@ -599,9 +580,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();
Expand All @@ -625,9 +604,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();
Expand All @@ -652,9 +629,7 @@ 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();
Expand All @@ -673,9 +648,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();
Expand All @@ -700,9 +673,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();
Expand All @@ -723,9 +694,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();
Expand Down Expand Up @@ -839,10 +808,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();
Expand Down Expand Up @@ -994,12 +960,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]");
}

}

0 comments on commit 423ea7c

Please sign in to comment.