Search in sources :

Example 1 with SWTBotTree

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTree in project linuxtools by eclipse.

the class TestUtils method openRepoFile.

public static SWTBotMultiPageEditor openRepoFile(SWTWorkbenchBot bot, SWTBotView navigator) {
    // open the package explorer view
    SWTBotTree botTree = navigator.bot().tree();
    botTree.select(ICreaterepoTestConstants.REPO_NAME).contextMenu(ICreaterepoTestConstants.OPEN).click();
    // get a handle on the multipage editor that was opened
    SWTBotMultiPageEditor editor = bot.multipageEditorByTitle(ICreaterepoTestConstants.REPO_NAME);
    editor.show();
    // 3 = repository form page, metadata form page, repo file
    assertEquals(3, editor.getPageCount());
    return editor;
}
Also used : SWTBotMultiPageEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)

Example 2 with SWTBotTree

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTree in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testTapsetContents.

@Test
public void testTapsetContents() {
    // Create a blank script and add a function to it while it's open.
    String scriptName = "probeScript.stp";
    createScript(bot, scriptName);
    SWTBotView funcView = bot.viewByTitle("Function");
    funcView.setFocus();
    SWTBotTree funcTree = funcView.bot().tree();
    SWTBotTreeItem item = funcTree.getTreeItem(funcNodeName);
    item.doubleClick();
    SWTBotEclipseEditor editor = bot.activeEditor().toTextEditor();
    assertTrue(editor.getText().contains(item.getText()));
    // Open a non-stap file and add a probe. This should bring up a dialog
    // asking if the function should be added to the only open .stp file.
    clickMainMenu("File", "New", "Other...");
    SWTBotShell shell = bot.shell("New");
    shell.setFocus();
    shell.bot().text().setText("Untitled Text File");
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Untitled Text File"));
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    SWTBotView probeView = bot.viewByTitle("Probe Alias");
    probeView.setFocus();
    SWTBotTree probeTree = probeView.bot().tree();
    SWTBotTreeItem probeCategory = probeTree.getTreeItem(probeCategoryFull);
    probeCategory.expand();
    bot.waitUntil(new TreeItemPopulated(probeCategory));
    String dialogTitle = "Select Script";
    item = probeCategory.getNode(probeGroup);
    item.expand();
    bot.waitUntil(new TreeItemPopulated(item));
    item = item.getNode(0);
    item.doubleClick();
    {
        Matcher<Shell> withText = withText(dialogTitle);
        bot.waitUntil(Conditions.waitForShell(withText));
    }
    shell = bot.shell(dialogTitle);
    shell.setFocus();
    bot.button("Yes").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    // The editor containing the script should now be in focus.
    bot.waitUntil(new EditorIsActive(scriptName));
    assertTrue(wasProbeInserted(editor, item, false));
    // Open the probe's definition file (an .stp script).
    probeView.show();
    item.contextMenu("View Definition").click();
    bot.waitUntil(new EditorIsActive(probeDef.getName()));
    // Adding a probe while an .stp editor is in focus should always add it
    // to that editor, even if multiple .stp editors are open.
    item = probeCategory.getNode(probeGroup);
    item.doubleClick();
    assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, true));
    assertFalse(wasProbeInserted(editor, item, true));
    // Switch to the non-stp editor, and add a probe. A dialog should appear
    // to let the user choose which of the open files to add to.
    editor = bot.editorByTitle("Untitled 1").toTextEditor();
    editor.show();
    item = probeCategory.getNode(probeSingleWithoutDef);
    item.doubleClick();
    shell = bot.shell(dialogTitle);
    shell.setFocus();
    SWTBotTable table = bot.table();
    assertTrue(table.containsItem(scriptName));
    assertTrue(table.containsItem(probeDef.getName()));
    table.select(scriptName);
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitUntil(new EditorIsActive(scriptName));
    assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, false));
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) Matcher(org.hamcrest.Matcher) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 3 with SWTBotTree

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTree in project linuxtools by eclipse.

the class ProjectExplorer method getTree.

/**
 * Assumes Project Explorer view is shown.
 *
 * @return The tree of the Project Explorer view
 */
public static SWTBotTree getTree() {
    SWTBotView projectExplorer = bot.viewByTitle("Project Explorer");
    projectExplorer.show();
    Composite projectExplorerComposite = (Composite) projectExplorer.getWidget();
    Tree swtTree = bot.widget(WidgetMatcherFactory.widgetOfType(Tree.class), projectExplorerComposite);
    return new SWTBotTree(swtTree);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Tree(org.eclipse.swt.widgets.Tree) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)

Example 4 with SWTBotTree

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTree in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method openConnectionEditionWizard.

private void openConnectionEditionWizard(final String elementName) {
    // $NON-NLS-1$
    final SWTBotTreeItem connectionItem = SWTUtils.getTreeItem(dockerExplorer.bot(), elementName);
    final SWTBotTree dockerExplorerViewTreeBot = dockerExplorer.bot().bot().tree();
    dockerExplorerViewTreeBot.select(connectionItem);
    // $NON-NLS-1$
    dockerExplorerViewTreeBot.contextMenu(WizardMessages.getString("ImageRunSelectionPage.editButton")).click();
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 5 with SWTBotTree

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTree in project linuxtools by eclipse.

the class ImageRunSWTBotTest method shouldReportErrorIfContainerWithSameNameExists.

@Test
public void shouldReportErrorIfContainerWithSameNameExists() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // expand the 'Images' node and select the 'foo' images
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo").select();
    // when opening the "Run Image..." wizard
    final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
    dockerExplorerViewTreeBot.contextMenu("Run...").click();
    // when use an existing container name
    bot.textWithLabel(WizardMessages.getString("ImageRunSelectionPage.containerName")).setText("foo_bar");
    // then
    // wait for https://bugs.eclipse.org/bugs/show_bug.cgi?id=482889 to be
    // able to check the wizard validation message
    // assertThat(bot.text(WizardMessages.getString("ImageRunSelectionPage.containerWithSameName"))).isNotNull();
    ButtonAssertions.assertThat(bot.button("Finish")).isNotEnabled();
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) Test(org.junit.Test)

Aggregations

SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)18 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)7 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)7 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)4 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)3 Test (org.junit.Test)3 DockerClient (com.spotify.docker.client.DockerClient)2 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)2 Shell (org.eclipse.swt.widgets.Shell)2 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 Consumer (java.util.function.Consumer)1 ConfirmProjectDeleteDialog (net.heartsome.cat.ts.test.ui.msgdialogs.ConfirmProjectDeleteDialog)1 ProgressDialog (net.heartsome.cat.ts.test.ui.msgdialogs.ProgressDialog)1 ProjectTreeView (net.heartsome.cat.ts.test.ui.views.ProjectTreeView)1 IResource (org.eclipse.core.resources.IResource)1 Composite (org.eclipse.swt.widgets.Composite)1 Tree (org.eclipse.swt.widgets.Tree)1 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)1 SWTBotMultiPageEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor)1 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)1