Search in sources :

Example 36 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot in project eclipse-pmd by acanda.

the class JavaProjectClient method createFileInProject.

/**
 * Creates a text file in a project.
 *
 * @param projectName The name of the existing project.
 * @param relativePath The path of the file including the file name, relative to the project.
 * @param content The content of the file.
 */
public static void createFileInProject(final String projectName, final Path relativePath, final String content) {
    final SWTWorkbenchBot bot = new SWTWorkbenchBot();
    bot.menu("File").menu("New").menu("File").click();
    final SWTBotShell dialog = bot.shell("New File");
    if (relativePath.getParent() != null) {
        dialog.bot().text(0).setText(projectName + "/" + relativePath.getParent().toString());
    } else {
        dialog.bot().text(0).setText(projectName);
    }
    dialog.bot().text(1).setText(relativePath.getFileName().toString());
    dialog.bot().button("Finish").click();
    final SWTBotEditor editor = bot.editorByTitle(relativePath.getFileName().toString());
    editor.toTextEditor().setText(content);
    editor.saveAndClose();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 37 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot in project eclipse-pmd by acanda.

the class GUITestCase method resetWorkbench.

@AfterClass
public static void resetWorkbench() {
    final SWTWorkbenchBot workbenchBot = new SWTWorkbenchBot();
    workbenchBot.resetWorkbench();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) AfterClass(org.junit.AfterClass)

Aggregations

SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)37 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)15 BeforeClass (org.junit.BeforeClass)15 Test (org.junit.Test)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)8 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 AbstractRefactoringSwtBotTest (org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 DockerClient (com.spotify.docker.client.DockerClient)4 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)4 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)4 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SWTUtils (org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTUtils)3 Before (org.junit.Before)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)2