Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 166972 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java (-10 / +25 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.IPlatformRunnable;
18
import org.eclipse.core.runtime.IPlatformRunnable;
19
import org.eclipse.core.runtime.IProduct;
19
import org.eclipse.core.runtime.IProduct;
20
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.equinox.app.IApplication;
22
import org.eclipse.equinox.app.IApplicationContext;
21
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.testing.ITestHarness;
24
import org.eclipse.ui.testing.ITestHarness;
23
import org.eclipse.ui.testing.TestableObject;
25
import org.eclipse.ui.testing.TestableObject;
Lines 26-56 Link Here
26
 * A Workbench that runs a test suite specified in the
28
 * A Workbench that runs a test suite specified in the
27
 * command line arguments.
29
 * command line arguments.
28
 */ 
30
 */ 
29
public class UITestApplication implements IPlatformRunnable, ITestHarness {
31
public class UITestApplication implements IApplication, ITestHarness {
30
	
32
	
31
	private static final String DEFAULT_APP_3_0 = "org.eclipse.ui.ide.workbench"; //$NON-NLS-1$
33
	private static final String DEFAULT_APP_3_0 = "org.eclipse.ui.ide.workbench"; //$NON-NLS-1$
32
	
34
	
33
	private TestableObject fTestableObject;
35
	private TestableObject fTestableObject;
36
	private IApplication application;
34
	
37
	
35
	/* (non-Javadoc)
38
	/* (non-Javadoc)
36
	 * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
39
	 * @see org.eclipse.equinox.app.IApplication#start(java.lang.Object)
37
	 */
40
	 */
38
	public Object run(final Object args) throws Exception {
41
	public Object start(IApplicationContext context) throws Exception {
39
		IPlatformRunnable application = getApplication((String[]) args);
42
		String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
43
		Object app = getApplication(args);
40
44
41
		Assert.assertNotNull(application);
45
		Assert.assertNotNull(app);
42
46
43
		fTestableObject = PlatformUI.getTestableObject();
47
		fTestableObject = PlatformUI.getTestableObject();
44
		fTestableObject.setTestHarness(this);
48
		fTestableObject.setTestHarness(this);
45
		return application.run(args);
49
		if (app instanceof IApplication) {
50
			application = (IApplication) app;
51
			return application.start(context);
52
		}
53
		return ((IPlatformRunnable) app).run(args);
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.equinox.app.IApplication#stop()
58
	 */
59
	public void stop() {
60
		if (application != null)
61
			application.stop();
46
	}
62
	}
47
	
48
63
49
	/*
64
	/*
50
	 * return the application to run, or null if not even the default application
65
	 * return the application to run, or null if not even the default application
51
	 * is found.
66
	 * is found.
52
	 */
67
	 */
53
	private IPlatformRunnable getApplication(String[] args) throws CoreException {
68
	private Object getApplication(String[] args) throws CoreException {
54
		// Find the name of the application as specified by the PDE JUnit launcher.
69
		// Find the name of the application as specified by the PDE JUnit launcher.
55
		// If no application is specified, the 3.0 default workbench application
70
		// If no application is specified, the 3.0 default workbench application
56
		// is returned.
71
		// is returned.
Lines 70-77 Link Here
70
			IConfigurationElement[] runs = elements[0].getChildren("run"); //$NON-NLS-1$
85
			IConfigurationElement[] runs = elements[0].getChildren("run"); //$NON-NLS-1$
71
			if (runs.length > 0) {
86
			if (runs.length > 0) {
72
				Object runnable = runs[0].createExecutableExtension("class"); //$NON-NLS-1$
87
				Object runnable = runs[0].createExecutableExtension("class"); //$NON-NLS-1$
73
				if (runnable instanceof IPlatformRunnable)
88
				if (runnable instanceof IPlatformRunnable || runnable instanceof IApplication)
74
					return (IPlatformRunnable) runnable;
89
					return runnable;
75
			}
90
			}
76
		}
91
		}
77
		return null;
92
		return null;

Return to bug 166972