diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 9037eb299f7..b589c5494db 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,6 @@ +2003-07-25 Bogdan Gheorghe + Added new indexer test for refs + 2003-07-24 John Camelon Updated CompleteParseASTTests for Method/Field updates. Fixed TortureTest's parser mode switch (was always QuickParsing). diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java index cee69e68dba..bf20749ecc4 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java @@ -51,7 +51,7 @@ public class IndexManagerTests extends TestCase { IProject testProject; NullProgressMonitor monitor; IndexManager indexManager; - public static final int TIMEOUT = 1500; + public static final int TIMEOUT = 10000; /** * Constructor for IndexManagerTest. * @param name @@ -84,10 +84,10 @@ public class IndexManagerTests extends TestCase { } public static Test suite() { - //TestSuite suite = new TestSuite(); - //suite.addTest(new IndexManagerTests("testDependencyTree")); - //return suite; - return new TestSuite(IndexManagerTests.class); + TestSuite suite = new TestSuite(); + suite.addTest(new IndexManagerTests("testRefs")); + return suite; + //return new TestSuite(IndexManagerTests.class); } /* * Utils @@ -282,6 +282,8 @@ public class IndexManagerTests extends TestCase { IIndex ind = indexManager.getIndex(testProjectPath,true,true); assertTrue("Index exists for project",ind != null); + IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF); + String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"}; IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL); @@ -349,6 +351,75 @@ public class IndexManagerTests extends TestCase { } } + public void testRefs() throws Exception{ + //Add a new file to the project, give it some time to index + importFile("reftest.cpp","resources/indexer/reftest.cpp"); + //Enable indexing on the created project + //By doing this, we force the Index Manager to indexAll() + indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager(); + indexManager.setEnabled(testProject,true); + Thread.sleep(TIMEOUT); + //Make sure project got added to index + IPath testProjectPath = testProject.getFullPath(); + IIndex ind = indexManager.getIndex(testProjectPath,true,true); + assertTrue("Index exists for project",ind != null); + + String [] typeRefEntryResultModel ={"EntryResult: word=typeRef/C/C/B/A, refs={ 1 }", "EntryResult: word=typeRef/E/e1/B/A, refs={ 1 }", "EntryResult: word=typeRef/V/x/B/A, refs={ 1 }"}; + IEntryResult[] typerefresults = ind.queryEntries(IIndexConstants.TYPE_REF); + + if (typerefresults.length != typeRefEntryResultModel.length) + fail("Entry Result length different from model for typeRef"); + + for (int i=0;i