### Eclipse Workspace Patch 1.0 #P org.eclipse.team.tests.cvs.core Index: src/org/eclipse/team/tests/ccvs/ui/CommitDialogTest.java =================================================================== RCS file: src/org/eclipse/team/tests/ccvs/ui/CommitDialogTest.java diff -N src/org/eclipse/team/tests/ccvs/ui/CommitDialogTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/team/tests/ccvs/ui/CommitDialogTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ +package org.eclipse.team.tests.ccvs.ui; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Test; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.ui.wizards.CommitWizard; +import org.eclipse.team.internal.ccvs.ui.wizards.ResizableWizard; +import org.eclipse.team.tests.ccvs.core.EclipseTest; +import org.eclipse.test.performance.Performance; +import org.eclipse.test.performance.PerformanceMeter; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class CommitDialogTest extends EclipseTest { + + public CommitDialogTest() { + super(); + } + + public CommitDialogTest(String name) { + super(name); + } + + public static Test suite() { + return suite(CommitDialogTest.class); + } + + public void testCommitDialog() throws TeamException, CoreException { + + Performance perf = Performance.getDefault(); + PerformanceMeter performanceMeter = perf.createPerformanceMeter(perf + .getDefaultScenarioId(this)); + try { + List projects = new ArrayList(2); + for (int i = 0; i < 2; i++) { + IProject project = createProject("bug321632", new String[] { + "file.txt", "changed.txt", "folder1/removed.txt", + "folder1/changed.txt" }); + setContentsAndEnsureModified(project.getFile("changed.txt")); + setContentsAndEnsureModified(project + .getFile("folder1/changed.txt")); + addResources(project, new String[] { "added.txt", "folder2/", + "folder2/added.txt" }, false); + deleteResources(new IResource[] { project + .getFile("folder1/removed.txt") }); + + projects.add(project); + } + + for (int i = 0; i < 10; i++) { + performanceMeter.start(); + NonBlockingCommitWizard.run(getActivePart(), getShell(), + (IResource[]) projects.toArray(new IResource[0])); + performanceMeter.stop(); + Display.getCurrent().getActiveShell().close(); + } + + performanceMeter.commit(); + perf.assertPerformance(performanceMeter); + } finally { + performanceMeter.dispose(); + } + } + + static class NonBlockingCommitWizard extends CommitWizard { + + public NonBlockingCommitWizard(IResource[] resources) + throws CVSException { + super(resources); + } + + protected static int open(Shell shell, ResizableWizard wizard) { + final WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.setPageSize(wizard.loadSize()); + dialog.setBlockOnOpen(false); + return dialog.open(); + } + } + + private Shell getShell() { + return getActivePart().getSite().getShell(); + } + + private IWorkbenchPart getActivePart() { + IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + if (window == null) { + return null; + } + IWorkbenchPage page = window.getActivePage(); + if (page == null) { + return null; + } + return page.getActivePart(); + } +}