Search in sources :

Example 36 with SWTBotShell

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());
}
Also used : TestUtils(org.eclipse.linuxtools.internal.rpm.createrepo.form.tests.TestUtils) IFile(org.eclipse.core.resources.IFile) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 37 with SWTBotShell

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;
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 38 with SWTBotShell

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");
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) BeforeClass(org.junit.BeforeClass)

Example 39 with SWTBotShell

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));
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 40 with SWTBotShell

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));
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)41 Test (org.junit.Test)14 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)8 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)6 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)5 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)5 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)5 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)4 Point (org.eclipse.swt.graphics.Point)3 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 BeforeClass (org.junit.BeforeClass)3 DockerClient (com.spotify.docker.client.DockerClient)2 ProgressHandler (com.spotify.docker.client.ProgressHandler)2 Path (java.nio.file.Path)2 IFile (org.eclipse.core.resources.IFile)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2