mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Delete projects fully at the end of tests
This code seems to be trying to optimize across tests. This change isolated each individual test better. Also removed is a bunch of effectively unused test code. Part of #117
This commit is contained in:
parent
e1dea25b40
commit
57d7a47f45
18 changed files with 116 additions and 581 deletions
|
@ -16,18 +16,15 @@ package org.eclipse.cdt.core.parser.tests;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.core.testplugin.FileManager;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -39,68 +36,21 @@ public abstract class FileBasePluginTestCase extends TestCase {
|
|||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects;
|
||||
static Class className;
|
||||
static ICProject cPrj;
|
||||
private Class className2;
|
||||
|
||||
public FileBasePluginTestCase() {
|
||||
}
|
||||
|
||||
public FileBasePluginTestCase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public FileBasePluginTestCase(String name, Class className) {
|
||||
super(name);
|
||||
className2 = className;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initialize(className2);
|
||||
}
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
assertNotNull(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,18 +58,8 @@ public abstract class FileBasePluginTestCase extends TestCase {
|
|||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
project.delete(true, false, monitor);
|
||||
BaseTestCase5.assertWorkspaceIsEmpty();
|
||||
}
|
||||
|
||||
protected IFolder importFolder(String folderName) throws Exception {
|
||||
|
@ -144,8 +84,6 @@ public abstract class FileBasePluginTestCase extends TestCase {
|
|||
file.create(stream, false, monitor);
|
||||
}
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,18 +52,6 @@ import org.eclipse.core.resources.IFile;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
|
||||
|
||||
public AST2SelectionParseTest() {
|
||||
}
|
||||
|
||||
public AST2SelectionParseTest(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
public AST2SelectionParseTest(String name) {
|
||||
super(name, AST2SelectionParseTest.class);
|
||||
}
|
||||
|
||||
public void testBaseCase_VariableReference() throws Exception {
|
||||
String code = "void f() { int x; x=3; }"; //$NON-NLS-1$
|
||||
int offset1 = code.indexOf("x="); //$NON-NLS-1$
|
||||
|
|
|
@ -45,19 +45,8 @@ import org.eclipse.core.resources.IFile;
|
|||
*/
|
||||
public abstract class AST2SelectionParseTestBase extends FileBasePluginTestCase {
|
||||
|
||||
public AST2SelectionParseTestBase() {
|
||||
}
|
||||
|
||||
public AST2SelectionParseTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||
|
||||
public AST2SelectionParseTestBase(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
protected IASTNode parse(String code, ParserLanguage lang, int offset, int length) throws ParserException {
|
||||
return parse(code, lang, false, false, offset, length);
|
||||
}
|
||||
|
|
|
@ -20,18 +20,15 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.core.testplugin.FileManager;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -42,69 +39,20 @@ import junit.framework.TestCase;
|
|||
public abstract class DOMFileBasePluginTest extends TestCase {
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects = 0;
|
||||
static Class className;
|
||||
protected IProject project;
|
||||
static ICProject cPrj;
|
||||
private Class className2;
|
||||
|
||||
public DOMFileBasePluginTest() {
|
||||
}
|
||||
|
||||
public DOMFileBasePluginTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public DOMFileBasePluginTest(String name, Class className) {
|
||||
super(name);
|
||||
className2 = className;
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initialize(className2);
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
assertNotNull(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,38 +60,10 @@ public abstract class DOMFileBasePluginTest extends TestCase {
|
|||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
project.delete(true, false, monitor);
|
||||
BaseTestCase5.assertWorkspaceIsEmpty();
|
||||
}
|
||||
|
||||
// below can be used to work with large files (too large for memory)
|
||||
// protected IFile importFile(String fileName) throws Exception {
|
||||
// IFile file = cPrj.getProject().getFile(fileName);
|
||||
// if (!file.exists()) {
|
||||
// try{
|
||||
// FileInputStream fileIn = new FileInputStream(
|
||||
// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
|
||||
// file.create(fileIn,false, monitor);
|
||||
// } catch (CoreException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return file;
|
||||
// }
|
||||
|
||||
protected IFolder importFolder(String folderName) throws Exception {
|
||||
IFolder folder = project.getProject().getFolder(folderName);
|
||||
|
||||
|
@ -165,8 +85,6 @@ public abstract class DOMFileBasePluginTest extends TestCase {
|
|||
else
|
||||
file.create(stream, false, monitor);
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,18 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
*
|
||||
*/
|
||||
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBase {
|
||||
|
||||
public DOMGCCSelectionParseExtensionsTest() {
|
||||
}
|
||||
|
||||
public DOMGCCSelectionParseExtensionsTest(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
public DOMGCCSelectionParseExtensionsTest(String name) {
|
||||
super(name, DOMGCCSelectionParseExtensionsTest.class);
|
||||
}
|
||||
|
||||
public void testBug43021() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write("extern int johnc(__const char *__restrict __format, ...);\n"); //$NON-NLS-1$
|
||||
|
|
|
@ -48,18 +48,6 @@ import org.eclipse.core.resources.IFile;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class DOMSelectionParseTest extends DOMSelectionParseTestBase {
|
||||
|
||||
public DOMSelectionParseTest() {
|
||||
}
|
||||
|
||||
public DOMSelectionParseTest(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
public DOMSelectionParseTest(String name) {
|
||||
super(name, DOMSelectionParseTest.class);
|
||||
}
|
||||
|
||||
public void testBaseCase_VariableReference() throws Exception {
|
||||
String code = "void f() { int x; x=3; }";
|
||||
int offset1 = code.indexOf("x=");
|
||||
|
|
|
@ -28,17 +28,6 @@ import org.eclipse.core.resources.IFile;
|
|||
*/
|
||||
public abstract class DOMSelectionParseTestBase extends DOMFileBasePluginTest {
|
||||
|
||||
public DOMSelectionParseTestBase() {
|
||||
}
|
||||
|
||||
public DOMSelectionParseTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public DOMSelectionParseTestBase(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
protected IASTNode parse(String code, int offset1, int offset2) throws Exception {
|
||||
return parse(code, offset1, offset2, true);
|
||||
}
|
||||
|
|
|
@ -21,19 +21,17 @@ package org.eclipse.cdt.core.tests;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.core.testplugin.FileManager;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
|
@ -41,42 +39,12 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
* @author aniefer
|
||||
*/
|
||||
abstract public class BaseTestFramework extends BaseTestCase {
|
||||
static protected NullProgressMonitor monitor;
|
||||
static protected IWorkspace workspace;
|
||||
static protected IProject project;
|
||||
static protected ICProject cproject;
|
||||
static protected FileManager fileManager;
|
||||
static protected boolean indexDisabled = false;
|
||||
|
||||
static void initProject() {
|
||||
if (project != null) {
|
||||
return;
|
||||
}
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
project = cproject.getProject();
|
||||
|
||||
/*project.setSessionProperty(SourceIndexer.activationKey, Boolean.FALSE);
|
||||
//Set the id of the source indexer extension point as a session property to allow
|
||||
//index manager to instantiate it
|
||||
project.setSessionProperty(IndexManager.indexerIDKey, sourceIndexerID);*/
|
||||
} catch (CoreException e) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
protected NullProgressMonitor monitor;
|
||||
protected IWorkspace workspace;
|
||||
protected IProject project;
|
||||
protected ICProject cproject;
|
||||
protected FileManager fileManager;
|
||||
protected boolean indexDisabled = false;
|
||||
|
||||
public BaseTestFramework() {
|
||||
super();
|
||||
|
@ -89,18 +57,17 @@ abstract public class BaseTestFramework extends BaseTestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
try {
|
||||
project.delete(true, false, monitor);
|
||||
} finally {
|
||||
project = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initProject();
|
||||
monitor = new NullProgressMonitor();
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
cproject = CProjectHelper.createCCProject("RegressionTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cproject.getProject();
|
||||
assertNotNull(project);
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,14 +75,9 @@ abstract public class BaseTestFramework extends BaseTestCase {
|
|||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (IResource member : members) {
|
||||
if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (member.getName().equals(".settings"))
|
||||
continue;
|
||||
member.delete(false, monitor);
|
||||
}
|
||||
project.delete(true, true, monitor);
|
||||
BaseTestCase5.assertWorkspaceIsEmpty();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected IFile importFile(String fileName, String contents) throws Exception {
|
||||
|
|
|
@ -29,16 +29,7 @@ public class RenameFunctionTests extends RenameTestBase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameFunctionTests.class);
|
||||
|
||||
if (cleanup) {
|
||||
suite.addTest(new RenameFunctionTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
return new TestSuite(RenameFunctionTests.class);
|
||||
}
|
||||
|
||||
public void testFunctionNameConflicts() throws Exception {
|
||||
|
|
|
@ -28,15 +28,7 @@ public class RenameMacroTests extends RenameTestBase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameMacroTests.class);
|
||||
if (cleanup) {
|
||||
suite.addTest(new RenameMacroTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
return new TestSuite(RenameMacroTests.class);
|
||||
}
|
||||
|
||||
public void testMacroRename() throws Exception {
|
||||
|
|
|
@ -32,15 +32,7 @@ public class RenameTemplatesTests extends RenameTestBase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameTemplatesTests.class);
|
||||
if (cleanup) {
|
||||
suite.addTest(new RenameTemplatesTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
return new TestSuite(RenameTemplatesTests.class);
|
||||
}
|
||||
|
||||
public void testClassTemplate() throws Exception {
|
||||
|
|
|
@ -33,15 +33,7 @@ public class RenameTypeTests extends RenameTestBase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameTypeTests.class);
|
||||
if (cleanup) {
|
||||
suite.addTest(new RenameTypeTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
return new TestSuite(RenameTypeTests.class);
|
||||
}
|
||||
|
||||
public void testClassNameConflicts() throws Exception {
|
||||
|
|
|
@ -32,16 +32,7 @@ public class RenameVariableTests extends RenameTestBase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameVariableTests.class);
|
||||
|
||||
if (cleanup) {
|
||||
suite.addTest(new RenameVariableTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
return new TestSuite(RenameVariableTests.class);
|
||||
}
|
||||
|
||||
public void testLocalNameConflicts() throws Exception {
|
||||
|
|
|
@ -23,17 +23,13 @@ import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
|
|||
import org.eclipse.cdt.ui.testplugin.ResourceTestHelper;
|
||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextOperationTarget;
|
||||
import org.eclipse.jface.text.source.SourceViewer;
|
||||
import org.eclipse.ui.texteditor.ShiftAction;
|
||||
|
||||
import junit.extensions.TestSetup;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Test the Shift left/right actions.
|
||||
|
@ -51,59 +47,30 @@ public class ShiftActionTest extends BaseUITestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected static class ShiftTestSetup extends TestSetup {
|
||||
|
||||
private ICProject fCProject;
|
||||
|
||||
public ShiftTestSetup(Test test) {
|
||||
super(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
fCProject = CProjectHelper.createCProject(PROJECT, null);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, String.valueOf(8));
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, String.valueOf(4));
|
||||
IFile file = EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
EditorTestHelper.closeAllEditors();
|
||||
if (fCProject != null) {
|
||||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Class<?> THIS = ShiftActionTest.class;
|
||||
|
||||
public static Test suite() {
|
||||
return new ShiftTestSetup(new TestSuite(THIS));
|
||||
return suite(ShiftActionTest.class);
|
||||
}
|
||||
|
||||
private CEditor fEditor;
|
||||
private SourceViewer fSourceViewer;
|
||||
private IDocument fDocument;
|
||||
private ShiftTestSetup fProjectSetup;
|
||||
private ICProject fCProject;
|
||||
|
||||
/*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
|
||||
fProjectSetup = new ShiftTestSetup(this);
|
||||
fProjectSetup.setUp();
|
||||
}
|
||||
super.setUp();
|
||||
|
||||
fCProject = CProjectHelper.createCProject(PROJECT, null);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, String.valueOf(8));
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, String.valueOf(4));
|
||||
IFile file = EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
|
||||
fEditor = (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(PROJECT + '/' + FILE), true);
|
||||
fSourceViewer = EditorTestHelper.getSourceViewer(fEditor);
|
||||
fDocument = fSourceViewer.getDocument();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -111,9 +78,8 @@ public class ShiftActionTest extends BaseUITestCase {
|
|||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (fProjectSetup != null) {
|
||||
fProjectSetup.tearDown();
|
||||
}
|
||||
EditorTestHelper.closeAllEditors();
|
||||
CProjectHelper.delete(fCProject);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,16 +24,12 @@ import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
|
|||
import org.eclipse.cdt.ui.testplugin.ResourceTestHelper;
|
||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.source.SourceViewer;
|
||||
|
||||
import junit.extensions.TestSetup;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Tests for the SortLinesAction.
|
||||
|
@ -51,68 +47,35 @@ public class SortLinesTest extends BaseUITestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected static class SortLinesTestSetup extends TestSetup {
|
||||
private ICProject fCProject;
|
||||
|
||||
public SortLinesTestSetup(Test test) {
|
||||
super(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
fCProject = CProjectHelper.createCProject(PROJECT, null);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, String.valueOf(8));
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, String.valueOf(4));
|
||||
IFile file = EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
EditorTestHelper.closeAllEditors();
|
||||
if (fCProject != null) {
|
||||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Class<?> THIS = SortLinesTest.class;
|
||||
|
||||
public static Test suite() {
|
||||
return new SortLinesTestSetup(new TestSuite(THIS));
|
||||
return suite(SortLinesTest.class);
|
||||
}
|
||||
|
||||
private CEditor fEditor;
|
||||
private SourceViewer fSourceViewer;
|
||||
private IDocument fDocument;
|
||||
private SortLinesTestSetup fProjectSetup;
|
||||
private ICProject fCProject;
|
||||
|
||||
/*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
|
||||
fProjectSetup = new SortLinesTestSetup(this);
|
||||
fProjectSetup.setUp();
|
||||
}
|
||||
super.setUp();
|
||||
|
||||
fCProject = CProjectHelper.createCProject(PROJECT, null);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, String.valueOf(8));
|
||||
fCProject.setOption(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, String.valueOf(4));
|
||||
IFile file = EditorTestHelper.createFile(fCProject.getProject(), FILE, "", new NullProgressMonitor());
|
||||
|
||||
fEditor = (CEditor) EditorTestHelper.openInEditor(ResourceTestHelper.findFile(PROJECT + '/' + FILE), true);
|
||||
fSourceViewer = EditorTestHelper.getSourceViewer(fEditor);
|
||||
fDocument = fSourceViewer.getDocument();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (fProjectSetup != null) {
|
||||
fProjectSetup.tearDown();
|
||||
}
|
||||
EditorTestHelper.closeAllEditors();
|
||||
CProjectHelper.delete(fCProject);
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
|||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
@ -51,26 +50,17 @@ import junit.framework.TestSuite;
|
|||
*/
|
||||
public class ContentAssistTests extends BaseUITestCase {
|
||||
private final NullProgressMonitor monitor = new NullProgressMonitor();
|
||||
static IProject project;
|
||||
static ICProject cproject;
|
||||
static boolean disabledHelpContributions;
|
||||
IProject project;
|
||||
ICProject cproject;
|
||||
boolean disabledHelpContributions;
|
||||
|
||||
@Override
|
||||
public void setUp() throws InterruptedException {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
|
||||
if (project == null) {
|
||||
try {
|
||||
cproject = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", //$NON-NLS-1$//$NON-NLS-2$
|
||||
IPDOMManager.ID_FAST_INDEXER);
|
||||
project = cproject.getProject();
|
||||
waitForIndexer(cproject);
|
||||
} catch (CoreException e) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
}
|
||||
public void setUp() throws InterruptedException, CoreException {
|
||||
cproject = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", //$NON-NLS-1$//$NON-NLS-2$
|
||||
IPDOMManager.ID_FAST_INDEXER);
|
||||
project = cproject.getProject();
|
||||
waitForIndexer(cproject);
|
||||
assertNotNull(project);
|
||||
}
|
||||
|
||||
public ContentAssistTests() {
|
||||
|
@ -106,20 +96,9 @@ public class ContentAssistTests extends BaseUITestCase {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite = suite(ContentAssistTests.class, "_");
|
||||
suite.addTest(new ContentAssistTests("cleanupProject")); //$NON-NLS-1$
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
closeAllEditors();
|
||||
try {
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (project == null || !project.exists())
|
||||
|
@ -129,20 +108,8 @@ public class ContentAssistTests extends BaseUITestCase {
|
|||
|
||||
// wait for indexer before deleting project to avoid errors in the log
|
||||
waitForIndexer(cproject);
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (IResource member : members) {
|
||||
if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (member.getName().equals(".settings"))
|
||||
continue;
|
||||
try {
|
||||
member.delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
|
||||
project.delete(true, false, monitor);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected IFile importFile(String fileName, String contents) throws Exception {
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
@ -64,41 +63,12 @@ import junit.framework.TestSuite;
|
|||
*/
|
||||
public class CPPSelectionNoIndexerTests extends BaseSelectionTests {
|
||||
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static ICProject cPrj;
|
||||
static FileManager fileManager;
|
||||
static boolean disabledHelpContributions = false;
|
||||
|
||||
static void initProject() {
|
||||
if (project != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("CPPSelectionTestsNoIndexer", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
project = cPrj.getProject();
|
||||
|
||||
IPath pathLoc = CCorePlugin.getDefault().getStateLocation();
|
||||
File indexFile = new File(pathLoc.append(INDEX_FILE_ID + ".index").toOSString()); //$NON-NLS-1$
|
||||
if (indexFile.exists())
|
||||
indexFile.delete();
|
||||
} catch (CoreException e) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
NullProgressMonitor monitor;
|
||||
IWorkspace workspace;
|
||||
IProject project;
|
||||
ICProject cPrj;
|
||||
FileManager fileManager;
|
||||
boolean disabledHelpContributions = false;
|
||||
|
||||
public CPPSelectionNoIndexerTests() {
|
||||
super();
|
||||
|
@ -113,28 +83,28 @@ public class CPPSelectionNoIndexerTests extends BaseSelectionTests {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite = suite(CPPSelectionNoIndexerTests.class, "_");
|
||||
suite.addTest(new CPPSelectionNoIndexerTests("cleanupProject")); //$NON-NLS-1$
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
closeAllEditors();
|
||||
try {
|
||||
project.delete(true, false, monitor);
|
||||
} catch (CoreException e) {
|
||||
try {
|
||||
project.delete(true, false, monitor);
|
||||
} catch (CoreException e1) {
|
||||
}
|
||||
} finally {
|
||||
project = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initProject();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
cPrj = CProjectHelper.createCCProject("CPPSelectionTestsNoIndexer", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
project = cPrj.getProject();
|
||||
|
||||
IPath pathLoc = CCorePlugin.getDefault().getStateLocation();
|
||||
File indexFile = new File(pathLoc.append(INDEX_FILE_ID + ".index").toOSString()); //$NON-NLS-1$
|
||||
if (indexFile.exists())
|
||||
indexFile.delete();
|
||||
assertNotNull("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
OpenDeclarationsAction.sDisallowAmbiguousInput = true;
|
||||
}
|
||||
|
||||
|
@ -144,19 +114,7 @@ public class CPPSelectionNoIndexerTests extends BaseSelectionTests {
|
|||
return;
|
||||
|
||||
closeAllEditors();
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (IResource member : members) {
|
||||
if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (member.getName().equals(".settings"))
|
||||
continue;
|
||||
try {
|
||||
member.delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
project.delete(true, true, monitor);
|
||||
}
|
||||
|
||||
protected IFile importFile(String fileName, String contents) throws Exception {
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
@ -51,34 +50,11 @@ import junit.framework.TestSuite;
|
|||
public class CSelectionNoIndexerTests extends BaseSelectionTests {
|
||||
|
||||
private static final String INDEX_FILE_ID = "2324852323"; //$NON-NLS-1$
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static ICProject cPrj;
|
||||
static FileManager fileManager;
|
||||
static boolean disabledHelpContributions = false;
|
||||
|
||||
void initProject() {
|
||||
if (project != null) {
|
||||
return;
|
||||
}
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCProject("CSelectionTestsNoIndexerProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
} catch (CoreException e) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
NullProgressMonitor monitor;
|
||||
IWorkspace workspace;
|
||||
IProject project;
|
||||
ICProject cPrj;
|
||||
FileManager fileManager;
|
||||
|
||||
public CSelectionNoIndexerTests() {
|
||||
super();
|
||||
|
@ -93,7 +69,6 @@ public class CSelectionNoIndexerTests extends BaseSelectionTests {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(CSelectionNoIndexerTests.class);
|
||||
suite.addTest(new CSelectionNoIndexerTests("cleanupProject")); //$NON-NLS-1$
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
@ -101,17 +76,16 @@ public class CSelectionNoIndexerTests extends BaseSelectionTests {
|
|||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
OpenDeclarationsAction.sDisallowAmbiguousInput = true;
|
||||
initProject();
|
||||
}
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
try {
|
||||
closeAllEditors();
|
||||
CProjectHelper.delete(cPrj);
|
||||
project = null;
|
||||
} finally {
|
||||
project = null;
|
||||
}
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
cPrj = CProjectHelper.createCProject("CSelectionTestsNoIndexerProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
assertNotNull(project);
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,19 +94,8 @@ public class CSelectionNoIndexerTests extends BaseSelectionTests {
|
|||
return;
|
||||
|
||||
closeAllEditors();
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (IResource member : members) {
|
||||
if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (member.getName().equals(".settings"))
|
||||
continue;
|
||||
try {
|
||||
member.delete(true, monitor);
|
||||
} catch (Throwable e) {
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
CProjectHelper.delete(cPrj);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected IFile importFile(String fileName, String contents) throws Exception {
|
||||
|
|
Loading…
Add table
Reference in a new issue