Search in sources :

Example 6 with IApplication

use of org.eclipse.equinox.app.IApplication in project reddeer by eclipse.

the class UITestApplication method start.

/**
 * Starts UI Test application from context.
 *
 * @param context
 *            context to start
 */
public Object start(IApplicationContext context) throws Exception {
    String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    Object app = getApplication(args);
    Assert.isNotNull(app, "The application " + getApplicationToRun(args) + " could not be found.");
    Object testableObject = Activator.getDefault().getTestableObject();
    if (testableObject != null) {
        fTestableObject = (TestableObject) testableObject;
    } else {
        try {
            fTestableObject = PlatformUI.getTestableObject();
        } catch (NoClassDefFoundError e) {
        // null check follows
        }
    }
    if (fTestableObject == null) {
        throw new RedDeerException("Could not find testable object");
    }
    fTestableObject.setTestHarness(this);
    if (app instanceof IApplication) {
        fApplication = (IApplication) app;
        return fApplication.start(context);
    }
    throw new IllegalArgumentException("Could not execute application " + getApplicationToRun(args));
}
Also used : RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) IApplication(org.eclipse.equinox.app.IApplication) TestableObject(org.eclipse.ui.testing.TestableObject)

Example 7 with IApplication

use of org.eclipse.equinox.app.IApplication in project equinox.bundles by eclipse-equinox.

the class EclipseAppHandle method destroySpecific.

@Override
protected void destroySpecific() {
    // when this method is called we must force the application to exit.
    // first set the status to stopping
    setAppStatus(EclipseAppHandle.FLAG_STOPPING);
    // now force the application to stop
    IApplication app = getApplication();
    if (app != null)
        app.stop();
    // make sure the app status is stopped
    setAppStatus(EclipseAppHandle.FLAG_STOPPED);
}
Also used : IApplication(org.eclipse.equinox.app.IApplication)

Example 8 with IApplication

use of org.eclipse.equinox.app.IApplication in project equinox.framework by eclipse-equinox.

the class ExitValueApp method run.

@Override
public synchronized void run() {
    if (active) {
        try {
            // only run for 5 seconds at most
            wait(5000);
        } catch (InterruptedException e) {
        // do nothing
        }
    }
    stopped = true;
    if (useAsync) {
        IApplication app = this;
        Object result = returnNull ? null : exitValue;
        if (setWrongApp) {
            result = "failed";
            app = new IApplication() {

                public void stop() {
                // nothing
                }

                public Object start(IApplicationContext context) throws Exception {
                    return null;
                }
            };
        }
        try {
            appContext.setResult(result, app);
        // failed
        } catch (IllegalArgumentException e) {
            // passed
            appContext.setResult(returnNull ? null : exitValue, this);
        }
    }
    notifyAll();
}
Also used : IApplication(org.eclipse.equinox.app.IApplication) IApplicationContext(org.eclipse.equinox.app.IApplicationContext)

Example 9 with IApplication

use of org.eclipse.equinox.app.IApplication in project eclipse.platform.ui by eclipse-platform.

the class Workbench method getApplication.

static Object getApplication(String[] args) {
    // Find the name of the application as specified by the PDE JUnit
    // launcher.
    // If no application is specified, the 3.0 default workbench application
    // is returned.
    IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, // $NON-NLS-1$
    "org.eclipse.e4.ui.workbench.swt.E4Application");
    Assert.isNotNull(extension);
    // Otherwise, return the application object.
    try {
        IConfigurationElement[] elements = extension.getConfigurationElements();
        if (elements.length > 0) {
            // $NON-NLS-1$
            IConfigurationElement[] runs = elements[0].getChildren("run");
            if (runs.length > 0) {
                Object runnable;
                // $NON-NLS-1$
                runnable = runs[0].createExecutableExtension("class");
                if (runnable instanceof IApplication)
                    return runnable;
            }
        }
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
Also used : IApplication(org.eclipse.equinox.app.IApplication) CoreException(org.eclipse.core.runtime.CoreException) IExtension(org.eclipse.core.runtime.IExtension) EObject(org.eclipse.emf.ecore.EObject) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 10 with IApplication

use of org.eclipse.equinox.app.IApplication in project eclipse.pde by eclipse-pde.

the class NonUIThreadTestApplication method start.

@Override
public Object start(IApplicationContext context) throws Exception {
    String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    String appId = getApplicationToRun(args);
    IApplication app = getApplication(appId);
    Assert.assertNotNull(app);
    if (!DEFAULT_HEADLESSAPP.equals(appId)) {
        // this means we are running a different application, which potentially can be UI application;
        // non-ui thread test app can also mean we are running UI tests but outside the UI thread;
        // this is a pattern used by SWT bot and worked before; we continue to support this
        // (see bug 340906 for details)
        installPlatformUITestHarness();
    }
    return runApp(app, context);
}
Also used : IApplication(org.eclipse.equinox.app.IApplication)

Aggregations

IApplication (org.eclipse.equinox.app.IApplication)10 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 IExtension (org.eclipse.core.runtime.IExtension)3 IApplicationContext (org.eclipse.equinox.app.IApplicationContext)3 TestableObject (org.eclipse.ui.testing.TestableObject)3 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPlatformRunnable (org.eclipse.core.runtime.IPlatformRunnable)1 EObject (org.eclipse.emf.ecore.EObject)1 RedDeerException (org.eclipse.reddeer.common.exception.RedDeerException)1 ApplicationException (org.osgi.service.application.ApplicationException)1