Search in sources :

Example 11 with SWTBotTreeItem

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

the class PrepareChangelogSWTBotTest method canPrepareChangeLog.

/**
 * Basic prepare changelog test.
 *
 * @throws Exception
 */
@Test
@Ignore
public void canPrepareChangeLog() throws Exception {
    // Find manifest file
    IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
    assertNotNull(manifest);
    // delete it
    manifest.delete(true, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    // select ChangeLog file
    String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
    SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
    SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
    changeLogItem.select();
    // Should be unique
    bot.menu("Prepare ChangeLog").click();
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    // Wait for ChangeLog editor to open
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotEditor swtBoteditor = bot.activeEditor();
    // save to avoid "save changes"-pop-up
    swtBoteditor.save();
    assertEquals("ChangeLog", swtBoteditor.getTitle());
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    // make sure expected entry has been added.
    assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IEditorReference(org.eclipse.ui.IEditorReference) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IResource(org.eclipse.core.resources.IResource) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with SWTBotTreeItem

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

the class SWTBotTreeItemAssertions method hasChildItems.

/**
 * Checks the number of items and also verifies that each item has an images and a text
 * @param expectedCount
 * @return
 */
public SWTBotTreeItemAssertions hasChildItems(final int expectedCount) {
    notNullValue();
    if (actual.getItems().length != expectedCount) {
        failWithMessage("Expected tree item %s to be have %s items but it had %s.", actual.getText(), expectedCount, actual.getItems().length);
    }
    for (SWTBotTreeItem swtBotTreeItem : actual.getItems()) {
        final String treeItemText = SWTUtils.syncExec(() -> swtBotTreeItem.getText());
        final Image treeItemWidgetImage = SWTUtils.syncExec(() -> swtBotTreeItem.widget.getImage());
        Assertions.assertThat(treeItemText).isNotNull();
        Assertions.assertThat(treeItemWidgetImage).isNotNull();
    }
    return this;
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Image(org.eclipse.swt.graphics.Image)

Example 13 with SWTBotTreeItem

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

the class SWTUtils method expand.

public static SWTBotTreeItem expand(final SWTBotTree tree, final String... paths) {
    final SWTBotTreeItem rootItem = getTreeItem(tree, paths[0]);
    expandTreeItem(rootItem);
    if (paths.length > 1) {
        final String[] remainingPath = new String[paths.length - 1];
        System.arraycopy(paths, 1, remainingPath, 0, remainingPath.length);
        return expand(rootItem, remainingPath);
    }
    return rootItem;
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 14 with SWTBotTreeItem

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

the class SWTUtils method expand.

public static SWTBotTreeItem expand(final SWTBotTreeItem treeItem, final String... paths) {
    final SWTBotTreeItem childItem = getTreeItem(treeItem, paths[0]);
    expandTreeItem(childItem);
    if (paths.length > 1) {
        final String[] remainingPath = new String[paths.length - 1];
        System.arraycopy(paths, 1, remainingPath, 0, remainingPath.length);
        return expand(childItem, remainingPath);
    }
    return getTreeItem(treeItem, paths[0]);
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 15 with SWTBotTreeItem

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

the class SWTUtils method getTreeItem.

private static SWTBotTreeItem getTreeItem(final SWTBotTreeItem[] treeItems, final String[] paths) {
    final SWTBotTreeItem swtBotTreeItem = Stream.of(treeItems).filter(item -> item.getText().startsWith(paths[0])).findFirst().orElseThrow(() -> new RuntimeException("Only available items: " + Stream.of(treeItems).map(item -> item.getText()).collect(Collectors.joining(", "))));
    if (paths.length > 1) {
        syncExec(() -> swtBotTreeItem.expand());
        final String[] remainingPath = new String[paths.length - 1];
        System.arraycopy(paths, 1, remainingPath, 0, remainingPath.length);
        return getTreeItem(swtBotTreeItem.getItems(), remainingPath);
    }
    return swtBotTreeItem;
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Aggregations

SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)63 Test (org.junit.Test)38 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 DockerClient (com.spotify.docker.client.DockerClient)19 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)9 Path (org.eclipse.core.runtime.Path)7 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)7 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 IEditorReference (org.eclipse.ui.IEditorReference)5 Ignore (org.junit.Ignore)5 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2