Search in sources :

Example 6 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testCreateScript.

@Test
public void testCreateScript() {
    String scriptName = "testScript.stp";
    createScript(bot, scriptName);
    // Type a script
    SWTBotEclipseEditor editor = bot.editorByTitle(scriptName).toTextEditor();
    editor.typeText(0, editor.getText().length(), "\nprobe begin{log(\"began");
    editor.typeText(0, editor.getText().length() - 1, "); exit(");
    editor.typeText(0, editor.getText().length(), "}");
    editor.save();
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 7 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project linuxtools by eclipse.

the class TestCreateSystemtapScript method prepareScript.

private static SWTBotShell prepareScript(String scriptName, String scriptContents) {
    createScript(bot, scriptName);
    if (scriptContents != null) {
        SWTBotEclipseEditor editor = bot.editorByTitle(scriptName).toTextEditor();
        editor.setText(scriptContents);
        editor.save();
    }
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
    // Select the "Graphing" tab and enable output graphing.
    bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle).activate();
    bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_graphOutputRun).click();
    return shell;
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 8 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project linuxtools by eclipse.

the class AddChangelogEntrySWTBotTest method canAddChangeLogEntryUsingEditMenuIfSourceIsActive.

/**
 * ChangeLog editor should pop-up if inside an active editor
 * and a ChangeLog file exists in the project. Tests the "Edit" => "ChangeLog Entry"
 * menu item.
 *
 * @throws Exception
 */
@Test
public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception {
    // Add a Java source file
    String sourceCode = "package src;\n" + "public class JavaTest {\n" + "public static void main(String args[]) {\n" + "//" + OFFSET_MARKER + "\n" + "System.out.println(\"Hello World!\");\n" + "}\n" + "}\n";
    assertNull(project.getTestProject().findMember(new Path("/src/JavaTest.java")));
    InputStream newFileInputStream = new ByteArrayInputStream(sourceCode.getBytes());
    project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
    // Add a changelog file
    newFileInputStream = new ByteArrayInputStream("".getBytes());
    project.addFileToProject("/", "ChangeLog", newFileInputStream);
    assertNotNull(project.getTestProject().findMember(new Path("/src/JavaTest.java")));
    assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
    // Open JavaTest.java in an editor
    SWTBotTreeItem projectItem = projectExplorerViewTree.expandNode(PROJECT_NAME);
    projectItem.expandNode("src").expandNode("JavaTest.java").doubleClick();
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("JavaTest.java"));
    // Wait for editor to open
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
    // Click menu item.
    bot.menu("Edit").menu("Insert ChangeLog entry").click();
    // Wait for ChangeLog editor to open
    editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    swtBoteditor = bot.activeEditor();
    // save to avoid "save changes"-pop-up
    swtBoteditor.save();
    assertEquals("ChangeLog", swtBoteditor.getTitle());
    eclipseEditor = swtBoteditor.toTextEditor();
    // make sure expected entry has been added.
    assertTrue(eclipseEditor.getText().contains("* src/JavaTest.java"));
}
Also used : Path(org.eclipse.core.runtime.Path) 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) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 9 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project linuxtools by eclipse.

the class FormatChangeLogSWTBotTest method canFormatChangeLogFile.

/**
 * Simple test for ChangeLog formatting.
 *
 * @throws Exception
 */
@Test
public void canFormatChangeLogFile() throws Exception {
    // add a ChangeLog file
    assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
    final String changelogContent = "2010-12-14  Severin Gehwolf  <sgehwolf@redhat.com>\n\n" + "\tAdded org.eclipse.linuxtools.changelog.tests.ui plug-in.\n" + "\t* .classpath: New file.\n" + "\t* .project: New file.\n" + "\t* .settings/org.eclipse.jdt.core.prefs: New file.\n" + "\t* build.properties: New file.\n" + "\t* src/log4j.xml: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file.\n";
    project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changelogContent.getBytes()));
    assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
    // select ChangeLog file
    String teamProviderString = "n/a";
    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");
    // should open ChangeLog file
    changeLogItem.doubleClick();
    oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    // Wait for ChangeLog editor to open
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    SWTBotEditor swtBoteditor = bot.activeEditor();
    assertEquals("ChangeLog", swtBoteditor.getTitle());
    SWTBotEclipseEditor swtBotEclipseEditor = swtBoteditor.toTextEditor();
    // Add two extra lines after the first date line
    swtBotEclipseEditor.insertText(1, 0, "\n\n");
    // Should have 3 empty lines between date-line and first file entry
    swtBotEclipseEditor.selectRange(1, 0, 3);
    // format: ESC CTRL+F
    swtBotEclipseEditor.pressShortcut(Keystrokes.ESC);
    swtBotEclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("F"));
    swtBoteditor.save();
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) ProjectExplorerTreeItemAppearsCondition(org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition) 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) Test(org.junit.Test)

Example 10 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project linuxtools by eclipse.

the class PrepareChangelogSWTBotTest method canPrepareChangeLog.

/**
 * Basic prepare changelog test.
 *
 * @throws Exception
 */
@Test
@Ignore
public void canPrepareChangeLog() throws Exception {
    // Find manifest file
    IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
    assertNotNull(manifest);
    // delete it
    manifest.delete(true, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    // select ChangeLog file
    String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
    SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
    SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
    changeLogItem.select();
    // Should be unique
    bot.menu("Prepare ChangeLog").click();
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    // Wait for ChangeLog editor to open
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotEditor swtBoteditor = bot.activeEditor();
    // save to avoid "save changes"-pop-up
    swtBoteditor.save();
    assertEquals("ChangeLog", swtBoteditor.getTitle());
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    // make sure expected entry has been added.
    assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IEditorReference(org.eclipse.ui.IEditorReference) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IResource(org.eclipse.core.resources.IResource) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)18 Test (org.junit.Test)14 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 Path (org.eclipse.core.runtime.Path)6 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)6 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)6 IEditorReference (org.eclipse.ui.IEditorReference)6 AbstractRefactoringSwtBotTest (org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 Ignore (org.junit.Ignore)4 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 InputStream (java.io.InputStream)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)2 List (java.util.List)1 TableAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1