Search in sources :

Example 91 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.

the class SWTBotUtils method selectChildTreeElement.

/**
 * Given a view name containing a tree, this method will attempt to select a
 * node contained within a parent.
 *
 * @param bot
 *           containing shell with a tree
 * @param shellName
 *           of the shell containing tree
 * @param parentName
 *           parent containing the node to be selected
 * @param childName
 *           node to be selected
 * @return the selected node
 */
public static SWTBotTreeItem selectChildTreeElement(SWTBot bot, String shellName, String parentName, String childName) {
    SWTBotShell shell = bot.shell(shellName);
    shell.activate();
    SWTBotTreeItem parentNode = SWTBotConditions.waitForNodeExpanded(bot, parentName);
    SWTBotTreeItem childNode = SWTBotConditions.waitChildNodeToAppear(bot, parentNode, childName);
    return childNode.select();
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 92 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.

the class SWTBotUtils method openPerspective.

/**
 * Open a particular perspective, or try to activate it if it can't be
 * opened (maybe it already open)
 */
public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) {
    SWTBotShell shell = null;
    try {
        menu(bot, "Window").menu("Open Perspective").menu("Other...").click();
        shell = bot.shell("Open Perspective");
        // SWTBotUtils.screenshot("openPerspective_"+perspectiveLabel);
        assertTrue(shell.isOpen());
        bot.waitUntil(SWTBotUtils.widgetMakeActive(shell));
        shell.bot().table().select(perspectiveLabel);
        shell.bot().button("OK").click();
        bot.waitUntil(Conditions.shellCloses(shell));
    } catch (Exception e) {
        if (shell != null && shell.isOpen())
            shell.close();
        System.err.println("Couldn't open perspective '" + perspectiveLabel + "'\n" + "trying to activate already open perspective instead");
        // maybe somehow the perspective is already opened (by another test
        // before us)
        SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel);
        perspective.activate();
        assertTrue(perspective.isActive());
    }
    Assert.assertEquals(perspectiveLabel, bot.activePerspective().getLabel());
}
Also used : SWTBotPerspective(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotPerspective) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 93 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project eclipse-integration-commons by spring-projects.

the class UITestCase method activateFileNewWizardShell.

/**
 * Activate a wizard from the "File >> New" menu.
 *
 * @param projectWizardName
 * @param wizardShellName
 * @return A reference to the Wizard's shell.
 */
protected SWTBotShell activateFileNewWizardShell(String projectWizardName, String wizardShellName) {
    SWTBotUtils.menu(bot, "File").menu("New").menu(projectWizardName).click();
    SWTBotShell shell = bot.shell(wizardShellName);
    shell.activate();
    return shell;
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 94 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project epp.mpc by eclipse.

the class AbstractMarketplaceWizardBotTest method closeWizard.

protected void closeWizard() {
    String problem = null;
    List<Exception> exceptions = new ArrayList<Exception>();
    SWTBotShell mpcShell;
    try {
        // check if dialog is still open
        mpcShell = bot.shell("Eclipse Marketplace");
    } catch (TimeoutException e) {
        // no MPC wizard found - maybe a bit strange, but so be it...
        return;
    }
    // check if any message dialogs are open
    boolean dumpedThreads = false;
    try {
        WaitForObjectCondition<Shell> subShellResult = Conditions.waitForShell(Matchers.any(Shell.class), mpcShell.widget);
        bot.waitUntil(subShellResult, 100, 60);
        List<Shell> subShells = subShellResult.getAllMatches();
        for (Shell shell : subShells) {
            if (shell == mpcShell.widget) {
                continue;
            }
            try {
                SWTBotShell botShell = new SWTBotShell(shell);
                // children are unexpected, so let's cry foul...
                if (problem == null) {
                    problem = "MPC wizard has open child dialog:";
                }
                problem += "\n" + describeShell(botShell);
                logger.info(problem);
                problem += "\n" + captureShellScreenshot(botShell);
                // "Wizard can not be closed due to an active operation"
                if (!dumpedThreads) {
                    dumpedThreads = true;
                    dumpThreads();
                }
                // kill message dialog
                botShell.close();
            } catch (Exception ex) {
                exceptions.add(ex);
            }
        }
    } catch (Exception ex) {
        exceptions.add(ex);
    }
    // try killing it softly
    try {
        mpcShell.activate();
        waitForWizardProgress(SWTBotPreferences.TIMEOUT);
        // same as pressing "Cancel" actually
        mpcShell.close();
        ICondition shellCloses = Conditions.shellCloses(mpcShell);
        bot.waitUntil(shellCloses);
        return;
    } catch (Exception ex) {
        exceptions.add(ex);
    }
    // now kill it hard - this is a last resort, because it can cause spurious errors in MPC jobs
    // also dump threads, since this is often caused by the wizard not being cancellable due to a still running operation:
    // "Wizard can not be closed due to an active operation"
    problem += "\nFailed to close wizard regularly. Forcing close.";
    if (!dumpedThreads) {
        dumpedThreads = true;
        dumpThreads();
    }
    try {
        final Shell shell = mpcShell.widget;
        if (!shell.isDisposed()) {
            Display display = shell.getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    if (!shell.isDisposed()) {
                        shell.dispose();
                    }
                }
            });
        }
    } catch (Exception ex) {
        exceptions.add(ex);
    }
    if (problem != null || !exceptions.isEmpty()) {
        // something happened
        try {
            fail(problem);
        } catch (AssertionError e) {
            for (Exception exception : exceptions) {
                e.addSuppressed(exception);
            }
            throw e;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) TimeoutException(org.eclipse.swtbot.swt.finder.widgets.TimeoutException) AssumptionViolatedException(org.junit.AssumptionViolatedException) ExecutionException(org.eclipse.core.commands.ExecutionException) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) TimeoutException(org.eclipse.swtbot.swt.finder.widgets.TimeoutException) Display(org.eclipse.swt.widgets.Display)

Example 95 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project epp.mpc by eclipse.

the class MarketplaceWizardTest method testMoreInfoLearnMore.

// TODO conditional on embedded browser availability
// FIXME
@Ignore("Tooltip doesn't stay open")
@Test
public void testMoreInfoLearnMore() {
    SWTBotClickableStyledText descriptionLabel = SWTBotClickableStyledText.from(bot.styledTextWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, AbstractMarketplaceDiscoveryItem.WIDGET_ID_DESCRIPTION));
    StyleRange linkRange = findLink(descriptionLabel, "more\u00a0info");
    bot.sleep(5000);
    descriptionLabel.click(linkRange);
    bot.sleep(5000);
    SWTBotShell tooltip = bot.shellWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, DiscoveryItem.WIDGET_ID_OVERVIEW);
    SWTBotLink moreLink = tooltip.bot().linkWithId(AbstractMarketplaceDiscoveryItem.WIDGET_ID_KEY, DiscoveryItem.WIDGET_ID_LEARNMORE);
    moreLink.click();
    checkMarketplaceBrowser();
}
Also used : SWTBotLink(org.eclipse.swtbot.swt.finder.widgets.SWTBotLink) StyleRange(org.eclipse.swt.custom.StyleRange) SWTBotClickableStyledText(org.eclipse.epp.mpc.tests.ui.wizard.widgets.SWTBotClickableStyledText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)158 Test (org.junit.Test)82 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)46 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)40 Repository (org.eclipse.jgit.lib.Repository)18 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)11 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)11 File (java.io.File)10 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)9 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)9 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)7 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)7 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)7 Path (org.eclipse.core.runtime.Path)6 JobJoiner (org.eclipse.egit.ui.test.JobJoiner)6 Shell (org.eclipse.swt.widgets.Shell)6 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)6 IProject (org.eclipse.core.resources.IProject)5 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)5