use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenNameAndTCPConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenNameAndTCPConnectionSettingsChanged() {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// let's ignore the connection savings that may have occurred when
// adding elements from the extension points
Mockito.reset(connectionStorageManager);
// when
openConnectionEditionWizard("Test");
bot.text(0).setText("foo");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("foo");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenTCPConnectionSettingsChanged.
@Test
public void shouldRefreshDockerExplorerViewWhenTCPConnectionSettingsChanged() {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureTCPConnection("Test");
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// when
openConnectionEditionWizard("Test");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
SWTUtils.wait(2, TimeUnit.SECONDS);
// then
final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(updatedConnectionTreeItem).isNotNull();
assertThat(updatedConnectionTreeItem.getText()).contains("https://foo.bar:1234");
// list of containers and images should have been refreshed
Mockito.verify(connection, Mockito.times(0)).getContainers(true);
Mockito.verify(connection, Mockito.times(0)).getImages(true);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class ImagePushSWTBotTests method openPushWizard.
private void openPushWizard() {
SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
final SWTBotTreeItem imageTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo/bar");
// when opening the "Push Image..." wizard
final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
dockerExplorerViewTreeBot.select(imageTreeItem);
SWTUtils.getContextMenu(dockerExplorerViewTreeBot, "Push...").click();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class ProjectExplorer method getProjectItem.
/**
* @param projectItem The tree item corresponding to the project.
* @param name
* name of an item
* @return the project item pertaining to the project
*/
public static SWTBotTreeItem getProjectItem(SWTBotTreeItem projectItem, String file) {
for (SWTBotTreeItem item : projectItem.getItems()) {
String itemText = item.getText();
if (itemText.contains(file)) {
if (itemText.contains(" ")) {
StringTokenizer tok = new StringTokenizer(itemText, " ");
String name = tok.nextToken();
if (file.equals(name))
return item;
} else if (itemText.equals(file)) {
return item;
}
}
}
return null;
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.
the class SVNProject method checkoutProject.
/**
* Use File => Import => SVN to create a svn-backed project.
*/
public IProject checkoutProject() throws IllegalStateException {
if (repoURL == null || projectName == null) {
// need to have url and project set
throw new IllegalStateException();
}
bot.menu("File").menu("Import...").click();
SWTBotShell shell = bot.shell("Import");
shell.activate();
bot.tree().expandNode("SVN").select("Checkout Projects from SVN");
bot.button("Next >").click();
// create new repo
shell = bot.shell("Checkout from SVN");
shell.activate();
bot.button("Next >").click();
shell = bot.shell("Checkout from SVN");
shell.activate();
// Enter url
bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL);
bot.button("Next >").click();
// the next few operation can take quite a while, adjust
// timout accordingly.
long oldTimeout = SWTBotPreferences.TIMEOUT;
SWTBotPreferences.TIMEOUT = 3 * 5000;
shell = bot.shell("Progress Information").activate();
bot.waitUntil(Conditions.shellCloses(shell));
shell = bot.shell("Checkout from SVN").activate();
bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName));
SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL);
projectTree.expandNode(projectName).select();
bot.button("Finish").click();
// Wait for import operation to finish
bot.waitUntil(Conditions.shellCloses(shell));
SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout").activate();
bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup));
// need a little delay
bot.waitUntil(new SVNProjectCreatedCondition(projectName));
// Set timout back what it was.
SWTBotPreferences.TIMEOUT = oldTimeout;
// A quick sanity check
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject changelogTestsProject = (IProject) wsRoot.findMember(new Path(projectName));
assertNotNull(changelogTestsProject);
try {
changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF"));
assertNotNull(manifest);
return changelogTestsProject;
}
Aggregations