diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java index 6667facebf3..8a72a7d864b 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Andrew Gvozdev and others. + * Copyright (c) 2009, 2010 Andrew Gvozdev and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -64,7 +64,8 @@ import org.eclipse.core.runtime.jobs.Job; public class ResourceHelper { private final static IProgressMonitor NULL_MONITOR = new NullProgressMonitor(); - + private static final int MAX_RETRY= 5; + private final static Set externalFilesCreated = new HashSet(); private final static Set resourcesCreated = new HashSet(); @@ -186,6 +187,74 @@ public class ResourceHelper { return project; } + /** + * Create a plain Eclipse project. + * + * @param projectName + * @return the project handle + * @throws CoreException if project could not be created + */ + public static IProject createProject(String projectName) throws CoreException { + IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); + IProject project= root.getProject(projectName); + if (!project.exists()) + project.create(NULL_MONITOR); + else + project.refreshLocal(IResource.DEPTH_INFINITE, null); + + if (!project.isOpen()) + project.open(NULL_MONITOR); + + return project; + } + + /** + * Delete project by name. + * + * @param projectName + * @throws CoreException + */ + public static void deleteProject(String projectName) throws CoreException { + IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); + IProject project= root.getProject(projectName); + if (project.exists()) + delete(project); + } + + /** + * Delete given project with content. + * + * @param project + * @throws CoreException + */ + public static void delete(final IProject project) throws CoreException { + delete(project, true); + } + + /** + * Delete project. + * + * @param project + * @param deleteContent whether to delete project content + * @throws CoreException + */ + public static void delete(final IProject project, boolean deleteContent) throws CoreException { + for (int i= 0; i < MAX_RETRY; i++) { + try { + project.delete(deleteContent, true, NULL_MONITOR); + i= MAX_RETRY; + } catch (CoreException x) { + if (i == MAX_RETRY - 1) { + CTestPlugin.getDefault().getLog().log(x.getStatus()); + } + try { + Thread.sleep(1000); // sleep a second + } catch (InterruptedException e) { + } + } + } + } + /** * Creates a file with specified content. * diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/Accessor.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java similarity index 95% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/Accessor.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java index c010e3b336d..38a53fb77b5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/Accessor.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/Accessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; +package org.eclipse.cdt.ui.testplugin; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -29,7 +29,7 @@ import junit.framework.Assert; public class Accessor extends Assert { /** The class to access. */ - private Class fClass; + private Class fClass; /** The instance to access. */ private Object fInstance; @@ -41,7 +41,7 @@ public class Accessor extends Assert { * @param instance the instance * @param clazz the class */ - public Accessor(Object instance, Class clazz) { + public Accessor(Object instance, Class clazz) { assertNotNull(instance); assertNotNull(clazz); fInstance= instance; @@ -95,7 +95,7 @@ public class Accessor extends Assert { * @param constructorTypes the types of the constructor arguments * @param constructorArgs the constructor arguments */ - public Accessor(String className, ClassLoader classLoader, Class[] constructorTypes, Object[] constructorArgs) { + public Accessor(String className, ClassLoader classLoader, Class[] constructorTypes, Object[] constructorArgs) { try { fClass= Class.forName(className, true, classLoader); } catch (ClassNotFoundException e) { @@ -103,7 +103,7 @@ public class Accessor extends Assert { } catch (ExceptionInInitializerError e) { fail(); } - Constructor constructor= null; + Constructor constructor= null; try { constructor= fClass.getDeclaredConstructor(constructorTypes); } catch (SecurityException e2) { @@ -169,7 +169,7 @@ public class Accessor extends Assert { * @param arguments the method arguments * @return the method return value */ - public Object invoke(String methodName, Class[] types, Object[] arguments) { + public Object invoke(String methodName, Class[] types, Object[] arguments) { Method method= null; try { method= fClass.getDeclaredMethod(methodName, types); @@ -313,12 +313,12 @@ public class Accessor extends Assert { return field; } - private static Class[] getTypes(Object[] objects) { + private static Class[] getTypes(Object[] objects) { if (objects == null) return null; int length= objects.length; - Class[] classes= new Class[length]; + Class[] classes= new Class[length]; for (int i= 0; i < length; i++) { assertNotNull(objects[i]); classes[i]= objects[i].getClass(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DisplayHelper.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java similarity index 99% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DisplayHelper.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java index b22080fce72..8404d2faf11 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DisplayHelper.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/DisplayHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; +package org.eclipse.cdt.ui.testplugin; import java.util.logging.Level; import java.util.logging.Logger; @@ -102,6 +102,7 @@ public abstract class DisplayHelper { */ public static void sleep(Display display, long millis) { new DisplayHelper() { + @Override public boolean condition() { return false; } @@ -426,6 +427,7 @@ final class DisplayWaiter { /* * @see java.lang.Runnable#run() */ + @Override public void run() { try { run2(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/EditorTestHelper.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/EditorTestHelper.java similarity index 95% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/EditorTestHelper.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/EditorTestHelper.java index f218fe25e81..5659d6210b1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/EditorTestHelper.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/EditorTestHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) - Adapted for CDT *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; +package org.eclipse.cdt.ui.testplugin; import java.io.ByteArrayInputStream; @@ -75,9 +75,9 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; -import org.eclipse.cdt.ui.testplugin.CTestPlugin; import org.eclipse.cdt.internal.ui.text.CReconcilingStrategy; import org.eclipse.cdt.internal.ui.text.CompositeReconcilingStrategy; @@ -280,6 +280,7 @@ public class EditorTestHelper { runEventQueue(minTime); DisplayHelper helper= new DisplayHelper() { + @Override public boolean condition() { return allJobsQuiet(); } @@ -361,6 +362,7 @@ public class EditorTestHelper { } final Accessor cReconcilerAccessor= reconcilerAccessor; DisplayHelper helper= new DisplayHelper() { + @Override public boolean condition() { return !isRunning(cReconcilerAccessor, backgroundThreadAccessor); } @@ -443,9 +445,10 @@ public class EditorTestHelper { public static ICProject createCProject(String project, String externalSourceFolder, boolean linkSourceFolder, boolean useIndexer) throws CoreException { ICProject cProject= CProjectHelper.createCCProject(project, "bin", useIndexer ? IIndexManager.ID_FAST_INDEXER : IIndexManager.ID_NO_INDEXER); IFolder folder; - if (linkSourceFolder) - folder= ResourceHelper.createLinkedFolder((IProject) cProject.getUnderlyingResource(), new Path("src"), CTestPlugin.getDefault(), new Path(externalSourceFolder)); - else { + if (linkSourceFolder) { + File file= FileTool.getFileInPlugin(CTestPlugin.getDefault(), new Path(externalSourceFolder)); + folder= ResourceHelper.createLinkedFolder((IProject) cProject.getUnderlyingResource(), "src", file.getAbsolutePath()); + } else { folder= ((IProject) cProject.getUnderlyingResource()).getFolder("src"); importFilesFromDirectory(FileTool.getFileInPlugin(CTestPlugin.getDefault(), new Path(externalSourceFolder)), folder.getFullPath(), null); } @@ -481,9 +484,10 @@ public class EditorTestHelper { final IProject project= newProject[0]; Assert.assertNotNull(project); final IFolder folder; - if (linkSourceFolder) - folder= ResourceHelper.createLinkedFolder(project, new Path("src"), CTestPlugin.getDefault(), new Path(externalSourceFolder)); - else { + if (linkSourceFolder) { + File file= FileTool.getFileInPlugin(CTestPlugin.getDefault(), new Path(externalSourceFolder)); + folder= ResourceHelper.createLinkedFolder(project, "src", file.getAbsolutePath()); + } else { folder= project.getFolder("src"); importFilesFromDirectory(FileTool.getFileInPlugin(CTestPlugin.getDefault(), new Path(externalSourceFolder)), folder.getFullPath(), null); } @@ -506,12 +510,12 @@ public class EditorTestHelper { } public static IFile[] findFiles(IResource resource) throws CoreException { - List files= new ArrayList(); + List files= new ArrayList(); findFiles(resource, files); - return (IFile[]) files.toArray(new IFile[files.size()]); + return files.toArray(new IFile[files.size()]); } - private static void findFiles(IResource resource, List files) throws CoreException { + private static void findFiles(IResource resource, List files) throws CoreException { if (resource instanceof IFile) { files.add(resource); return; @@ -534,7 +538,7 @@ public class EditorTestHelper { public static void importFilesFromDirectory(File rootDir, IPath destPath, IProgressMonitor monitor) throws CoreException { try { IImportStructureProvider structureProvider= FileSystemStructureProvider.INSTANCE; - List files= new ArrayList(100); + List files= new ArrayList(100); addFiles(rootDir, files); ImportOperation op= new ImportOperation(destPath, rootDir, structureProvider, new ImportOverwriteQuery(), files); op.setCreateContainerStructure(false); @@ -548,9 +552,9 @@ public class EditorTestHelper { return new CoreException(new Status(IStatus.ERROR, CTestPlugin.PLUGIN_ID, -1, "", x)); } - private static void addFiles(File dir, List collection) throws IOException { + private static void addFiles(File dir, List collection) throws IOException { File[] files= dir.listFiles(); - List subDirs= new ArrayList(2); + List subDirs= new ArrayList(2); for (int i= 0; i < files.length; i++) { if (files[i].isFile()) { collection.add(files[i]); @@ -558,9 +562,9 @@ public class EditorTestHelper { subDirs.add(files[i]); } } - Iterator iter= subDirs.iterator(); + Iterator iter= subDirs.iterator(); while (iter.hasNext()) { - File subDir= (File)iter.next(); + File subDir= iter.next(); addFiles(subDir, collection); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FileTool.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/FileTool.java similarity index 96% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FileTool.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/FileTool.java index 3c491e70d46..15c84dbe064 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FileTool.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/FileTool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; +package org.eclipse.cdt.ui.testplugin; import java.io.File; import java.io.FileInputStream; @@ -62,11 +62,11 @@ public class FileTool { private static void unzip(ZipFile zipFile, File rootDstDir, File dstDir, int depth) throws IOException { - Enumeration entries = zipFile.entries(); + Enumeration entries = zipFile.entries(); try { while(entries.hasMoreElements()){ - ZipEntry entry = (ZipEntry)entries.nextElement(); + ZipEntry entry = entries.nextElement(); if(entry.isDirectory()){ continue; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceTestHelper.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/ResourceTestHelper.java similarity index 98% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceTestHelper.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/ResourceTestHelper.java index 76f9b6a0910..719d2cb80c0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceTestHelper.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/testplugin/ResourceTestHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; +package org.eclipse.cdt.ui.testplugin; import java.io.File; import java.io.IOException; @@ -141,6 +141,7 @@ public class ResourceTestHelper { public static void write(String dest, final String content) throws IOException, CoreException { InputStream stream= new InputStream() { private Reader fReader= new StringReader(content); + @Override public int read() throws IOException { return fReader.read(); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java index f3cde15eb7f..e1e3ef13725 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -23,8 +23,8 @@ import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IBuildConsoleManager; +import org.eclipse.cdt.ui.testplugin.DisplayHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.DisplayHelper; /** * BuildConsoleTests. @@ -41,11 +41,13 @@ public class BuildConsoleTests extends BaseUITestCase { return new TestSuite(BuildConsoleTests.class); } + @Override protected void setUp() throws Exception { super.setUp(); fCProject= CProjectHelper.createCCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER); } + @Override protected void tearDown() throws Exception { CProjectHelper.delete(fCProject); fCProject= null; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java index 7ebf0e93798..9ae7e731e3d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,8 +28,8 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart; import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java index c9c2db95c52..88e75bdeb5d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,8 +29,8 @@ import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/quickfix/AssistQuickFixTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/quickfix/AssistQuickFixTest.java index 7523ac6939c..14647a0049a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/quickfix/AssistQuickFixTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/quickfix/AssistQuickFixTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,8 +40,8 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.ui.text.ICCompletionProposal; import org.eclipse.cdt.ui.text.IInvocationContext; import org.eclipse.cdt.ui.text.IProblemLocation; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java index 96760d52c80..c89cce94787 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractSemanticHighlightingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -43,6 +43,9 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.Accessor; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java index 334ea70b24c..71aaa4b12eb 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.core.model.ext.SourceRange; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java index e38450a27af..6235b28f14d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddIncludeTest.java @@ -28,6 +28,8 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java index 175a4f430ff..76a264530f3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -50,7 +50,13 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.Accessor; +import org.eclipse.cdt.ui.testplugin.DisplayHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.FileTool; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.IColorManager; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java index 3bf187f4844..1bba6821a4d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,6 +42,9 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.Accessor; +import org.eclipse.cdt.ui.testplugin.DisplayHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CStructureCreatorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CStructureCreatorTest.java index 84962278d53..6aadb84b72f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CStructureCreatorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CStructureCreatorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,8 @@ import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.compare.CStructureCreator; @@ -47,11 +49,13 @@ public class CStructureCreatorTest extends BaseUITestCase { private ICProject fCProject; + @Override protected void setUp() throws Exception { super.setUp(); fCProject= EditorTestHelper.createCProject("CStructureCreatorTest", "resources/compare", false); } + @Override protected void tearDown() throws Exception { if (fCProject != null) { CProjectHelper.delete(fCProject); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java index 876e3a5c4e1..1de7015d280 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FoldingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,6 +35,8 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FormatActionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FormatActionTest.java index 6c4b45e49d3..23e0304c4ff 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FormatActionTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/FormatActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,6 +26,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -36,6 +38,7 @@ public class FormatActionTest extends TestCase { private static final String PROJECT= "FormatTests"; private static final class EmptyBundle extends ListResourceBundle { + @Override protected Object[][] getContents() { return new Object[0][]; } @@ -49,6 +52,7 @@ public class FormatActionTest extends TestCase { super(test); } + @Override protected void setUp() throws Exception { super.setUp(); @@ -56,6 +60,7 @@ public class FormatActionTest extends TestCase { fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.TAB); } + @Override protected void tearDown () throws Exception { if (fCProject != null) CProjectHelper.delete(fCProject); @@ -64,7 +69,7 @@ public class FormatActionTest extends TestCase { } } - private static final Class THIS= FormatActionTest.class; + private static final Class THIS= FormatActionTest.class; public static Test suite() { return new FormatTestSetup(new TestSuite(THIS)); } @@ -76,6 +81,7 @@ public class FormatActionTest extends TestCase { /* * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { String filename= createFileName("Before"); fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(filename), true); @@ -86,6 +92,7 @@ public class FormatActionTest extends TestCase { /* * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { EditorTestHelper.closeEditor(fEditor); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java index 44726d8a695..2f81bdbabf6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/InactiveCodeHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/InactiveCodeHighlightingTest.java index f5d646d3468..5e2d5d865c7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/InactiveCodeHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/InactiveCodeHighlightingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,9 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.Accessor; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CSourceViewerDecorationSupport; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/IndentActionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/IndentActionTest.java index 15025ea3618..82a202307d5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/IndentActionTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/IndentActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,6 +25,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.internal.ui.actions.IndentAction; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -36,6 +38,7 @@ public class IndentActionTest extends TestCase { private static final String PROJECT= "IndentTests"; private static final class EmptyBundle extends ListResourceBundle { + @Override protected Object[][] getContents() { return new Object[0][]; } @@ -49,6 +52,7 @@ public class IndentActionTest extends TestCase { super(test); } + @Override protected void setUp() throws Exception { super.setUp(); @@ -56,6 +60,7 @@ public class IndentActionTest extends TestCase { fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.TAB); } + @Override protected void tearDown () throws Exception { if (fCProject != null) CProjectHelper.delete(fCProject); @@ -75,6 +80,7 @@ public class IndentActionTest extends TestCase { /* * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { String filename= createFileName("Before"); fEditor= (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(filename), true); @@ -85,6 +91,7 @@ public class IndentActionTest extends TestCase { /* * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { EditorTestHelper.closeEditor(fEditor); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java index 9df501d8f84..922db6353c4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,6 +49,8 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.DisplayHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -85,10 +87,12 @@ public class MarkOccurrenceTest extends BaseUITestCase { public MarkOccurrenceTestSetup(Test test) { super(test); } + @Override protected void setUp() throws Exception { super.setUp(); fCProject= EditorTestHelper.createCProject(PROJECT, "resources/ceditor", false, true); } + @Override protected void tearDown() throws Exception { if (fCProject != null) CProjectHelper.delete(fCProject); @@ -105,6 +109,7 @@ public class MarkOccurrenceTest extends BaseUITestCase { return setUpTest(new TestSuite(MarkOccurrenceTest.class)); } + @Override protected void setUp() throws Exception { if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) { fProjectSetup= new MarkOccurrenceTestSetup(this); @@ -146,6 +151,7 @@ public class MarkOccurrenceTest extends BaseUITestCase { /* * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fSelWASTListener); EditorTestHelper.closeAllEditors(); @@ -549,6 +555,7 @@ public class MarkOccurrenceTest extends BaseUITestCase { private void assertOccurrences(final int expected) { DisplayHelper helper= new DisplayHelper() { + @Override protected boolean condition() { return fOccurrences == expected; } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java index 059597b855a..7f25776ad1e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.ui.tests.text.AddBlockCommentTest.LinePosition; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceHelper.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceHelper.java deleted file mode 100644 index 017539b5e7c..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ResourceHelper.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text; - -import java.io.File; -import java.io.InputStream; - -import org.eclipse.core.filebuffers.manipulation.ContainerCreator; -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.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; - -import org.eclipse.cdt.ui.testplugin.CTestPlugin; - -/** - * Copied from org.eclipse.core.filebuffers.tests. - * - * @since 4.0 - */ -public class ResourceHelper { - - private final static IProgressMonitor NULL_MONITOR= new NullProgressMonitor(); - private static final int MAX_RETRY= 5; - - public static IProject createProject(String projectName) throws CoreException { - - IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - IProject project= root.getProject(projectName); - if (!project.exists()) - project.create(NULL_MONITOR); - else - project.refreshLocal(IResource.DEPTH_INFINITE, null); - - if (!project.isOpen()) - project.open(NULL_MONITOR); - - return project; - } - - public static void deleteProject(String projectName) throws CoreException { - IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - IProject project= root.getProject(projectName); - if (project.exists()) - delete(project); - } - - public static void delete(final IProject project) throws CoreException { - delete(project, true); - } - - public static void delete(final IProject project, boolean deleteContent) throws CoreException { - for (int i= 0; i < MAX_RETRY; i++) { - try { - project.delete(deleteContent, true, NULL_MONITOR); - i= MAX_RETRY; - } catch (CoreException x) { - if (i == MAX_RETRY - 1) { - CTestPlugin.getDefault().getLog().log(x.getStatus()); -// throw x; - } - try { - Thread.sleep(1000); // sleep a second - } catch (InterruptedException e) { - } - } - } - } - - public static IFolder createFolder(String portableFolderPath) throws CoreException { - ContainerCreator creator= new ContainerCreator(ResourcesPlugin.getWorkspace(), new Path(portableFolderPath)); - IContainer container= creator.createContainer(NULL_MONITOR); - if (container instanceof IFolder) - return (IFolder) container; - return null; - } - - public static IFile createFile(IFolder folder, String name, String contents) throws CoreException { - return createFile(folder.getFile(name), name, contents); - } - - public static IFile createFile(IProject project, String name, String contents) throws CoreException { - return createFile(project.getFile(name), name, contents); - } - - private static IFile createFile(IFile file, String name, String contents) throws CoreException { - if (contents == null) - contents= ""; - InputStream inputStream= new java.io.StringBufferInputStream(contents); - file.create(inputStream, true, NULL_MONITOR); - return file; - } - - public static IFile createLinkedFile(IContainer container, IPath linkPath, File linkedFileTarget) throws CoreException { - IFile iFile= container.getFile(linkPath); - iFile.createLink(new Path(linkedFileTarget.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR); - return iFile; - } - - public static IFile createLinkedFile(IContainer container, IPath linkPath, Plugin plugin, IPath linkedFileTargetPath) throws CoreException { - File file= FileTool.getFileInPlugin(plugin, linkedFileTargetPath); - IFile iFile= container.getFile(linkPath); - iFile.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR); - return iFile; - } - - public static IFolder createLinkedFolder(IContainer container, IPath linkPath, File linkedFolderTarget) throws CoreException { - IFolder folder= container.getFolder(linkPath); - folder.createLink(new Path(linkedFolderTarget.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR); - return folder; - } - - public static IFolder createLinkedFolder(IContainer container, IPath linkPath, Plugin plugin, IPath linkedFolderTargetPath) throws CoreException { - File file= FileTool.getFileInPlugin(plugin, linkedFolderTargetPath); - IFolder iFolder= container.getFolder(linkPath); - iFolder.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR); - return iFolder; - } - - public static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException { - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IProject project= workspace.getRoot().getProject(projectName); - - IProjectDescription desc= workspace.newProjectDescription(projectName); - File file= FileTool.getFileInPlugin(plugin, linkPath); - IPath projectLocation= new Path(file.getAbsolutePath()); - if (Platform.getLocation().equals(projectLocation)) - projectLocation= null; - desc.setLocation(projectLocation); - - project.create(desc, NULL_MONITOR); - if (!project.isOpen()) - project.open(NULL_MONITOR); - - return project; - } -} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java index 5f142a8befc..c43f2b2e23e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,6 +27,8 @@ import org.eclipse.ui.texteditor.ShiftAction; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.editor.CEditor; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java index 5edd645865e..31be146d059 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/AbstractContentAssistTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,8 +35,8 @@ import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.testplugin.CTestPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.ui.text.ICCompletionProposal; import org.eclipse.cdt.ui.text.ICPartitions; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java index 644b26bcdf9..6a9ade316b9 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/DocCommentHighlightingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Symbian Software Systems and others. + * Copyright (c) 2008, 2010 Symbian Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -38,10 +38,10 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.testplugin.Accessor; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; +import org.eclipse.cdt.ui.testplugin.ResourceTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.Accessor; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; -import org.eclipse.cdt.ui.tests.text.ResourceTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java index fa78b4384d3..8c37cd4b9e3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java @@ -51,8 +51,8 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.FileManager; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable; import org.eclipse.cdt.internal.core.parser.ParserException; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java index 19fd22dacf1..a64a729bcc6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -55,8 +55,8 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java index 27633762849..484e47a5c6e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -49,8 +49,8 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.FileManager; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java index 281f34354a8..e2330f2e010 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,8 +35,8 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; -import org.eclipse.cdt.ui.tests.text.EditorTestHelper; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;