01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 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.performance;
11:
12: import org.eclipse.core.resources.IFile;
13: import org.eclipse.test.performance.Dimension;
14: import org.eclipse.ui.IEditorPart;
15: import org.eclipse.ui.IWorkbenchPage;
16: import org.eclipse.ui.IWorkbenchWindow;
17: import org.eclipse.ui.ide.IDE;
18:
19: /**
20: * @since 3.1
21: */
22: public class OpenCloseEditorTest extends BasicPerformanceTest {
23:
24: private String extension;
25:
26: public OpenCloseEditorTest(String extension, int tagging) {
27: super ("testOpenAndCloseEditors:" + extension, tagging);
28: this .extension = extension;
29: }
30:
31: protected void runTest() throws Throwable {
32: final IFile file = getProject().getFile("1." + extension);
33: assertTrue(file.exists());
34:
35: IWorkbenchWindow window = openTestWindow(UIPerformanceTestSetup.PERSPECTIVE1);
36: final IWorkbenchPage activePage = window.getActivePage();
37:
38: exercise(new TestRunnable() {
39: public void run() throws Exception {
40: startMeasuring();
41: for (int j = 0; j < 10; j++) {
42: IEditorPart part = IDE.openEditor(activePage, file,
43: true);
44: processEvents();
45: activePage.closeEditor(part, false);
46: processEvents();
47:
48: }
49: stopMeasuring();
50: }
51: });
52:
53: tagIfNecessary("UI - Open/Close Editor",
54: Dimension.ELAPSED_PROCESS);
55: commitMeasurements();
56: assertPerformance();
57: }
58: }
|