use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.
the class CreaterepoWizardTest method testCreaterepoWizardProjectCreation.
/**
* Go through the project creation wizard process of creating a new
* createrepo project.
*
* @throws CoreException
* @throws IOException
*/
@Test
public void testCreaterepoWizardProjectCreation() throws CoreException, IOException {
// go through the process of creating a new createrepo project
bot.menu(ICreaterepoTestConstants.FILE).menu(ICreaterepoTestConstants.NEW).menu(ICreaterepoTestConstants.OTHER).click();
SWTBotShell shell = bot.shell(ICreaterepoTestConstants.NEW);
shell.activate();
bot.text().setText(ICreaterepoTestConstants.CREATEREPO_PROJECT_WIZARD);
bot.waitUntil(new TestUtils.NodeAvailableAndSelect(bot.tree(), ICreaterepoTestConstants.CREATEREPO_PROJECT_CATEGORY, ICreaterepoTestConstants.CREATEREPO_PROJECT_WIZARD));
bot.button(ICreaterepoTestConstants.NEXT_BUTTON).click();
bot.textWithLabel(ICreaterepoTestConstants.PROJECT_NAME_LABEL).setText(ICreaterepoTestConstants.PROJECT_NAME);
bot.button(ICreaterepoTestConstants.NEXT_BUTTON).click();
bot.textWithLabel(Messages.CreaterepoNewWizardPageTwo_labelID).setText(REPO_ID);
bot.textWithLabel(Messages.CreaterepoNewWizardPageTwo_labelName).setText(REPO_WIZARD_NAME);
bot.textWithLabel(Messages.CreaterepoNewWizardPageTwo_labelURL).setText(REPO_WIZARD_URL);
bot.button(ICreaterepoTestConstants.FINISH_BUTTON).click();
// verify that project has been initialized properly
project = root.getProject(ICreaterepoTestConstants.PROJECT_NAME);
assertTrue(project.exists());
assertTrue(project.hasNature(CreaterepoProjectNature.CREATEREPO_NATURE_ID));
// 3 = .project + content folder + .repo file
assertEquals(3, project.members().length);
// contains the content folder and repo file
assertTrue(project.findMember(ICreaterepoConstants.CONTENT_FOLDER).exists());
assertTrue(project.findMember(REPO_FILE).exists());
// content folder has nothing in it
IFolder contentFolder = (IFolder) project.findMember(ICreaterepoConstants.CONTENT_FOLDER);
assertEquals(0, contentFolder.members().length);
// get the created .repo file contents
IFile repoFile = (IFile) project.findMember(REPO_FILE);
// repo file should not be empty
assertNotEquals(0, repoFile.getContents().available());
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(repoFile.getContents()));
String line;
while ((line = br.readLine()) != null) {
// disregards newline
sb.append(line);
}
assertEquals(REPO_FILE_CONTENTS, sb.toString());
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.
the class TestUtils method openPropertyPage.
/**
* Open the property page, and activate its shell.
*/
public static SWTBotShell openPropertyPage(SWTWorkbenchBot bot, SWTBotView navigator) {
navigator.show();
// select the .repo file from the package explorer and open its properties
SWTBotTree botTree = navigator.bot().tree();
botTree.select(ICreaterepoTestConstants.REPO_NAME).contextMenu(ICreaterepoTestConstants.PROPERTIES).click();
// get a handle of the property shell
SWTBotShell propertyShell = bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME));
propertyShell.activate();
return propertyShell;
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.
the class AbstractSWTBotTest method setUpWorkbench.
@BeforeClass
public static void setUpWorkbench() throws Exception {
SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
bot.viewByTitle("Welcome").close();
// hide Subclipse Usage stats popup if present/installed
bot.shell("Subclipse Usage").activate();
bot.button("Cancel").click();
} catch (WidgetNotFoundException e) {
// ignore
}
// Set C/C++ perspective.
bot.perspectiveByLabel("C/C++").activate();
bot.sleep(500);
for (SWTBotShell sh : bot.shells()) {
if (sh.getText().startsWith("C/C++")) {
sh.activate();
bot.sleep(500);
break;
}
}
// Turn off automatic building by default to avoid timing issues
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription desc = workspace.getDescription();
boolean isAutoBuilding = desc.isAutoBuilding();
if (isAutoBuilding) {
desc.setAutoBuilding(false);
workspace.setDescription(desc);
}
projectExplorer = bot.viewByTitle("Project Explorer");
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-pmd by acanda.
the class JavaProjectClient method createJavaProject.
/**
* Creates a Java project with the provided name.
*
* @param name The name of the Java project.
*/
public static void createJavaProject(final String name) {
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.menu("File").menu("New").menu("Project...").click();
final SWTBotShell dialog = bot.shell("New Project");
final SWTBot newProjectDialogBot = dialog.bot();
final SWTBotTree projectTree = newProjectDialogBot.tree();
projectTree.expandNode("Java", "Java Project").select();
newProjectDialogBot.button("Next >").click();
newProjectDialogBot.textWithLabel("Project name:").setText(name);
newProjectDialogBot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(dialog));
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-pmd by acanda.
the class JavaProjectClient method deleteJavaProject.
/**
* Deletes the project with the provided name.
*
* @param name The name of the project.
*/
public static void deleteJavaProject(final String name) {
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.viewById("org.eclipse.jdt.ui.PackageExplorer").bot().tree().getTreeItem(name).contextMenu("Delete").click();
final SWTBotShell dialog = bot.shell("Delete Resources");
final SWTBot dialogBot = dialog.bot();
dialogBot.checkBox().select();
dialogBot.button("OK").click();
bot.waitUntil(Conditions.shellCloses(dialog));
}
Aggregations