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));
}
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);
}
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();
}
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;
}
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);
}
Aggregations