Search in sources :

Example 1 with BoolResult

use of org.eclipse.swtbot.swt.finder.results.BoolResult 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 2 with BoolResult

use of org.eclipse.swtbot.swt.finder.results.BoolResult in project dsl-devkit by dsldevkit.

the class CheckWizardTestUtil method waitForGrammarFieldEnabled.

/**
 * Waits until the grammar field combo box is enabled.
 *
 * @param wizard
 *          the wizard
 */
public static void waitForGrammarFieldEnabled(final SwtWizardBot wizard) {
    boolean wizardIsActive = syncExec(new BoolResult() {

        @Override
        public Boolean run() {
            SWTBotShell wizardShell = wizard.activeShell();
            return wizardShell.widget.getData() instanceof WizardDialog;
        }
    });
    assertTrue("Wizard is active before waiting on grammar field", wizardIsActive);
    wizard.waitUntil(Conditions.widgetIsEnabled(wizard.comboBoxWithLabel(Messages.GRAMMAR_FIELD_NAME_LABEL)), 2 * SwtWizardBot.SWTBOT_TIMEOUT);
}
Also used : BoolResult(org.eclipse.swtbot.swt.finder.results.BoolResult) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 BoolResult (org.eclipse.swtbot.swt.finder.results.BoolResult)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)1 ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)1 AbstractSWTBot (org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot)1