mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Updated to refledt api changes, and come CProjectHelper code cleanup
This commit is contained in:
parent
92c9f39f22
commit
d54c3caff1
3 changed files with 20 additions and 89 deletions
11
core/org.eclipse.cdt.ui.tests/ChangeLog
Normal file
11
core/org.eclipse.cdt.ui.tests/ChangeLog
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
2002-10-30 Alain Magloire
|
||||||
|
|
||||||
|
* model/org/eclipse/cdt/core/model/tests/CModelTests.java (testGetNatureID):
|
||||||
|
The fields and the methods use in this test was removed from the CoreModel class.
|
||||||
|
(testHasNature): The method use in this case was refactor in the classes
|
||||||
|
CProjectNature and CCProjectNature, fix the test.
|
||||||
|
|
||||||
|
2002-10-18 Peter Graves
|
||||||
|
src/org/eclipse/cdt/testplugin/CProjectHelper.jada
|
||||||
|
Cleanup of the CProjectHelper file to remove unused imports, commeted out code etc.
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.io.FileNotFoundException;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.testplugin.*;
|
import org.eclipse.cdt.testplugin.*;
|
||||||
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
import org.eclipse.cdt.core.model.*;
|
import org.eclipse.cdt.core.model.*;
|
||||||
import org.eclipse.core.resources.*;
|
import org.eclipse.core.resources.*;
|
||||||
import org.eclipse.core.runtime.*;
|
import org.eclipse.core.runtime.*;
|
||||||
|
@ -85,30 +86,7 @@ public class CModelTests extends TestCase {
|
||||||
junit.textui.TestRunner.run(suite());
|
junit.textui.TestRunner.run(suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
|
||||||
* Very simple sanity tests to make sure the get*Nature* functions
|
|
||||||
* are returning sane values
|
|
||||||
*/
|
|
||||||
public void testGetNatureId(){
|
|
||||||
assertTrue("GetCNatureId returns correct value", CoreModel.getDefault().getCNatureId().equals(CoreModel.C_NATURE_ID));
|
|
||||||
assertTrue("GetCNatureName returns correct value", CoreModel.getDefault().getCNatureName().equals(CoreModel.C_NATURE_NAME));
|
|
||||||
|
|
||||||
assertTrue("GetCCNatureId returns correct value", CoreModel.getDefault().getCCNatureId().equals(CoreModel.CC_NATURE_ID));
|
|
||||||
assertTrue("GetCCNatureName returns correct value", CoreModel.getDefault().getCCNatureName().equals(CoreModel.CC_NATURE_NAME));
|
|
||||||
|
|
||||||
/***
|
|
||||||
* The following tests are here to make sure the names/ids of the
|
|
||||||
* natures do not change over time. Changing them would likely break
|
|
||||||
* backwards compatibility, so if it happens, we should know about it.
|
|
||||||
*/
|
|
||||||
assertTrue("C_NATURE_NAME is constant", CoreModel.C_NATURE_NAME.equals("cnature"));
|
|
||||||
assertTrue("C_NATURE_ID is constant", CoreModel.C_NATURE_ID.equals("org.eclipse.cdt.core.cnature"));
|
|
||||||
assertTrue("CC_NATURE_NAME is constant", CoreModel.CC_NATURE_NAME.equals("ccnature"));
|
|
||||||
assertTrue("CC_NATURE_ID is constant", CoreModel.CC_NATURE_ID.equals("org.eclipse.cdt.core.ccnature"));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* The follow are a simple set of tests to make usre the HasC/CCNature calls
|
* The follow are a simple set of tests to make usre the HasC/CCNature calls
|
||||||
* seem to be sane.
|
* seem to be sane.
|
||||||
|
@ -127,11 +105,13 @@ public class CModelTests extends TestCase {
|
||||||
fail("Unable to create project");
|
fail("Unable to create project");
|
||||||
assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject()));
|
assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject()));
|
||||||
assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
||||||
CoreModel.addCCNature(testProject.getProject(), monitor);
|
|
||||||
|
|
||||||
|
CCProjectNature.addCCNature(testProject.getProject(), monitor);
|
||||||
assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject())));
|
||||||
|
|
||||||
CoreModel.removeCCNature(testProject.getProject(), monitor);
|
CCProjectNature.removeCCNature(testProject.getProject(), monitor);
|
||||||
CoreModel.removeCNature(testProject.getProject(), monitor);
|
CCProjectNature.removeCNature(testProject.getProject(), monitor);
|
||||||
assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject()));
|
assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject()));
|
||||||
assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject())));
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package org.eclipse.cdt.testplugin;
|
package org.eclipse.cdt.testplugin;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICFolder;
|
import org.eclipse.cdt.core.model.ICFolder;
|
||||||
|
@ -26,22 +24,15 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||||
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
|
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
|
||||||
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper methods to set up a IJavaProject.
|
* Helper methods to set up a ICProject.
|
||||||
*/
|
*/
|
||||||
public class CProjectHelper {
|
public class CProjectHelper {
|
||||||
|
|
||||||
public static final IPath RT_STUBS= new Path("testresources/rtstubs.jar");
|
|
||||||
public static final IPath JUNIT_SRC= new Path("testresources/junit37-noUI-src.zip");
|
|
||||||
|
|
||||||
public static final IPath MYLIB= new Path("testresources/mylib.jar");
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ICProject.
|
* Creates a ICProject.
|
||||||
*/
|
*/
|
||||||
|
@ -72,24 +63,9 @@ public class CProjectHelper {
|
||||||
* Removes a ICProject.
|
* Removes a ICProject.
|
||||||
*/
|
*/
|
||||||
public static void delete(ICProject cproject) throws CoreException {
|
public static void delete(ICProject cproject) throws CoreException {
|
||||||
performDummySearch();
|
|
||||||
cproject.getProject().delete(true, true, null);
|
cproject.getProject().delete(true, true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performDummySearch() throws CModelException {
|
|
||||||
/* SearchEngine().searchAllTypeNames(
|
|
||||||
ResourcesPlugin.getWorkspace(),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
IJavaSearchConstants.EXACT_MATCH,
|
|
||||||
IJavaSearchConstants.CASE_SENSITIVE,
|
|
||||||
IJavaSearchConstants.CLASS,
|
|
||||||
SearchEngine.createJavaSearchScope(new IJavaElement[0]),
|
|
||||||
new Requestor(),
|
|
||||||
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
|
||||||
null); */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a source container to a ICProject.
|
* Adds a source container to a ICProject.
|
||||||
|
@ -121,7 +97,7 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a source folder from a IJavaProject.
|
* Removes a source folder from a ICProject.
|
||||||
*/
|
*/
|
||||||
public static void removeSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
public static void removeSourceContainer(ICProject cproject, String containerName) throws CoreException {
|
||||||
IFolder folder= cproject.getProject().getFolder(containerName);
|
IFolder folder= cproject.getProject().getFolder(containerName);
|
||||||
|
@ -129,13 +105,6 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a required project entry.
|
|
||||||
*/
|
|
||||||
public static void addRequiredProject(ICProject cproject, ICProject required) throws CModelException {
|
|
||||||
//IClasspathEntry cpe= JavaCore.newProjectEntry(required.getProject().getFullPath());
|
|
||||||
//addToClasspath(cproject, cpe);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find an archive with the given name in the workspace
|
* Attempts to find an archive with the given name in the workspace
|
||||||
|
@ -244,35 +213,6 @@ public class CProjectHelper {
|
||||||
return(null);
|
return(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to find rt.jar
|
|
||||||
*/
|
|
||||||
public static IPath[] findRtJar() {
|
|
||||||
File rtStubs= CTestPlugin.getDefault().getFileInPlugin(RT_STUBS);
|
|
||||||
if (rtStubs != null && rtStubs.exists()) {
|
|
||||||
return new IPath[] {
|
|
||||||
new Path(rtStubs.getPath()),
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
IVMInstall vmInstall= JavaRuntime.getDefaultVMInstall();
|
|
||||||
if (vmInstall != null) {
|
|
||||||
LibraryLocation loc= vmInstall.getVMInstallType().getDefaultLibraryLocation(vmInstall.getInstallLocation());
|
|
||||||
if (loc != null) {
|
|
||||||
return new IPath[] {
|
|
||||||
new Path(loc.getSystemLibrary().getPath()),
|
|
||||||
new Path(loc.getSystemLibrarySource().getPath()),
|
|
||||||
loc.getPackageRootPath()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
|
||||||
IProjectDescription description = proj.getDescription();
|
IProjectDescription description = proj.getDescription();
|
||||||
String[] prevNatures= description.getNatureIds();
|
String[] prevNatures= description.getNatureIds();
|
||||||
|
|
Loading…
Add table
Reference in a new issue