Search in sources :

Example 16 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class ContextMenuHelper method clickContextMenu.

/**
 * Clicks the context menu matching the text.
 *
 * @param bot
 *
 * @param texts
 *            the text on the context menu.
 * @throws WidgetNotFoundException
 *             if the widget is not found.
 * @throws SWTException
 *             if the menu item is disabled (the root cause being an
 *             {@link IllegalStateException})
 */
public static void clickContextMenu(final AbstractSWTBot<?> bot, final String... texts) {
    // show
    final MenuItem menuItem = UIThreadRunnable.syncExec((WidgetResult<MenuItem>) () -> {
        MenuItem theItem = getMenuItem(bot, texts);
        if (theItem != null && !theItem.isEnabled())
            throw new IllegalStateException("Menu item is diabled");
        return theItem;
    });
    if (menuItem == null) {
        throw new WidgetNotFoundException("Could not find menu: " + Arrays.asList(texts));
    }
    // click
    click(menuItem);
    // hide
    UIThreadRunnable.syncExec(() -> {
        if (menuItem.isDisposed())
            // menu already gone
            return;
        hide(menuItem.getParent());
    });
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 17 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class AbstractSWTBotTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    // delay click speed
    // System.setProperty("org.eclipse.swtbot.playback.delay", "200");
    bot = new SWTWorkbenchBot();
    try {
        bot.viewByTitle("Welcome").close();
        // hide Subclipse Usage stats popup if present/installed
        bot.shell("Subclipse Usage").activate();
        bot.button("Cancel").click();
    } catch (WidgetNotFoundException e) {
    // ignore
    }
    // Make sure project explorer is open and tree available
    ProjectExplorer.openView();
    projectExplorerViewTree = ProjectExplorer.getTree();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) BeforeClass(org.junit.BeforeClass)

Example 18 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class PreferencesTest method setUpWorkbench.

@BeforeClass
public static void setUpWorkbench() throws Exception {
    // Set up is based from from GcovTest{c,CPP}.
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    try {
        // $NON-NLS-1$
        bot.viewByTitle("Welcome").close();
        // hide Subclipse Usage stats popup if present/installed
        // $NON-NLS-1$
        bot.shell("Subclipse Usage").activate();
        // $NON-NLS-1$
        bot.button("Cancel").click();
    } catch (WidgetNotFoundException e) {
    // ignore
    }
    // Set C/C++ perspective.
    // $NON-NLS-1$
    bot.perspectiveByLabel("C/C++").activate();
    bot.sleep(500);
    for (SWTBotShell sh : bot.shells()) {
        if (sh.getText().startsWith("C/C++")) {
            // $NON-NLS-1$
            sh.activate();
            bot.sleep(500);
            break;
        }
    }
    // Turn off automatic building by default to avoid timing issues
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    boolean isAutoBuilding = desc.isAutoBuilding();
    if (isAutoBuilding) {
        desc.setAutoBuilding(false);
        workspace.setDescription(desc);
    }
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) BeforeClass(org.junit.BeforeClass)

Example 19 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class ImportRPMsPageTest method setUpBeforeClass.

/**
 * Initialize the test project.
 *
 * @throws CoreException
 */
@BeforeClass
public static void setUpBeforeClass() throws CoreException {
    testProject = new TestCreaterepoProject();
    assertTrue(testProject.getProject().exists());
    bot = new SWTWorkbenchBot();
    try {
        bot.shell(ICreaterepoTestConstants.MAIN_SHELL).activate();
    } catch (WidgetNotFoundException e) {
    // cannot activate main shell, continue anyways
    }
    monitor = new NullProgressMonitor();
    TestUtils.openResourcePerspective(bot);
    navigator = TestUtils.enterProjectFolder(bot);
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) BeforeClass(org.junit.BeforeClass)

Example 20 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class RepoFormEditorTest method setUpBeforeClass.

/**
 * Initialize the test project.
 *
 * @throws CoreException
 */
@BeforeClass
public static void setUpBeforeClass() throws CoreException {
    testProject = new TestCreaterepoProject();
    assertTrue(testProject.getProject().exists());
    bot = new SWTWorkbenchBot();
    try {
        bot.shell(ICreaterepoTestConstants.MAIN_SHELL).activate();
    } catch (WidgetNotFoundException e) {
    // cannot activate main shell, continue anyways
    }
    TestUtils.openResourcePerspective(bot);
    navigator = TestUtils.enterProjectFolder(bot);
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) BeforeClass(org.junit.BeforeClass)

Aggregations

WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)24 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)12 BeforeClass (org.junit.BeforeClass)12 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 TestCreaterepoProject (org.eclipse.linuxtools.internal.rpm.createrepo.form.tests.TestCreaterepoProject)3 DBManagement (net.heartsome.cat.ts.test.basecase.menu.db.DBManagement)2 InformationDialog (net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 After (org.junit.After)2 File (java.io.File)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 InputDialog (net.heartsome.cat.ts.test.ui.dialogs.InputDialog)1 PreTranslateResultDialog (net.heartsome.cat.ts.test.ui.dialogs.PreTranslateResultDialog)1 PreferencesDialog (net.heartsome.cat.ts.test.ui.dialogs.PreferencesDialog)1 IsWidgetInvisible (net.heartsome.test.swtbot.waits.IsWidgetInvisible)1