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.ListViewer;
13: import org.eclipse.jface.viewers.StructuredViewer;
14: import org.eclipse.swt.widgets.Shell;
15: import org.eclipse.test.performance.Dimension;
16: import org.eclipse.ui.tests.performance.TestRunnable;
17:
18: /**
19: * The ListViewerRefreshTest is a test of refreshing the list viewer.
20: *
21: */
22: public class ListViewerRefreshTest extends ViewerTest {
23:
24: ListViewer viewer;
25:
26: private RefreshTestContentProvider contentProvider;
27:
28: public ListViewerRefreshTest(String testName, int tagging) {
29: super (testName, tagging);
30:
31: }
32:
33: public ListViewerRefreshTest(String testName) {
34: super (testName);
35:
36: }
37:
38: /*
39: * (non-Javadoc)
40: *
41: * @see org.eclipse.jface.tests.performance.ViewerTest#createViewer(org.eclipse.swt.widgets.Shell)
42: */
43: protected StructuredViewer createViewer(Shell shell) {
44: viewer = new ListViewer(shell);
45: contentProvider = new RefreshTestContentProvider(
46: RefreshTestContentProvider.ELEMENT_COUNT);
47: viewer.setContentProvider(contentProvider);
48: viewer.setLabelProvider(getLabelProvider());
49: return viewer;
50: }
51:
52: /**
53: * Test the time for doing a refresh.
54: *
55: * @throws Throwable
56: */
57: public void testRefresh() throws Throwable {
58:
59: tagIfNecessary("JFace - Refresh 100 item ListViewer 10 times",
60: Dimension.ELAPSED_PROCESS);
61: setDegradationComment("<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=99022>See Bug 99022</a> ");
62:
63: openBrowser();
64:
65: exercise(new TestRunnable() {
66: public void run() {
67: startMeasuring();
68: viewer.refresh();
69: processEvents();
70: stopMeasuring();
71: }
72: }, MIN_ITERATIONS, ITERATIONS, JFacePerformanceSuite.MAX_TIME);
73:
74: commitMeasurements();
75: assertPerformance();
76: }
77:
78: }
|