01: /*******************************************************************************
02: * Copyright (c) 2005, 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.jface.tests.performance;
11:
12: import org.eclipse.jface.viewers.StructuredViewer;
13: import org.eclipse.jface.viewers.TreeViewer;
14: import org.eclipse.swt.widgets.Shell;
15:
16: /**
17: * The TreeViewerRefreshTest is the refresh test for
18: * tree viewers.
19: *
20: */
21: public class TreeViewerRefreshTest extends ViewerTest {
22:
23: TreeViewer viewer;
24: private RefreshTestTreeContentProvider contentProvider;
25:
26: public TreeViewerRefreshTest(String testName, int tagging) {
27: super (testName, tagging);
28: }
29:
30: public TreeViewerRefreshTest(String testName) {
31: super (testName);
32: }
33:
34: /* (non-Javadoc)
35: * @see org.eclipse.jface.tests.performance.ViewerTest#createViewer(org.eclipse.swt.widgets.Shell)
36: */
37: protected StructuredViewer createViewer(Shell shell) {
38: viewer = new TreeViewer(shell);
39: contentProvider = new RefreshTestTreeContentProvider();
40: viewer.setContentProvider(contentProvider);
41: viewer.setLabelProvider(getLabelProvider());
42: return viewer;
43: }
44:
45: /**
46: * Test the time for doing a refresh.
47: * @throws Throwable
48: */
49: public void testRefresh() throws Throwable {
50: openBrowser();
51:
52: for (int i = 0; i < ITERATIONS; i++) {
53: startMeasuring();
54: viewer.refresh();
55: processEvents();
56: stopMeasuring();
57: }
58:
59: commitMeasurements();
60: assertPerformance();
61: }
62:
63: }
|