Search in sources :

Example 6 with SWTBotText

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

the class AbstractRefactoringSwtBotTest method renameInJavaEditor.

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);
}
Also used : SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText)

Example 7 with SWTBotText

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

the class SwtBotProjectHelper method clearSourceFolderContents.

public static void clearSourceFolderContents(final SWTWorkbenchBot it, final String project) {
    try {
        try {
            SWTBotTree packageExplorerTree = it.tree();
            boolean _hasItems = it.tree().hasItems();
            boolean _not = (!_hasItems);
            if (_not) {
                packageExplorerTree = it.viewByTitle("Package Explorer").bot().tree();
            }
            final SWTBotTreeItem srcNode = SwtBotProjectHelper.expandNode(SwtBotProjectHelper.expandNode(packageExplorerTree, project), "src");
            SWTBotTreeItem[] _items = srcNode.getItems();
            for (final SWTBotTreeItem source : _items) {
                boolean _isDisposed = source.widget.isDisposed();
                boolean _not_1 = (!_isDisposed);
                if (_not_1) {
                    InputOutput.<SWTBotText>println(it.text());
                    srcNode.select(source.getText());
                    source.contextMenu("Delete").click();
                    it.shell("Delete").activate();
                    it.button("OK").click();
                }
            }
        } catch (final Throwable _t) {
            if (_t instanceof WidgetNotFoundException) {
                final Consumer<IResource> _function = (IResource it_1) -> {
                    try {
                        it_1.delete(true, null);
                    } catch (Throwable _e) {
                        throw Exceptions.sneakyThrow(_e);
                    }
                };
                ((List<IResource>) Conversions.doWrapArray(ResourcesPlugin.getWorkspace().getRoot().getProject(project).getFolder("src").members())).forEach(_function);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) Consumer(java.util.function.Consumer) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) IResource(org.eclipse.core.resources.IResource)

Example 8 with SWTBotText

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

the class SwtBotProjectHelper method newXtendEditor.

public static SWTBotEclipseEditor newXtendEditor(final SWTWorkbenchBot it, final String typeName, final String packageName, final String sourceFolderPath) {
    SWTBotEclipseEditor _xblockexpression = null;
    {
        try {
            SwtBotProjectHelper.fileNew(it, "Xtend Class");
        } catch (final Throwable _t) {
            if (_t instanceof WidgetNotFoundException) {
                final WidgetNotFoundException e = (WidgetNotFoundException) _t;
                final Consumer<SWTBotShell> _function = (SWTBotShell it_1) -> {
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append("Shell: \'");
                    String _text = it_1.getText();
                    _builder.append(_text);
                    _builder.append("\', active: ");
                    boolean _isActive = it_1.isActive();
                    _builder.append(_isActive);
                    InputOutput.<String>println(_builder.toString());
                };
                ((List<SWTBotShell>) Conversions.doWrapArray(it.shells())).forEach(_function);
                StringConcatenation _builder = new StringConcatenation();
                _builder.append(SWTBotPreferences.SCREENSHOTS_DIR);
                _builder.append("/MenuFileNotFound");
                long _currentTimeMillis = System.currentTimeMillis();
                _builder.append(_currentTimeMillis);
                _builder.append(".");
                _builder.append(SWTBotPreferences.SCREENSHOT_FORMAT);
                final Function1<SWTBotShell, Boolean> _function_1 = (SWTBotShell it_1) -> {
                    return Boolean.valueOf(it_1.isActive());
                };
                SWTUtils.captureScreenshot(_builder.toString(), IterableExtensions.<SWTBotShell>head(IterableExtensions.<SWTBotShell>filter(((Iterable<SWTBotShell>) Conversions.doWrapArray(it.shells())), _function_1)).widget);
                throw e;
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
        it.shell("Xtend 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 + ".xtend")).toTextEditor();
    }
    return _xblockexpression;
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 9 with SWTBotText

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

the class TestCreateSystemtapScript method testGraphConfig.

@Test
public void testGraphConfig() {
    String scriptName = "testGraph.stp";
    createScript(bot, scriptName);
    final String val0 = "i";
    final String val1 = "j";
    final String val2 = "k";
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
    bot.textWithLabel("Name:").setText(scriptName);
    // Select the "Graphing" tab.
    SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_graphOutputRun).click();
    // Create first regex.
    SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    combo.setText("Value:(\\d+) (\\d+)");
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    SWTBotText text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    text.setText("Value:1 2");
    assertEquals("Value:1 2", text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val1);
    assertEquals(val1, text.getText());
    setupGraphWithTests("Values", false);
    // Make a second regex, and a graph for it.
    shell.setFocus();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    assertEquals(2, combo.itemCount());
    combo.setSelection(combo.selectionIndex() + 1);
    assertEquals(3, combo.itemCount());
    assertEquals("", combo.getText());
    combo.setText("Other:(\\d+) (\\d+)");
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val2);
    assertEquals(val2, text.getText());
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    assertEquals("", text.getText());
    setupGraphWithTests("Others", false);
    // Apply the changes, then close the menu & reopen it to make sure settings were saved.
    shell.setFocus();
    bot.button("Apply").click();
    bot.button("Close").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    openRunConfigurations(scriptName);
    shell = bot.shell("Run Configurations");
    shell.setFocus();
    // Set the filter text to show configs of the current script
    shell.bot().text().setText(scriptName);
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "SystemTap", scriptName));
    tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    SWTBotTable table = bot.table();
    assertEquals(3, combo.itemCount());
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    assertEquals("Value:1 2", text.getText());
    assertEquals(1, table.rowCount());
    String graphName = GraphFactory.getGraphName("org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder");
    assertTrue(table.containsItem(graphName.concat(":Values")));
    combo.setSelection(1);
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    assertEquals("", text.getText());
    assertEquals(1, table.rowCount());
    assertTrue(table.containsItem(graphName.concat(":Others")));
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotCTabItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem) Test(org.junit.Test)

Example 10 with SWTBotText

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

the class TestCreateSystemtapScript method setupGraphWithTests.

private static void setupGraphWithTests(String title, boolean isTab) {
    SWTBotShell firstShell = bot.activeShell();
    openGraphMenu(isTab);
    SWTBotShell shell = bot.shell("Create Graph");
    shell.setFocus();
    SWTBotText text = bot.textWithLabel("Title:");
    text.setText(title);
    assertEquals(title, text.getText());
    SWTBotCombo comboX = bot.comboBoxWithLabel("X Series:");
    // X Series includes "Row Num" as a selection
    assertEquals(3, comboX.itemCount());
    SWTBotCombo comboY0 = bot.comboBoxWithLabel("Y Series 0:");
    // Y Series 0 only includes series entries
    assertEquals(2, comboY0.itemCount());
    comboY0.setSelection(0);
    SWTBotCombo comboY1 = bot.comboBoxWithLabel("Y Series 1:");
    // Y Series (i>0) has extra "NA" option as first entry
    assertEquals(3, comboY1.itemCount());
    comboY1.setSelection(1);
    // Don't allow duplicate selections
    assertFalse(bot.button("Finish").isEnabled());
    comboY1.setSelection(2);
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    firstShell.setFocus();
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Aggregations

SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)2 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)2 List (java.util.List)1 Consumer (java.util.function.Consumer)1 ProjectExistsDialog (net.heartsome.cat.ts.test.ui.dialogs.ProjectExistsDialog)1 RenameProblemsDialog (net.heartsome.cat.ts.test.ui.dialogs.RenameProblemsDialog)1 IsSegmentSelected (net.heartsome.cat.ts.test.ui.waits.IsSegmentSelected)1 IResource (org.eclipse.core.resources.IResource)1 Point (org.eclipse.swt.graphics.Point)1 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)1 SWTBotCTabItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem)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 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 Test (org.junit.Test)1