01: /*******************************************************************************
02: * Copyright (c) 2004, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.tests.rcp.performance;
11:
12: import org.eclipse.swt.widgets.Display;
13: import org.eclipse.test.performance.PerformanceTestCase;
14: import org.eclipse.ui.PlatformUI;
15: import org.eclipse.ui.tests.rcp.util.WorkbenchAdvisorObserver;
16:
17: /**
18: * @since 3.1
19: */
20: public class PlatformUIPerfTest extends PerformanceTestCase {
21:
22: public void testCreateAndDisposeDisplayX100() {
23: for (int i = 0; i < 10; ++i) {
24: startMeasuring();
25: for (int j = 0; j < 100; ++j) {
26: Display display = PlatformUI.createDisplay();
27: display.dispose();
28: assertTrue(display.isDisposed());
29: }
30: stopMeasuring();
31: }
32:
33: commitMeasurements();
34: assertPerformance();
35: }
36:
37: public void testRunAndShutdownWorkbench() {
38: Display display = PlatformUI.createDisplay();
39:
40: for (int i = 0; i < 10; ++i) {
41: startMeasuring();
42: int code = PlatformUI.createAndRunWorkbench(display,
43: new WorkbenchAdvisorObserver(2));
44: stopMeasuring();
45:
46: assertEquals(PlatformUI.RETURN_OK, code);
47: }
48:
49: display.dispose();
50: assertTrue(display.isDisposed());
51:
52: commitMeasurements();
53: assertPerformance();
54: }
55: }
|