01: /*******************************************************************************
02: * Copyright (c) 2004, 2007 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.test.performance.Dimension;
13: import org.eclipse.ui.IViewPart;
14: import org.eclipse.ui.IWorkbenchPage;
15: import org.eclipse.ui.IWorkbenchWindow;
16:
17: /**
18: * Performance tests for showing views.
19: * There are separate tests for showing a simple view (MockViewPart)
20: * and a more complex view (Resource Navigator).
21: * The views are shown in an empty perspective.
22: */
23: public class OpenCloseViewTest extends BasicPerformanceTest {
24:
25: private String viewId;
26:
27: public OpenCloseViewTest(String viewId, int tagging) {
28: super ("showView:" + viewId, tagging);
29: this .viewId = viewId;
30: }
31:
32: protected void runTest() throws Throwable {
33: IWorkbenchWindow window = openTestWindow();
34: final IWorkbenchPage page = window.getActivePage();
35:
36: // prime it
37: IViewPart view1 = page.showView(viewId);
38: page.hideView(view1);
39: waitForBackgroundJobs();
40: processEvents();
41:
42: tagIfNecessary("UI - Open/Close " + view1.getTitle(),
43: Dimension.ELAPSED_PROCESS);
44:
45: for (int j = 0; j < 100; j++) {
46:
47: startMeasuring();
48: for (int i = 0; i < 5; i++) {
49: IViewPart view = page.showView(viewId);
50: processEvents();
51:
52: page.hideView(view);
53: processEvents();
54: }
55: stopMeasuring();
56: }
57:
58: commitMeasurements();
59: assertPerformance();
60: }
61: }
|