1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2017,2018 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.eclipse.linuxtools.docker.integration.tests.ui;
import static org.junit.Assert.assertTrue;
import org.eclipse.linuxtools.docker.integration.tests.image.AbstractImageBotTest;
import org.eclipse.linuxtools.docker.reddeer.ui.DockerImagesTab;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.eclipse.ui.views.properties.PropertySheet;
import org.eclipse.reddeer.swt.api.TableItem;
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class ImageTabTest extends AbstractImageBotTest {
@Before
public void before() {
clearConsole();
deleteAllConnections();
getConnection();
}
@Test
public void testImageTab() {
pullImage(IMAGE_HELLO_WORLD);
DockerImagesTab imageTab = new DockerImagesTab();
imageTab.activate();
imageTab.refresh();
new WaitWhile(new JobIsRunning(), TimePeriod.DEFAULT);
String idFromTable = "";
String repoTagsFromTable = "";
String createdFromTable = "";
String sizeFromTable = "";
for (TableItem item : imageTab.getTableItems()) {
if (item.getText(1).contains(IMAGE_HELLO_WORLD)) {
idFromTable = item.getText();
repoTagsFromTable = item.getText(1);
createdFromTable = item.getText(2);
sizeFromTable = item.getText(3).replaceAll(".", "").replaceAll(" MB", "");
item.click();
}
}
idFromTable = idFromTable.replace("sha256:", "");
getConnection().getImage(getCompleteImageName(IMAGE_HELLO_WORLD)).select();
PropertySheet propertiesView = new PropertySheet();
propertiesView.open();
propertiesView.selectTab("Info");
String idProp = propertiesView.getProperty("Id").getPropertyValue();
String repoTagsProp = propertiesView.getProperty("RepoTags").getPropertyValue();
String createdProp = propertiesView.getProperty("Created").getPropertyValue();
String sizeProp = propertiesView.getProperty("VirtualSize").getPropertyValue();
assertTrue("Id in table and in Properties do not match!", idProp.contains(idFromTable));
assertTrue("RepoTags in table and in Properties do not match!", repoTagsProp.equals(repoTagsFromTable));
assertTrue("Created in table and in Properties do not match!", createdProp.equals(createdFromTable));
assertTrue("Size in table and in Properties do not match!", sizeProp.startsWith(sizeFromTable));
}
@Test
public void testImageTabSearch() {
pullImage(IMAGE_HELLO_WORLD);
DockerImagesTab imageTab = new DockerImagesTab();
imageTab.activate();
imageTab.refresh();
new WaitWhile(new JobIsRunning(), TimePeriod.DEFAULT);
imageTab.searchImage("aaa");
assertTrue("Search result is not 0!", imageTab.getTableItems().size() == 0);
imageTab.searchImage("");
assertTrue("Search result is 0!", imageTab.getTableItems().size() > 0);
}
@Override
@After
public void after() {
deleteImageContainerAfter(IMAGE_HELLO_WORLD);
}
}
|