Search in sources :

Example 66 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project dsl-devkit by dsldevkit.

the class SwtWorkbenchBot method waitUntilWizardPageAppears.

/**
 * Waits until a wizard page with the given title is visible and active.
 *
 * @param wizardPageTitle
 *          the title of the wizard page
 */
public void waitUntilWizardPageAppears(final String wizardPageTitle) {
    waitUntil(new ICondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
            return syncExec(new BoolResult() {

                @Override
                public Boolean run() {
                    SWTBotShell wizardShell = activeShell();
                    if (wizardShell.widget.getData() instanceof WizardDialog) {
                        return ((WizardDialog) wizardShell.widget.getData()).getCurrentPage().getTitle().equals(wizardPageTitle);
                    }
                    return false;
                }
            });
        }

        @Override
        public void init(final SWTBot paramSWTBot) {
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Failed to find the wizard page with title ''{0}''.", wizardPageTitle);
        }
    });
    // additionally, we need to wait until the wizard page has finished loading (button cancel is enabled).
    waitUntil(new ICondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
            return button("Cancel").isEnabled();
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return NLS.bind("Failed while waiting for the wizard page with title ''{0}''.", wizardPageTitle);
        }
    });
    sleep(DELAY_WIZARD_PAGE);
}
Also used : AbstractSWTBot(org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) BoolResult(org.eclipse.swtbot.swt.finder.results.BoolResult) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition)

Example 67 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project dsl-devkit by dsldevkit.

the class CoreSwtbotTools method checkOpenWindow.

/**
 * Returns {@code true} if the SWTBot finds the specified window.
 *
 * @param bot
 *          the {@link SWTWorkbenchBot}, must not be {@code null}
 * @param windowName
 *          the name of the window to search for, must not be {@code null}
 * @return {@code true} if a window was found, {@code false} otherwise
 */
public static boolean checkOpenWindow(final SWTWorkbenchBot bot, final String windowName) {
    Assert.isNotNull(bot, ARGUMENT_BOT);
    Assert.isNotNull(windowName, "windowName");
    Boolean windowFound = false;
    try {
        final SWTBotShell shell = bot.shell(windowName);
        shell.isActive();
        windowFound = true;
    } catch (WidgetNotFoundException exception) {
        throw new WrappedException("Error during searching for window", exception);
    }
    return windowFound;
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) WrappedException(org.eclipse.emf.common.util.WrappedException) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 68 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project dsl-devkit by dsldevkit.

the class CoreSwtbotTools method switchPerspective.

/**
 * Switching to a new Perspective.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param perspective
 *          the new perspective to open, must not be {@code null}
 */
public static void switchPerspective(final SWTWorkbenchBot bot, final String perspective) {
    Assert.isNotNull(bot, ARGUMENT_BOT);
    Assert.isNotNull(perspective, "perspective");
    // Change the perspective via the Open Perspective dialog
    bot.menu("Window").menu("Open Perspective").menu("Other...").click();
    final SWTBotShell shell = bot.shell("Open Perspective");
    shell.activate();
    // select the dialog
    bot.table().select(perspective);
    bot.button("OK").click();
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 69 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project dsl-devkit by dsldevkit.

the class SwtWizardBot method closeWizard.

/**
 * Close the wizard.
 */
public void closeWizard() {
    SWTBotShell activeShell = activeShell();
    boolean wizardIsActive = isWizard(activeShell);
    assertTrue("Wizard is active on close", wizardIsActive);
    activeShell.close();
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 70 with SWTBotShell

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

the class StsUiTestCase method cleanUp.

protected void cleanUp() throws Exception {
    List<? extends SWTBotEditor> editors = bot.editors();
    for (SWTBotEditor editor : editors) {
        editor.close();
    }
    StsTestUtil.deleteAllProjects();
    Shell mainWidget = UIThreadRunnable.syncExec(new Result<Shell>() {

        public Shell run() {
            return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        }
    });
    SWTBotShell[] shells = bot.shells();
    SWTBotShell mainShell = null;
    for (SWTBotShell shell : shells) {
        if (shell.widget != mainWidget) {
            shell.close();
        } else {
            mainShell = shell;
        }
    }
    if (mainShell != null) {
        mainShell.activate();
    }
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

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