diff options
author | Jean Michel-Lemieux | 2003-11-06 19:20:55 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2003-11-06 19:20:55 +0000 |
commit | d4d024394790595efca7082852b64db662950e20 (patch) | |
tree | 07ec20b0185d3e07f7668409f11abb0c9dddd49d /tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team | |
parent | 358bcdaa25349caaff72757a2baad0a8ae770207 (diff) | |
download | eclipse.platform.team-d4d024394790595efca7082852b64db662950e20.tar.gz eclipse.platform.team-d4d024394790595efca7082852b64db662950e20.tar.xz eclipse.platform.team-d4d024394790595efca7082852b64db662950e20.zip |
Absorbing the RCP UI work.
Diffstat (limited to 'tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team')
2 files changed, 8 insertions, 221 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/EclipseUITestHarnessApplication.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/EclipseUITestHarnessApplication.java deleted file mode 100644 index f944872e4..000000000 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/EclipseUITestHarnessApplication.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.tests.ccvs.ui.old; - - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.PrintStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import junit.framework.Test; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.tests.harness.EclipseTestHarnessApplication; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.internal.Workbench; - -/** - * A test harness with UI and logging support. - * <pre> - * Supported arguments: - * -test <suite> : id of suite to run (must be plugged into extension point) - * -log <file> : specify a file for logging - * -nolog : do not write a log file - * -repeat <n> : number of iterations to run - * -ignorefirst : ignore (do not record) results from first iteration - * -purge : purge all projects from the workspace before each iteration - * <anything else> : passed verbatim to the org.eclipse.ui.workbench application - * </pre> - */ -public class EclipseUITestHarnessApplication extends EclipseTestHarnessApplication { - protected boolean purgeWorkspace; - protected boolean ignoreFirst; - protected int repeatCount; - protected LoggingTestResult logResult; - - /** - * Application entry point. - */ - public Object run(Object userArgs) throws Exception { - PrintStream logStream = System.err; - String logFilename = null; - purgeWorkspace = false; - ignoreFirst = false; - repeatCount = 1; - if (userArgs instanceof String[]) { - // parse args, no error handling - String[] args = (String[]) userArgs; - List argsList = new ArrayList(args.length); - for (int i = 0; i < args.length; ++i) { - if ("-repeat".equals(args[i])) { - repeatCount = Integer.parseInt(args[++i]); - } else if ("-ignorefirst".equals(args[i])) { - ignoreFirst = true; - } else if ("-nolog".equals(args[i])) { - logStream = null; - } else if ("-log".equals(args[i])) { - logFilename = args[++i]; - } else if ("-purge".equals(args[i])) { - purgeWorkspace = true; - } else { - argsList.add(args[i]); - } - } - userArgs = argsList.toArray(new String[argsList.size()]); - } - // setup logging - if (logFilename != null) { - File file = new File(logFilename); - logStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(logFilename))); - } - logResult = new LoggingTestResult(logStream); - try { - logResult.startLog(System.currentTimeMillis(), getSDKBuildId()); - return launchWorkbench(userArgs); - } finally { - logResult.endLog(); - if (logFilename != null) logStream.close(); - } - } - - /** - * Launches the Workbench UI. - */ - protected Object launchWorkbench(final Object userArgs) throws Exception { - final Exception[] exception = new Exception[1]; - Workbench workbench = new Workbench() { - /*** this code should be kept in sync with Workbench.runEventLoop() ***/ - protected void runEventLoop(Window.IExceptionHandler handler) { - // Dispatch all events. - Display display = Display.getCurrent(); - while (true) { - try { - if (!display.readAndDispatch()) - break; - } catch (Throwable e) { - break; - } - } - - // Run our hook. - try { - workbenchHook(this); - } catch (Exception e) { - exception[0] = e; - } - - // Close the workbench. - close(); - } - }; - Object result = workbench.run(userArgs); - if (exception[0] != null) throw exception[0]; - return result; - } - - /** - * Callback from Workbench if it launched successfully. - */ - protected Object workbenchHook(Workbench workbench) throws Exception { - // run the underlying non-ui test launcher to locate and start the test cases - return super.run(workbench.getCommandLineArgs()); - } - - /** - * Runs the specified test. Called from the non-ui test launcher. - */ - protected void run(Test test) { - for (int i = 0; i < repeatCount; ++i) { - if (purgeWorkspace) purgeWorkspaceProjects(); - LoggingTestRunner runner = new LoggingTestRunner(); - runner.doRun(test, (i == 0 && ignoreFirst) ? null : logResult, false); - } - } - - /** - * Purges the projects in the workspace. - */ - public static void purgeWorkspaceProjects() { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - // purge all known projects from the workspace - IProject[] projects = workspace.getRoot().getProjects(); - for (int i = 0; i < projects.length; ++i) { - IProject project = projects[i]; - try { - project.delete(true, true, null); - } catch (CoreException e) { - System.err.println("Could not purge project: " + project.getName()); - } - } - } - - /** - * Gets the SDK build id. - */ - public static String getSDKBuildId() { - try { - URL url = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.sdk").getInstallURL(); - url = new URL(url, "platform.ini"); - InputStream is = url.openStream(); - try { - Properties sdkProperties = new Properties(); - sdkProperties.load(is); - String buildId = sdkProperties.getProperty("buildID"); - if (buildId != null) return buildId; - } finally { - is.close(); - } - } catch (Exception e) { - } - return "unknown"; - } -} diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/Utils.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/Utils.java index fdccc453a..4ef55baba 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/Utils.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/old/Utils.java @@ -11,48 +11,26 @@ package org.eclipse.team.tests.ccvs.ui.old; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; +import java.util.*; import java.util.List; import java.util.zip.ZipException; import java.util.zip.ZipFile; import junit.framework.Assert; -import org.eclipse.compare.structuremergeviewer.DiffNode; -import org.eclipse.compare.structuremergeviewer.IDiffContainer; -import org.eclipse.compare.structuremergeviewer.IDiffElement; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; + +import org.eclipse.compare.structuremergeviewer.*; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; +import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ccvs.core.CVSStatus; -import org.eclipse.ui.internal.dialogs.InternalErrorDialog; +import org.eclipse.ui.internal.ide.dialogs.InternalErrorDialog; import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; |