Search in sources :

Example 21 with WidgetNotFoundException

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

the class CreaterepoDeltaPropertyPageTest 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();
    testProject.restoreDefaults();
    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) TestCreaterepoProject(org.eclipse.linuxtools.internal.rpm.createrepo.form.tests.TestCreaterepoProject) BeforeClass(org.junit.BeforeClass)

Example 22 with WidgetNotFoundException

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

the class CreaterepoDeltaPropertyPageTest method tearDown.

/**
 * Restore the defaults for the general preference page.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws BackingStoreException {
    try {
        if (bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).isActive()) {
            bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).close();
        }
    } catch (WidgetNotFoundException e) {
    // cannot close property shell
    }
    testProject.restoreDefaults();
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    assertEquals(0, pref.keys().length);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 23 with WidgetNotFoundException

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

the class CreaterepoGeneralPropertyPageTest method tearDown.

/**
 * Restore the defaults for the general preference page.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws BackingStoreException {
    try {
        if (bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).isActive()) {
            bot.shell(String.format(ICreaterepoTestConstants.PROPERTIES_SHELL, ICreaterepoTestConstants.REPO_NAME)).close();
        }
    } catch (WidgetNotFoundException e) {
    // cannot close property shell
    }
    testProject.restoreDefaults();
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    assertEquals(0, pref.keys().length);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 24 with WidgetNotFoundException

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

the class AbstractSWTBotTest method setUpWorkbench.

@BeforeClass
public static void setUpWorkbench() throws Exception {
    SWTWorkbenchBot 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
    }
    // Set C/C++ perspective.
    bot.perspectiveByLabel("C/C++").activate();
    bot.sleep(500);
    for (SWTBotShell sh : bot.shells()) {
        if (sh.getText().startsWith("C/C++")) {
            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);
    }
    projectExplorer = bot.viewByTitle("Project Explorer");
}
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)

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