org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor Java Examples
The following examples show how to use
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeChKeyboardLayoutTest.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Tests com.avaloq.test.swtbot.DE_CH. */ @Test public void testDeChKeyboardLayout() { SWTBotPreferences.KEYBOARD_LAYOUT = "com.avaloq.test.swtbot.DE_CH"; SWTBotPreferences.KEYBOARD_STRATEGY = "org.eclipse.swtbot.swt.finder.keyboard.MockKeyboardStrategy"; SwtWorkbenchBot bot = new SwtWorkbenchBot(); bot.closeWelcomePage(); bot.menu("File").menu("New").menu("Untitled Text File").click(); SWTBotEclipseEditor editor = bot.activeEditor().toTextEditor(); editor.setFocus(); editor.typeText(EXPECTED_RESULT); String actualResult = editor.getText(); bot.closeAllEditors(); assertEquals("Written and read characters must exactly match", EXPECTED_RESULT, actualResult); }
Example #2
Source File: RenameXtendClassSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void renameXtendClassWithAA() { SWTWorkbenchBot _bot = this.getBot(); StringConcatenation _builder = new StringConcatenation(); _builder.append("import org.eclipse.xtend.lib.annotations.Data"); _builder.newLine(); _builder.append("@Data"); _builder.newLine(); _builder.append("class ?Fonk? {}"); _builder.newLine(); final SWTBotEclipseEditor barEditor = SwtBotProjectHelper.newXtendEditor(_bot, "Fonk", _builder); this.renameInXtendEditor(barEditor, "NewFonk", "Rename Element"); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("import org.eclipse.xtend.lib.annotations.Data"); _builder_1.newLine(); _builder_1.append("@Data"); _builder_1.newLine(); _builder_1.append("class NewFonk {}"); _builder_1.newLine(); this.assertEquals(_builder_1, barEditor.getText()); this.assertEquals("NewFonk.xtend", barEditor.getTitle()); }
Example #3
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static SWTBotEclipseEditor newJavaEditor(final SWTWorkbenchBot it, final String typeName, final String packageName, final String sourceFolderPath) { SWTBotEclipseEditor _xblockexpression = null; { SwtBotProjectHelper.fileNew(it, "Class"); it.shell("New Java Class").activate(); SWTBotText _textWithLabel = it.textWithLabel("Source folder:"); _textWithLabel.setText(sourceFolderPath); SWTBotText _textWithLabel_1 = it.textWithLabel("Package:"); _textWithLabel_1.setText(packageName); SWTBotText _textWithLabel_2 = it.textWithLabel("Name:"); _textWithLabel_2.setText(typeName); it.button("Finish").click(); _xblockexpression = it.editorByTitle((typeName + ".java")).toTextEditor(); } return _xblockexpression; }
Example #4
Source File: RenameJavaClassSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void renameJavaClass() { SWTWorkbenchBot _bot = this.getBot(); StringConcatenation _builder = new StringConcatenation(); _builder.append("package test"); _builder.newLine(); _builder.append("class XtendClass extends JavaClass {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final SWTBotEclipseEditor xtendEditor = SwtBotProjectHelper.newXtendEditor(_bot, "XtendClass", "test", _builder); SWTWorkbenchBot _bot_1 = this.getBot(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("package test;"); _builder_1.newLine(); _builder_1.append("public class ?JavaClass? {}"); _builder_1.newLine(); final SWTBotEclipseEditor javaEditor = SwtBotProjectHelper.newJavaEditor(_bot_1, "JavaClass", "test", _builder_1); this.renameInJavaEditor(javaEditor, "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()); }
Example #5
Source File: EditorConfigTestContext.java From editorconfig-eclipse with Apache License 2.0 | 5 votes |
public void editFile(final String fileName, final String contents) { if (Files.exists(filePath(fileName), LinkOption.NOFOLLOW_LINKS)) { bot.tree().getTreeItem(projectName).getNode(fileName).doubleClick(); } else { newFile(fileName); } final SWTBotEclipseEditor textEditor = bot.editorByTitle(fileName).toTextEditor(); textEditor.setText(""); textEditor.typeText(contents); textEditor.save(); }
Example #6
Source File: MarkerSetSwtBotTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void removeContent() { SWTBotRootMenu viewMenu = fViewBot.viewMenu(); viewMenu.menu("Marker Set").menu("Edit...").click(); fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, EDITOR_TITLE)); SWTBotEclipseEditor editor = fBot.editorByTitle(EDITOR_TITLE).toTextEditor(); editor.setText("<marker-sets></marker-sets>"); editor.saveAndClose(); WaitUtils.waitForJobs(); }
Example #7
Source File: MarkerSetSwtBotTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static void insertContent() { SWTBotRootMenu viewMenu = fViewBot.viewMenu(); viewMenu.menu("Marker Set").menu("Edit...").click(); fBot.waitUntil(ConditionHelpers.isEditorOpened(fBot, EDITOR_TITLE)); SWTBotEclipseEditor editor = fBot.editorByTitle(EDITOR_TITLE).toTextEditor(); editor.setText(XML_CONTENT); editor.saveAndClose(); WaitUtils.waitForJobs(); }
Example #8
Source File: AbstractXtextUiTest.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected void afterAllTests() { final SWTBotEclipseEditor editor = getEditor(); final IEditorPart editorPart = editor.getReference().getEditor(false); Object editorJobs = getTestUtil().getEditorJobFamily(editorPart); if (editor != null) { editor.close(); if (editorJobs != null) { waitForJobsOfFamily(editorJobs); } } super.afterAllTests(); }
Example #9
Source File: AbstractXtextUiTest.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected void beforeAllTests() { super.beforeAllTests(); initializeSWTBot(); getBot().closeWelcomePage(); getBot().resetActivePerspective(); IEditorPart editor = openEditor(getTestSource().getUri(), true); SWTBotEditor swtBotEditor = getBot().editorByTitle(editor.getTitle()); getTestInformation().putTestObject(SWTBotEclipseEditor.class, new AcfSwtBotEclipseEditor(swtBotEditor.getReference(), getBot())); }
Example #10
Source File: AbstractRefactoringSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void undo(final SWTBotEclipseEditor editor) { editor.setFocus(); editor.pressShortcut(SWT.MOD1, 'Z'); AbstractRefactoringSwtBotTest.bot.shell("Undo").activate(); AbstractRefactoringSwtBotTest.bot.button("OK").click(); SWTBot _sWTBot = new SWTBot(); WaitForRefactoringCondition _waitForRefactoringCondition = new WaitForRefactoringCondition(editor, true); _sWTBot.waitUntil(_waitForRefactoringCondition, 15000); }
Example #11
Source File: AbstractRefactoringSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void renameInJavaEditor(final SWTBotEclipseEditor javaEditor, final String newName, final String dialogName) { final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(javaEditor, "Refactor", "Rename..."); renameMenuItem.click(); boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring(); if (_isUseInlineRefactoring) { javaEditor.typeText(newName); boolean _isUsePreview = this.testParams.isUsePreview(); if (_isUsePreview) { javaEditor.pressShortcut(SWT.CTRL, SWT.CR); AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate(); AbstractRefactoringSwtBotTest.bot.button("OK").click(); } else { javaEditor.pressShortcut(KeyStroke.getInstance(SWT.LF)); } } else { SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot(); final Procedure1<SWTBot> _function = (SWTBot it) -> { SWTBotText _textWithLabel = it.textWithLabel("New name:"); _textWithLabel.setText(newName); boolean _isUsePreview_1 = this.testParams.isUsePreview(); if (_isUsePreview_1) { it.button("Next").click(); } it.button("Finish").click(); }; ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function); } this.waitForRefactoring(javaEditor); }
Example #12
Source File: AbstractRefactoringSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void renameInXtendEditor(final SWTBotEclipseEditor xtendEditor, final String newName, final String dialogName) { final SWTBotMenu renameMenuItem = SwtBotProjectHelper.clickableContextMenu(xtendEditor, "Refactor", "Rename Element"); renameMenuItem.click(); boolean _isUseInlineRefactoring = this.testParams.isUseInlineRefactoring(); if (_isUseInlineRefactoring) { this.waitForLinkedMode(); xtendEditor.typeText(newName); boolean _isUsePreview = this.testParams.isUsePreview(); if (_isUsePreview) { xtendEditor.pressShortcut(SWT.CTRL, SWT.CR); AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate(); AbstractRefactoringSwtBotTest.bot.button("OK").click(); } else { xtendEditor.pressShortcut(KeyStroke.getInstance(SWT.LF)); } } else { SWTBot _bot = AbstractRefactoringSwtBotTest.bot.shell(dialogName).activate().bot(); final Procedure1<SWTBot> _function = (SWTBot it) -> { SWTBotText _textWithLabel = it.textWithLabel("New name:"); _textWithLabel.setText(newName); boolean _isUsePreview_1 = this.testParams.isUsePreview(); if (_isUsePreview_1) { it.button("Preview >").click(); } it.button("OK").click(); }; ObjectExtensions.<SWTBot>operator_doubleArrow(_bot, _function); } this.waitForRefactoring(xtendEditor); }
Example #13
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static void setContent(final SWTBotEclipseEditor it, final CharSequence content) { final String contentString = content.toString(); it.setText(contentString.replace("?", "")); final int offset = contentString.indexOf("?"); if ((offset != (-1))) { final Pair<Integer, Integer> lineAndColumn = SwtBotProjectHelper.getLineAndColumn(contentString, offset); int _lastIndexOf = contentString.lastIndexOf("?"); int _minus = (_lastIndexOf - offset); int _minus_1 = (_minus - 1); it.selectRange((lineAndColumn.getKey()).intValue(), (lineAndColumn.getValue()).intValue(), _minus_1); } }
Example #14
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static SWTBotEclipseEditor newXtendEditor(final SWTWorkbenchBot it, final String typeName, final String packageName, final CharSequence content) { SWTBotEclipseEditor _newXtendEditor = SwtBotProjectHelper.newXtendEditor(it, typeName, packageName, (SwtBotProjectHelper.defaultProject + "/src")); final Procedure1<SWTBotEclipseEditor> _function = (SWTBotEclipseEditor it_1) -> { SwtBotProjectHelper.setContent(it_1, content); }; return ObjectExtensions.<SWTBotEclipseEditor>operator_doubleArrow(_newXtendEditor, _function); }
Example #15
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static SWTBotEclipseEditor newXtendEditor(final SWTWorkbenchBot it, final String typeName, final CharSequence content) { SWTBotEclipseEditor _newXtendEditor = SwtBotProjectHelper.newXtendEditor(it, typeName, "", (SwtBotProjectHelper.defaultProject + "/src")); final Procedure1<SWTBotEclipseEditor> _function = (SWTBotEclipseEditor it_1) -> { SwtBotProjectHelper.setContent(it_1, content); }; return ObjectExtensions.<SWTBotEclipseEditor>operator_doubleArrow(_newXtendEditor, _function); }
Example #16
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static SWTBotEclipseEditor newJavaEditor(final SWTWorkbenchBot it, final String typeName, final String packageName, final CharSequence content) { SWTBotEclipseEditor _newJavaEditor = SwtBotProjectHelper.newJavaEditor(it, typeName, packageName, (SwtBotProjectHelper.defaultProject + "/src")); final Procedure1<SWTBotEclipseEditor> _function = (SWTBotEclipseEditor it_1) -> { SwtBotProjectHelper.setContent(it_1, content); }; return ObjectExtensions.<SWTBotEclipseEditor>operator_doubleArrow(_newJavaEditor, _function); }
Example #17
Source File: RenameJavaClassSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #18
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public static SWTBotEclipseEditor newJavaEditor(final SWTWorkbenchBot it, final String typeName, final CharSequence content) { SWTBotEclipseEditor _newJavaEditor = SwtBotProjectHelper.newJavaEditor(it, typeName, "", (SwtBotProjectHelper.defaultProject + "/src")); final Procedure1<SWTBotEclipseEditor> _function = (SWTBotEclipseEditor it_1) -> { SwtBotProjectHelper.setContent(it_1, content); }; return ObjectExtensions.<SWTBotEclipseEditor>operator_doubleArrow(_newJavaEditor, _function); }
Example #19
Source File: RenameXtendClassSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #20
Source File: RenameXtendClassSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #21
Source File: RemoteBotEditor.java From saros with GNU General Public License v2.0 | 4 votes |
public void setWidget(SWTBotEclipseEditor editor) { this.widget = editor; }
Example #22
Source File: WaitForRefactoringCondition.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public WaitForRefactoringCondition(final SWTBotEclipseEditor editor, final boolean isRedo) { this.editor = editor; this.isRedo = isRedo; }
Example #23
Source File: SwtBotMenuActions.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public static String getEditorText(final SWTWorkbenchBot bot, String title) { SWTBotEclipseEditor te = bot.editorByTitle(title).toTextEditor(); return te.getText(); }
Example #24
Source File: AbstractXtextUiTest.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
public SWTBotEclipseEditor getEditor() { return (SWTBotEclipseEditor) getTestInformation().getTestObject(SWTBotEclipseEditor.class); }
Example #25
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public static SWTBotEclipseEditor newJavaEditor(final SWTWorkbenchBot it, final String typeName) { return SwtBotProjectHelper.newJavaEditor(it, typeName, "", (SwtBotProjectHelper.defaultProject + "/src")); }
Example #26
Source File: AbstractRefactoringSwtBotTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void waitForRefactoring(final SWTBotEclipseEditor editor) { SWTBot _sWTBot = new SWTBot(); WaitForRefactoringCondition _waitForRefactoringCondition = new WaitForRefactoringCondition(editor, false); _sWTBot.waitUntil(_waitForRefactoringCondition, 15000); }
Example #27
Source File: SwtBotProjectHelper.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public static SWTBotMenu clickableContextMenu(final SWTBotEclipseEditor editor, final String... text) { MenuItem _contextMenu = ContextMenuHelper.contextMenu(editor.getStyledText(), text); return new SWTBotMenu(_contextMenu); }
Example #28
Source File: AbstractOccurrencesTest.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Returns background color at the given offset in the given document. * * @param eBot * editor bot, may be {@code null} * @param document * document, may be {@code null} * @param offset * offset in the document * @return color, may be {@code null} * @throws BadLocationException * if offset is not valid for the document */ private Color getColorAtOffset(final SWTBotEclipseEditor eBot, final IDocument document, final int offset) throws BadLocationException { int line = document.getLineOfOffset(offset); int column = offset - document.getLineOffset(line); return eBot.getStyle(line, column).background; }
Example #29
Source File: DragAndDropUtil.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Performs a drag and drop operation from this widget to the target editor. * The drag start location will be chosen depending on this widget's default * implementation. * The exact drop position is calculated through the StyledText contained by the editor. * * @param source * the source widget to drag * @param target * Editor to perform the drop on * @see #dragAndDrop(Point) */ public void dragAndDrop(final AbstractSWTBot<? extends Widget> source, final SWTBotEclipseEditor target) { if (target != null) { dragAndDrop(source, on(target.getStyledText())); } }