Search in sources :

Example 6 with SWTBot

use of org.eclipse.swtbot.swt.finder.SWTBot in project linuxtools by eclipse.

the class CreateChangeLogFromHistorySWTBotTest method canPrepareChangeLogFromSVNHistory.

/**
 * Create changelog from SVN history (commit messages).
 *
 * @throws Exception
 */
@Test
@Ignore
public void canPrepareChangeLogFromSVNHistory() throws Exception {
    // select ChangeLog file
    String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
    SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 5000;
    bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
    changeLogItem.select();
    // open history for ChangeLog file
    clickOnShowHistory(projectExplorerViewTree);
    SWTBot historyViewBot = bot.viewByTitle("History").bot();
    // wait for SVN revision table to appear
    oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    historyViewBot.waitUntil(new TableAppearsCondition());
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotTable historyTable = historyViewBot.table();
    // select the first row
    historyTable.select(0);
    // right-click => Generate Changelog...
    clickOnGenerateChangeLog(historyTable);
    SWTBotShell shell = bot.shell("Generate ChangeLog").activate();
    SWTBot generateChangelogBot = shell.bot();
    generateChangelogBot.radio("Clipboard").click();
    generateChangelogBot.button("OK").click();
    // create and open a new file for pasting
    String pasteFile = "newFile";
    IFile newFile = project.getFile(new Path(pasteFile));
    newFile.create(new ByteArrayInputStream("".getBytes()), /* empty content */
    false, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    assertNotNull(project.findMember(new Path(pasteFile)));
    ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString).expandNode(pasteFile).select().doubleClick();
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName(pasteFile));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotEditor swtBoteditor = bot.activeEditor();
    assertEquals(pasteFile, swtBoteditor.getTitle());
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    // go to beginning of editor
    eclipseEditor.selectRange(0, 0, 0);
    // paste
    eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
    swtBoteditor.save();
    // make sure some changelog like text was pasted
    String text = eclipseEditor.getText();
    assertFalse(text.isEmpty());
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectExplorerTreeItemAppearsCondition(org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition) IFile(org.eclipse.core.resources.IFile) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) TableAppearsCondition(org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IEditorReference(org.eclipse.ui.IEditorReference) ByteArrayInputStream(java.io.ByteArrayInputStream) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with SWTBot

use of org.eclipse.swtbot.swt.finder.SWTBot 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 8 with SWTBot

use of org.eclipse.swtbot.swt.finder.SWTBot 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

SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)8 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)3 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 WaitForRefactoringCondition (org.eclipse.xtend.ide.tests.WaitForRefactoringCondition)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IFile (org.eclipse.core.resources.IFile)1 Path (org.eclipse.core.runtime.Path)1 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)1 TableAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition)1 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)1 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)1 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)1 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 IEditorReference (org.eclipse.ui.IEditorReference)1 WaitForLinkedModeCondition (org.eclipse.xtend.ide.tests.WaitForLinkedModeCondition)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1