mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 19:25:38 +02:00
Clean up usage of TestScannerProvider within the tests.
This commit is contained in:
parent
61c38d0f85
commit
f6b7c739ba
9 changed files with 105 additions and 110 deletions
|
@ -58,7 +58,6 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
@ -75,18 +74,18 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return suite(IndexBugsTests.class);
|
return suite(IndexBugsTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws CoreException {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
fCProject= CProjectHelper.createCCProject("__bugsTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
fCProject= CProjectHelper.createCCProject("__bugsTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
CCorePlugin.getIndexManager().reindex(fCProject);
|
CCorePlugin.getIndexManager().reindex(fCProject);
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws CoreException {
|
protected void tearDown() throws Exception {
|
||||||
TestScannerProvider.sIncludeFiles= TestScannerProvider.sIncludes=
|
|
||||||
TestScannerProvider.sMacroFiles= null;
|
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
CProjectHelper.delete(fCProject);
|
CProjectHelper.delete(fCProject);
|
||||||
}
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject getProject() {
|
protected IProject getProject() {
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +155,6 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
public void testIncludeProperties() throws Exception {
|
public void testIncludeProperties() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
||||||
try {
|
|
||||||
String content= readTaggedComment("source20061107");
|
String content= readTaggedComment("source20061107");
|
||||||
TestSourceReader.createFile(fProject.getProject(), "user20061107.h", "");
|
TestSourceReader.createFile(fProject.getProject(), "user20061107.h", "");
|
||||||
TestSourceReader.createFile(fProject.getProject(), "system20061107.h", "");
|
TestSourceReader.createFile(fProject.getProject(), "system20061107.h", "");
|
||||||
|
@ -177,14 +175,9 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testIncludeProperties_2() throws Exception {
|
public void testIncludeProperties_2() throws Exception {
|
||||||
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
||||||
try {
|
|
||||||
TestSourceReader.createFile(fProject.getProject(), "header20061107.h", "");
|
TestSourceReader.createFile(fProject.getProject(), "header20061107.h", "");
|
||||||
String content = "// comment \n#include \"header20061107.h\"\n";
|
String content = "// comment \n#include \"header20061107.h\"\n";
|
||||||
IFile file= TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content);
|
IFile file= TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content);
|
||||||
|
@ -206,14 +199,9 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInactiveInclude() throws Exception {
|
public void testInactiveInclude() throws Exception {
|
||||||
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
||||||
try {
|
|
||||||
String content = "#if 0\n#include \"inactive20070213.h\"\n#endif\n";
|
String content = "#if 0\n#include \"inactive20070213.h\"\n#endif\n";
|
||||||
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content);
|
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content);
|
||||||
CCorePlugin.getIndexManager().reindex(fProject);
|
CCorePlugin.getIndexManager().reindex(fProject);
|
||||||
|
@ -233,14 +221,9 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testUnresolvedInclude() throws Exception {
|
public void testUnresolvedInclude() throws Exception {
|
||||||
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()};
|
||||||
try {
|
|
||||||
String content = "#include \"unresolved20070213.h\"\n";
|
String content = "#include \"unresolved20070213.h\"\n";
|
||||||
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content);
|
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content);
|
||||||
CCorePlugin.getIndexManager().reindex(fProject);
|
CCorePlugin.getIndexManager().reindex(fProject);
|
||||||
|
@ -261,10 +244,6 @@ public class IndexIncludeTest extends IndexTestBase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem) throws CoreException {
|
private void checkInclude(IIndexInclude include, String content, String includeName, boolean isSystem) throws CoreException {
|
||||||
int offset= content.indexOf(includeName);
|
int offset= content.indexOf(includeName);
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||||
if (cproject == null) {
|
if (cproject == null) {
|
||||||
cproject= createProject(true, "resources/indexTests/trilogy");
|
cproject= createProject(true, "resources/indexTests/trilogy");
|
||||||
|
@ -48,6 +49,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
cproject.getProject().delete(true, new NullProgressMonitor());
|
cproject.getProject().delete(true, new NullProgressMonitor());
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// you must have the Windows SDK installed and the INETSDK env var setup
|
// you must have the Windows SDK installed and the INETSDK env var setup
|
||||||
|
@ -55,7 +57,6 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
||||||
if(Platform.getOS().equals(Platform.OS_WIN32)) {
|
if(Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||||
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
|
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
|
||||||
try {
|
|
||||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
CCorePlugin.getIndexManager().reindex(cproject);
|
CCorePlugin.getIndexManager().reindex(cproject);
|
||||||
|
@ -64,9 +65,6 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor());
|
IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor());
|
||||||
assertEquals(1, binding.length);
|
assertEquals(1, binding.length);
|
||||||
} finally {
|
|
||||||
TestScannerProvider.sIncludes = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,10 @@ public class TestScannerProvider extends AbstractCExtension implements IScannerI
|
||||||
public static String[] sMacroFiles= null;
|
public static String[] sMacroFiles= null;
|
||||||
public final static String SCANNER_ID = CTestPlugin.PLUGIN_ID + ".TestScanner";
|
public final static String SCANNER_ID = CTestPlugin.PLUGIN_ID + ".TestScanner";
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
sIncludes= sIncludeFiles= sMacroFiles= null;
|
||||||
|
}
|
||||||
|
|
||||||
public IScannerInfo getScannerInformation(IResource resource) {
|
public IScannerInfo getScannerInformation(IResource resource) {
|
||||||
return new TestScannerInfo(sIncludes, sIncludeFiles, sMacroFiles);
|
return new TestScannerInfo(sIncludes, sIncludeFiles, sMacroFiles);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
|
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.ILogListener;
|
import org.eclipse.core.runtime.ILogListener;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -53,6 +54,13 @@ public class BaseTestCase extends TestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
TestScannerProvider.clear();
|
||||||
|
}
|
||||||
|
|
||||||
protected static TestSuite suite(Class clazz) {
|
protected static TestSuite suite(Class clazz) {
|
||||||
return suite(clazz, null);
|
return suite(clazz, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
if (fCProject2 != null) {
|
if (fCProject2 != null) {
|
||||||
CProjectHelper.delete(fCProject2);
|
CProjectHelper.delete(fCProject2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.ui.tests.includebrowser;
|
package org.eclipse.cdt.ui.tests.includebrowser;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
|
@ -44,7 +43,8 @@ public class IncludeBrowserBaseTest extends BaseUITestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws CoreException {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
fCProject= CProjectHelper.createCCProject("__ibTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
fCProject= CProjectHelper.createCCProject("__ibTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
|
||||||
// clear the index
|
// clear the index
|
||||||
|
@ -52,10 +52,11 @@ public class IncludeBrowserBaseTest extends BaseUITestCase {
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws CoreException {
|
protected void tearDown() throws Exception {
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
CProjectHelper.delete(fCProject);
|
CProjectHelper.delete(fCProject);
|
||||||
}
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICProject getProject() {
|
protected ICProject getProject() {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.search;
|
package org.eclipse.cdt.ui.tests.search;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ public class BasicSearchTest extends BaseUITestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
fCProject = CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
fCProject = CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||||
testData = TestSourceReader.getContentsForTest(b, "ui", this.getClass(), getName(), 2);
|
testData = TestSourceReader.getContentsForTest(b, "ui", this.getClass(), getName(), 2);
|
||||||
|
@ -74,6 +76,7 @@ public class BasicSearchTest extends BaseUITestCase {
|
||||||
if(fCProject != null) {
|
if(fCProject != null) {
|
||||||
fCProject.getProject().delete(true, NPM);
|
fCProject.getProject().delete(true, NPM);
|
||||||
}
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// // empty
|
// // empty
|
||||||
|
@ -110,14 +113,19 @@ public class BasicSearchTest extends BaseUITestCase {
|
||||||
ILabelProvider labpv= (ILabelProvider) viewer.getLabelProvider();
|
ILabelProvider labpv= (ILabelProvider) viewer.getLabelProvider();
|
||||||
IStructuredContentProvider scp= (IStructuredContentProvider) viewer.getContentProvider();
|
IStructuredContentProvider scp= (IStructuredContentProvider) viewer.getContentProvider();
|
||||||
|
|
||||||
Object result0= result.getElements()[0];
|
String label0= labpv.getText(scp.getElements(result)[0]);
|
||||||
Object result1= result.getElements()[1];
|
String label1= labpv.getText(scp.getElements(result)[1]);
|
||||||
|
|
||||||
|
// the content provider does not sort the result, so we have to do it:
|
||||||
|
if (label0.compareTo(label1) < 0) {
|
||||||
|
String h= label0; label0= label1; label1= h;
|
||||||
|
}
|
||||||
|
|
||||||
// check the results are rendered
|
// check the results are rendered
|
||||||
String expected0= fCProject.getProject().getName();
|
String expected0= fCProject.getProject().getName();
|
||||||
String expected1= new Path(externalFile.getAbsolutePath()).toString();
|
String expected1= new Path(externalFile.getAbsolutePath()).toString();
|
||||||
assertEquals(expected0,labpv.getText(scp.getElements(result)[0]));
|
assertEquals(expected0,label0);
|
||||||
assertEquals(expected1,labpv.getText(scp.getElements(result)[1]));
|
assertEquals(expected1,label1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
TestScannerProvider.sIncludes= null;
|
|
||||||
if (fCProject2 != null) {
|
if (fCProject2 != null) {
|
||||||
CProjectHelper.delete(fCProject2);
|
CProjectHelper.delete(fCProject2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue