001: /*******************************************************************************
002: * Copyright (c) 2005, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jface.tests.performance;
011:
012: import org.eclipse.jface.viewers.ComboViewer;
013: import org.eclipse.jface.viewers.StructuredViewer;
014: import org.eclipse.swt.widgets.Shell;
015: import org.eclipse.ui.tests.performance.TestRunnable;
016:
017: /**
018: * ComboViewerRefreshTest is a test of refreshes of difference size in the combo
019: * viewer.
020: */
021: public class ComboViewerRefreshTest extends ViewerTest {
022:
023: ComboViewer viewer;
024:
025: private RefreshTestContentProvider contentProvider;
026:
027: private static int ELEMENT_COUNT;
028:
029: public ComboViewerRefreshTest(String testName, int tagging) {
030: super (testName, tagging);
031:
032: }
033:
034: public ComboViewerRefreshTest(String testName) {
035: super (testName);
036:
037: }
038:
039: protected StructuredViewer createViewer(Shell shell) {
040:
041: viewer = new ComboViewer(shell);
042: contentProvider = new RefreshTestContentProvider(ELEMENT_COUNT);
043: viewer.setContentProvider(contentProvider);
044: viewer.setLabelProvider(getLabelProvider());
045: return viewer;
046: }
047:
048: /**
049: * Test the time for doing a refresh.
050: *
051: * @throws Throwable
052: */
053: public void testRefresh() throws Throwable {
054:
055: setDegradationComment("<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=98265>See Bug 98265</a> ");
056: ELEMENT_COUNT = 1000;
057: openBrowser();
058:
059: exercise(new TestRunnable() {
060: public void run() {
061: startMeasuring();
062: viewer.refresh();
063: processEvents();
064: stopMeasuring();
065: }
066: }, MIN_ITERATIONS, ITERATIONS, JFacePerformanceSuite.MAX_TIME);
067:
068: commitMeasurements();
069: assertPerformance();
070: }
071:
072: /**
073: * Test the time for doing a refresh.
074: *
075: * @throws Throwable
076: */
077: public void testRefreshSmall() throws Throwable {
078:
079: setDegradationComment("<a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=98265>See Bug 98265</a> ");
080:
081: ELEMENT_COUNT = 50;
082: openBrowser();
083:
084: exercise(new TestRunnable() {
085: public void run() {
086: startMeasuring();
087: for (int i = 0; i < 1000; i++) {
088: viewer.refresh();
089: }
090: processEvents();
091: stopMeasuring();
092: }
093: }, MIN_ITERATIONS, slowGTKIterations(),
094: JFacePerformanceSuite.MAX_TIME);
095:
096: commitMeasurements();
097: assertPerformance();
098: }
099:
100: }
|