Search in sources :

Example 1 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project xtext-xtend by eclipse.

the class RenameJavaClassSwtBotTest method renameJavaClassXtendReference.

@Test
public void renameJavaClassXtendReference() {
    SWTWorkbenchBot _bot = this.getBot();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package test;");
    _builder.newLine();
    _builder.append("public class JavaClass {}");
    _builder.newLine();
    final SWTBotEclipseEditor javaEditor = SwtBotProjectHelper.newJavaEditor(_bot, "JavaClass", "test", _builder);
    SWTWorkbenchBot _bot_1 = this.getBot();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package test");
    _builder_1.newLine();
    _builder_1.append("class XtendClass extends ?JavaClass? {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final SWTBotEclipseEditor xtendEditor = SwtBotProjectHelper.newXtendEditor(_bot_1, "XtendClass", "test", _builder_1);
    this.renameInXtendEditor(xtendEditor, "NewJavaClass", "Rename Type");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("package test");
    _builder_2.newLine();
    _builder_2.append("class XtendClass extends NewJavaClass {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    this.assertEquals(_builder_2, xtendEditor.getText());
    Assert.assertFalse(xtendEditor.isDirty());
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("package test;");
    _builder_3.newLine();
    _builder_3.append("public class NewJavaClass {}");
    _builder_3.newLine();
    this.assertEquals(_builder_3, javaEditor.getText());
    Assert.assertFalse(javaEditor.isDirty());
    this.assertEquals("NewJavaClass.java", javaEditor.getTitle());
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractRefactoringSwtBotTest(org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)

Example 2 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project xtext-xtend by eclipse.

the class RenameXtendClassBug516096SwtBotTest method testBug516096.

@Test
public void testBug516096() {
    final String projectName = "this is a test";
    SwtBotProjectHelper.newXtendProject(this.getBot(), projectName);
    SWTBotEclipseEditor _newXtendEditor = SwtBotProjectHelper.newXtendEditor(this.getBot(), "Foo", "", (projectName + "/src"));
    final Procedure1<SWTBotEclipseEditor> _function = (SWTBotEclipseEditor it) -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class ?Foo? {}");
        _builder.newLine();
        SwtBotProjectHelper.setContent(it, _builder);
    };
    final SWTBotEclipseEditor fooEditor = ObjectExtensions.<SWTBotEclipseEditor>operator_doubleArrow(_newXtendEditor, _function);
    this.renameInXtendEditor(fooEditor, "Bar", "Rename Element");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Bar {}");
    _builder.newLine();
    this.assertEquals(_builder, fooEditor.getText());
    this.assertEquals("Bar.xtend", fooEditor.getTitle());
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractRefactoringSwtBotTest(org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)

Example 3 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project xtext-xtend by eclipse.

the class RenameXtendClassSwtBotTest method renameXtendClass.

@Test
public void renameXtendClass() {
    SWTWorkbenchBot _bot = this.getBot();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo extends Bar {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final SWTBotEclipseEditor fooEditor = SwtBotProjectHelper.newXtendEditor(_bot, "Foo", _builder);
    SWTWorkbenchBot _bot_1 = this.getBot();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class ?Bar? {}");
    _builder_1.newLine();
    final SWTBotEclipseEditor barEditor = SwtBotProjectHelper.newXtendEditor(_bot_1, "Bar", _builder_1);
    this.renameInXtendEditor(barEditor, "NewBar", "Rename Element");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Foo extends NewBar {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    this.assertEquals(_builder_2, fooEditor.getText());
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("class NewBar {}");
    _builder_3.newLine();
    this.assertEquals(_builder_3, barEditor.getText());
    this.assertEquals("NewBar.xtend", barEditor.getTitle());
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractRefactoringSwtBotTest(org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)

Example 4 with SWTBotEclipseEditor

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor in project xtext-xtend by eclipse.

the class RenameXtendClassSwtBotTest method renameXtendClassReference.

@Test
public void renameXtendClassReference() {
    SWTWorkbenchBot _bot = this.getBot();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Bar {}");
    _builder.newLine();
    final SWTBotEclipseEditor barEditor = SwtBotProjectHelper.newXtendEditor(_bot, "Bar", _builder);
    SWTWorkbenchBot _bot_1 = this.getBot();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo extends ?Bar? {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final SWTBotEclipseEditor fooEditor = SwtBotProjectHelper.newXtendEditor(_bot_1, "Foo", _builder_1);
    this.renameInXtendEditor(fooEditor, "NewBar", "Rename Element");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Foo extends NewBar {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    this.assertEquals(_builder_2, fooEditor.getText());
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("class NewBar {}");
    _builder_3.newLine();
    this.assertEquals(_builder_3, barEditor.getText());
    this.assertEquals("NewBar.xtend", barEditor.getTitle());
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractRefactoringSwtBotTest(org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)

Example 5 with SWTBotEclipseEditor

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

the class TestCreateSystemtapScript method testTapsetContents.

@Test
public void testTapsetContents() {
    // Create a blank script and add a function to it while it's open.
    String scriptName = "probeScript.stp";
    createScript(bot, scriptName);
    SWTBotView funcView = bot.viewByTitle("Function");
    funcView.setFocus();
    SWTBotTree funcTree = funcView.bot().tree();
    SWTBotTreeItem item = funcTree.getTreeItem(funcNodeName);
    item.doubleClick();
    SWTBotEclipseEditor editor = bot.activeEditor().toTextEditor();
    assertTrue(editor.getText().contains(item.getText()));
    // Open a non-stap file and add a probe. This should bring up a dialog
    // asking if the function should be added to the only open .stp file.
    clickMainMenu("File", "New", "Other...");
    SWTBotShell shell = bot.shell("New");
    shell.setFocus();
    shell.bot().text().setText("Untitled Text File");
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Untitled Text File"));
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    SWTBotView probeView = bot.viewByTitle("Probe Alias");
    probeView.setFocus();
    SWTBotTree probeTree = probeView.bot().tree();
    SWTBotTreeItem probeCategory = probeTree.getTreeItem(probeCategoryFull);
    probeCategory.expand();
    bot.waitUntil(new TreeItemPopulated(probeCategory));
    String dialogTitle = "Select Script";
    item = probeCategory.getNode(probeGroup);
    item.expand();
    bot.waitUntil(new TreeItemPopulated(item));
    item = item.getNode(0);
    item.doubleClick();
    {
        Matcher<Shell> withText = withText(dialogTitle);
        bot.waitUntil(Conditions.waitForShell(withText));
    }
    shell = bot.shell(dialogTitle);
    shell.setFocus();
    bot.button("Yes").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    // The editor containing the script should now be in focus.
    bot.waitUntil(new EditorIsActive(scriptName));
    assertTrue(wasProbeInserted(editor, item, false));
    // Open the probe's definition file (an .stp script).
    probeView.show();
    item.contextMenu("View Definition").click();
    bot.waitUntil(new EditorIsActive(probeDef.getName()));
    // Adding a probe while an .stp editor is in focus should always add it
    // to that editor, even if multiple .stp editors are open.
    item = probeCategory.getNode(probeGroup);
    item.doubleClick();
    assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, true));
    assertFalse(wasProbeInserted(editor, item, true));
    // Switch to the non-stp editor, and add a probe. A dialog should appear
    // to let the user choose which of the open files to add to.
    editor = bot.editorByTitle("Untitled 1").toTextEditor();
    editor.show();
    item = probeCategory.getNode(probeSingleWithoutDef);
    item.doubleClick();
    shell = bot.shell(dialogTitle);
    shell.setFocus();
    SWTBotTable table = bot.table();
    assertTrue(table.containsItem(scriptName));
    assertTrue(table.containsItem(probeDef.getName()));
    table.select(scriptName);
    bot.button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitUntil(new EditorIsActive(scriptName));
    assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, false));
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) Matcher(org.hamcrest.Matcher) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) 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