01: /*******************************************************************************
02: * Copyright (c) 2000, 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.core.runtime.CoreException;
14: import org.eclipse.ui.IWorkbenchPage;
15: import org.eclipse.ui.IWorkbenchWindow;
16: import org.eclipse.ui.ide.IDE;
17:
18: /**
19: * Test editor switching.
20: */
21: public class EditorSwitchTest extends BasicPerformanceTest {
22:
23: private String extension1;
24:
25: private String extension2;
26:
27: /**
28: * Constructor.
29: *
30: * @param testName
31: * Test's name.
32: */
33: public EditorSwitchTest(String[] pair) {
34: super ("testEditorSwitch:" + pair[0] + "," + pair[1]);
35: extension1 = pair[0];
36: extension2 = pair[1];
37: }
38:
39: /**
40: * Test editor opening performance. This test always fails.
41: */
42: protected void runTest() throws CoreException {
43:
44: // Open both files outside the loop so as not to include
45: // the initial time to open, just switching.
46: IWorkbenchWindow window = openTestWindow(UIPerformanceTestSetup.PERSPECTIVE1);
47: final IWorkbenchPage activePage = window.getActivePage();
48: final IFile file1 = getProject().getFile("1." + extension1);
49: assertTrue(file1.exists());
50: final IFile file2 = getProject().getFile("1." + extension2);
51: assertTrue(file2.exists());
52: IDE.openEditor(activePage, file1, true);
53: IDE.openEditor(activePage, file2, true);
54: processEvents();
55: EditorTestHelper.calmDown(500, 30000, 500);
56: waitForBackgroundJobs();
57:
58: for (int j = 0; j < 100; j++) {
59:
60: startMeasuring();
61: for (int i = 0; i < 12; i++) {
62: IDE.openEditor(activePage, file1, true);
63: processEvents();
64: IDE.openEditor(activePage, file2, true);
65: processEvents();
66: }
67: stopMeasuring();
68: EditorTestHelper.calmDown(500, 30000, 100);
69: }
70:
71: commitMeasurements();
72: assertPerformance();
73: }
74: }
|