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 OpenMultipleEditorTest extends BasicPerformanceTest {
23:
24: private String extension;
25: private boolean closeAll;
26:
27: /**
28: * @param testName
29: */
30: public OpenMultipleEditorTest(String extension, boolean closeAll,
31: int tagging) {
32: super ("testOpenMultipleEditors:" + extension
33: + (closeAll ? "[closeAll]" : "[closeEach]"), tagging);
34: this .extension = extension;
35: this .closeAll = closeAll;
36: setDegradationComment("<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=179578>See Bug 179578</a>");
37: }
38:
39: protected void runTest() throws Throwable {
40: IWorkbenchWindow window = openTestWindow(UIPerformanceTestSetup.PERSPECTIVE1);
41: IWorkbenchPage activePage = window.getActivePage();
42:
43: tagIfNecessary("UI - Open Multiple Editors",
44: Dimension.ELAPSED_PROCESS);
45:
46: startMeasuring();
47:
48: for (int i = 0; i < 100; i++) {
49: IFile file = getProject().getFile(i + "." + extension);
50: IDE.openEditor(activePage, file, true);
51: processEvents();
52: }
53: if (closeAll) {
54: activePage.closeAllEditors(false);
55: } else {
56: IEditorPart[] parts = activePage.getEditors();
57: for (int i = 0; i < parts.length; i++) {
58: activePage.closeEditor(parts[i], false);
59: }
60: }
61: stopMeasuring();
62: commitMeasurements();
63: assertPerformance();
64: }
65:
66: }
|