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));
}
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;
}
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;
}
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]);
}
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;
}
Aggregations