Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swtbot: Make FetchRemoteTracesTest more robust #11

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 = ".*";
Expand Down Expand Up @@ -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");
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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]");
}

}
Loading