Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-06 10:56:00 +0000
committerJeff Johnston2016-01-18 22:37:20 +0000
commitc813585d7d5674bdd3a9f11910f3497168dc9876 (patch)
treef94c70272f588fd81b149b023dec0e90d251283b
parent919d59c4404f788576d37a5c9375435872780c7b (diff)
downloadorg.eclipse.linuxtools-c813585d7d5674bdd3a9f11910f3497168dc9876.tar.gz
org.eclipse.linuxtools-c813585d7d5674bdd3a9f11910f3497168dc9876.tar.xz
org.eclipse.linuxtools-c813585d7d5674bdd3a9f11910f3497168dc9876.zip
Bug 481502 - Allow for commands on multiple containers
Remove the restriction for "count=1" on the selection to display the command in the context menu Added SWTBot to verify that commands are visible and enabled/disabled, depending on the containers' state. Change-Id: Ic590bb36f6933d4ec30d9560dea9e6ffae3cf579 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/63621 Tested-by: Hudson CI Reviewed-on: https://git.eclipse.org/r/64607 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/DockerConnectionManagerUtils.java5
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java33
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java249
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/plugin.xml18
4 files changed, 260 insertions, 45 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/DockerConnectionManagerUtils.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/DockerConnectionManagerUtils.java
index 493a71fe78..954552515b 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/DockerConnectionManagerUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/DockerConnectionManagerUtils.java
@@ -32,10 +32,9 @@ public class DockerConnectionManagerUtils {
* {@link DockerExplorerView}.
*
* @param connections the connection to configure in the {@link DockerConnectionManager} via a mocked {@link IDockerConnectionStorageManager}
- * @throws InterruptedException
*/
public static void configureConnectionManager(
- final IDockerConnection... connections) throws InterruptedException {
+ final IDockerConnection... connections) {
DockerConnectionManager.getInstance()
.setConnectionStorageManager(MockDockerConnectionStorageManagerFactory.providing(connections));
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
@@ -47,7 +46,7 @@ public class DockerConnectionManagerUtils {
dockerExplorerView.getCommonViewer().refresh();
dockerExplorerView.showConnectionsOrExplanations();
});
- Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ SWTUtils.wait(1, TimeUnit.SECONDS);
}
}
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
index 354256002f..2132a5ec4e 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
@@ -1,9 +1,13 @@
package org.eclipse.linuxtools.internal.docker.ui.testutils.swt;
+import static org.assertj.core.api.Assertions.fail;
+
+import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.core.runtime.jobs.Job;
@@ -91,7 +95,7 @@ public class SWTUtils {
* @param runnable
* @throws InterruptedException
*/
- public static void asyncExec(final Runnable runnable) throws InterruptedException {
+ public static void asyncExec(final Runnable runnable) {
final Queue<ComparisonFailure> failure = new ArrayBlockingQueue<>(1);
final Queue<SWTException> swtException = new ArrayBlockingQueue<>(1);
Display.getDefault().asyncExec(new Runnable() {
@@ -121,10 +125,10 @@ public class SWTUtils {
*
* @throws InterruptedException
*/
- public static void waitForJobsToComplete() throws InterruptedException {
- Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ public static void waitForJobsToComplete() {
+ wait(1, TimeUnit.SECONDS);
while (!Job.getJobManager().isIdle()) {
- Thread.sleep(TimeUnit.SECONDS.toMillis(1));
+ wait(1, TimeUnit.SECONDS);
}
}
@@ -171,5 +175,26 @@ public class SWTUtils {
}
return swtBotTreeItem;
}
+
+ public static void wait(final int duration, final TimeUnit unit) {
+ try {
+ Thread.sleep(unit.toMillis(duration));
+ } catch (InterruptedException e) {
+ fail("Failed to wait for a " + unit.toMillis(duration) + "ms", e);
+ }
+ }
+
+ /**
+ * Selects all child items in the given <code>parentTreeItm</code> whose labels match the given <code>items</code>.
+ * @param parentTreeItem the parent tree item
+ * @param matchItems the items to select
+ */
+ public static void select(SWTBotTreeItem parentTreeItem, String... matchItems) {
+ final List<String> fullyQualifiedItems = Stream.of(parentTreeItem.getItems())
+ .filter(treeItem -> Stream.of(matchItems)
+ .anyMatch(matchItem -> treeItem.getText().startsWith(matchItem)))
+ .map(item -> item.getText()).collect(Collectors.toList());
+ parentTreeItem.select(fullyQualifiedItems.toArray(new String[0]));
+ }
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
index 91f2ba9065..ac6dc2e9ee 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
@@ -11,6 +11,10 @@
package org.eclipse.linuxtools.internal.docker.ui.views;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.concurrent.TimeUnit;
+
import org.assertj.core.api.Assertions;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.linuxtools.internal.docker.core.DockerConnection;
@@ -30,6 +34,7 @@ import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.PlatformUI;
@@ -63,7 +68,7 @@ public class DockerExplorerViewSWTBotTest {
public ClearConnectionManagerRule clearConnectionManager = new ClearConnectionManagerRule();
@Before
- public void setup() throws InterruptedException {
+ public void setup() {
this.bot = new SWTWorkbenchBot();
SWTUtils.asyncExec(() -> {try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
@@ -81,7 +86,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldDisplayExplanationPane() throws InterruptedException {
+ public void shouldDisplayExplanationPane() {
// given
DockerConnectionManagerUtils.configureConnectionManager();
// then
@@ -89,7 +94,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldDisplayConnectionsPane() throws InterruptedException {
+ public void shouldDisplayConnectionsPane() {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
@@ -99,7 +104,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldRefreshImagesAndShowChanges() throws InterruptedException {
+ public void shouldRefreshImagesAndShowChanges() {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
@@ -121,7 +126,7 @@ public class DockerExplorerViewSWTBotTest {
dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
dockerExplorerViewTreeBot.select(imagesTreeItem);
dockerExplorerViewTreeBot.contextMenu("Refresh").click();
- Thread.sleep(2000);
+ SWTUtils.wait(2, TimeUnit.SECONDS);
imagesTreeItem.expand();
Conditions.waitForJobs(DockerExplorerView.class, "Docker Explorer View jobs");
// then check that there are images now
@@ -130,7 +135,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldRefreshContainersAndShowChanges() throws InterruptedException {
+ public void shouldRefreshContainersAndShowChanges() {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
@@ -160,7 +165,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldShowContainerPortMapping() throws InterruptedException {
+ public void shouldShowContainerPortMapping() {
// given
final DockerClient client = MockDockerClientFactory
.container(MockDockerContainerFactory.name("foo_bar").build(), MockDockerContainerInfoFactory
@@ -172,11 +177,11 @@ public class DockerExplorerViewSWTBotTest {
// when a second call to expand the container is done (because the first
// expandAll stopped with a "Loading..." job that retrieved the
// containers)
- final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test (null)",
- "Containers", "foo_bar (null)");
+ final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test",
+ "Containers", "foo_bar");
SWTUtils.asyncExec(() -> containerTreeItem.expand());
- final SWTBotTreeItem containerPortsTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test (null)",
- "Containers", "foo_bar (null)", "Ports");
+ final SWTBotTreeItem containerPortsTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test",
+ "Containers", "foo_bar", "Ports");
SWTUtils.asyncExec(() -> containerPortsTreeItem.expand());
// then
SWTUtils.syncAssert(() -> {
@@ -189,7 +194,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldShowContainerLinks() throws InterruptedException {
+ public void shouldShowContainerLinks() {
// given
final DockerClient client = MockDockerClientFactory
.container(MockDockerContainerFactory.name("foo_bar").build(), MockDockerContainerInfoFactory
@@ -201,8 +206,8 @@ public class DockerExplorerViewSWTBotTest {
// when a second call to expand the container is done (because the first
// expandAll stopped with a "Loading..." job that retrieved the
// containers)
- final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test (null)",
- "Containers", "foo_bar (null)");
+ final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test",
+ "Containers", "foo_bar");
SWTUtils.asyncExec(() -> containerTreeItem.expand());
final SWTBotTreeItem containerLinksTreeItem = SWTUtils.getTreeItem(containerTreeItem, "Links");
SWTUtils.asyncExec(() -> containerLinksTreeItem.expand());
@@ -215,7 +220,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldShowContainerVolumes() throws InterruptedException {
+ public void shouldShowContainerVolumes() {
// given
final DockerClient client = MockDockerClientFactory
.container(MockDockerContainerFactory.name("foo_bar").build(),
@@ -229,8 +234,8 @@ public class DockerExplorerViewSWTBotTest {
// when a second call to expand the container is done (because the first
// expandAll stopped with a "Loading..." job that retrieved the
// containers)
- final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test (null)",
- "Containers", "foo_bar (null)");
+ final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test",
+ "Containers", "foo_bar");
SWTUtils.asyncExec(() -> containerTreeItem.expand());
final SWTBotTreeItem containerVolumesItem = SWTUtils.getTreeItem(containerTreeItem, "Volumes");
SWTUtils.asyncExec(() -> containerVolumesItem.expand());
@@ -246,7 +251,7 @@ public class DockerExplorerViewSWTBotTest {
}
@Test
- public void shouldRemainExpandedAfterRefresh() throws InterruptedException {
+ public void shouldRemainExpandedAfterRefresh() {
// given
final DockerClient client = MockDockerClientFactory
.container(MockDockerContainerFactory.name("foo_bar").build(),
@@ -258,9 +263,9 @@ public class DockerExplorerViewSWTBotTest {
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
- final SWTBotTreeItem containersTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test (null)",
+ final SWTBotTreeItem containersTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test",
"Containers");
- final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(containersTreeItem, "foo_bar (null)");
+ final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(containersTreeItem, "foo_bar");
SWTUtils.asyncExec(() -> containerTreeItem.expand());
SWTUtils.asyncExec(() -> SWTUtils.getTreeItem(containerTreeItem, "Links").expand());
SWTUtils.asyncExec(() -> SWTUtils.getTreeItem(containerTreeItem, "Ports").expand());
@@ -284,4 +289,208 @@ public class DockerExplorerViewSWTBotTest {
});
}
+ @Test
+ public void shouldProvideEnabledStartCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Stopped").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Stopped").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Start");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideDisabledStartCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Stopped").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Start");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void shouldProvideEnabledStopCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Stop");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideDisabledStopCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Stopped").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Stop");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void shouldProvideEnabledPauseCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Pause");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideDisabledPauseCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Up (Paused)").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Pause");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void shouldProvideEnabledUnpauseCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Up (Paused)").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Up (Paused)").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Unpause");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideDisabledUnpauseCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Up (Paused)").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Unpause");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void shouldProvideEnabledKillCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Running").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Kill");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideDisabledKillCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Stopped").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Kill");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void shouldProvideEnabledRemoveCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Stopped").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Stopped").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Remove");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void shouldProvideRemoveCommandOnMultipleContainersAtOnce() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .container(MockDockerContainerFactory.name("gentle_foo").status("Running").build())
+ .container(MockDockerContainerFactory.name("angry_bar").status("Stopped").build()).build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // open the context menu on one of the containers
+ selectMultipleContainersInTreeView();
+ final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Remove");
+ // then
+ assertThat(menuCommand.isVisible()).isEqualTo(true);
+ assertThat(menuCommand.isEnabled()).isEqualTo(false);
+ }
+
+ private SWTBotTreeItem selectMultipleContainersInTreeView() {
+ SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
+ // when a second call to expand the container is done (because the first
+ // expandAll stopped with a "Loading..." job that retrieved the
+ // containers)
+ final SWTBotTreeItem containersTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Containers");
+ SWTUtils.asyncExec(() -> containersTreeItem.expand());
+ // select both containers
+ SWTUtils.select(containersTreeItem, "gentle_foo", "angry_bar");
+ final SWTBotTreeItem containerTreeItem = SWTUtils.getTreeItem(containersTreeItem, "gentle_foo");
+ return containerTreeItem;
+ }
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
index 8bb34c4c06..7bf1bf8562 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
+++ b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
@@ -575,9 +575,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">
@@ -600,9 +597,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">
@@ -625,9 +619,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">
@@ -650,9 +641,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">
@@ -675,9 +663,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">
@@ -700,9 +685,6 @@
checkEnabled="false">
<with
variable="selection">
- <count
- value="1">
- </count>
<iterate
ifEmpty="false"
operator="and">

Back to the top