use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.
the class PreferencesTest method setUpWorkbench.
@BeforeClass
public static void setUpWorkbench() throws Exception {
// Set up is based from from GcovTest{c,CPP}.
SWTWorkbenchBot bot = new SWTWorkbenchBot();
try {
// $NON-NLS-1$
bot.viewByTitle("Welcome").close();
// hide Subclipse Usage stats popup if present/installed
// $NON-NLS-1$
bot.shell("Subclipse Usage").activate();
// $NON-NLS-1$
bot.button("Cancel").click();
} catch (WidgetNotFoundException e) {
// ignore
}
// Set C/C++ perspective.
// $NON-NLS-1$
bot.perspectiveByLabel("C/C++").activate();
bot.sleep(500);
for (SWTBotShell sh : bot.shells()) {
if (sh.getText().startsWith("C/C++")) {
// $NON-NLS-1$
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);
}
}
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-integration-commons by spring-projects.
the class SWTBotUtils method shells.
/**
* @return a List of {@link Shell} under a parent.
* @param parent
* the parent under which a shell will be found.
*/
public static List<Shell> shells(SWTBotShell parent) {
Matcher<Shell> anyShell = widgetOfType(Shell.class);
WaitForObjectCondition<Shell> waitForShell = waitForShell(anyShell, parent.widget);
parent.bot().waitUntilWidgetAppears(waitForShell);
List<Shell> allShells = waitForShell.getAllMatches();
System.err.println(">>> SWTBot Shells found:");
for (Shell shell : allShells) {
SWTBotShell bot = new SWTBotShell(shell);
System.err.println(" '" + bot.getText() + "'");
}
System.err.println("<<< SWTBot Shells found:");
return allShells;
}
Aggregations