1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Changes from Bogdan added more tests for the indexer.

This commit is contained in:
Alain Magloire 2003-07-04 03:03:02 +00:00
parent 077238bae2
commit 91fe88d338
4 changed files with 755 additions and 622 deletions

View file

@ -1,3 +1,8 @@
2003-07-03 Bogdan Gheorghe
Added IndexManagerTest::testAddNewFileToIndex()
Added IndexManagerTest::testRemoveProjectFromIndex()
Added IndexManagerTest::testRemoveFileFromIndex()
2003-07-02 Victor Mozgin
Added DOMTests::testBug39501().
Improved filtering of expected failures/inconclusives in TortureTest.

View file

@ -67,9 +67,6 @@ public class IndexManagerTest extends TestCase {
fail("Unable to create project");
//Add a file to the project
importFile("mail.cpp","resources/indexer/mail.cpp");
//Start up the index manager
//indexManager = new IndexManager();
//indexManager.reset();
}
/*
* @see TestCase#tearDown()
@ -77,7 +74,9 @@ public class IndexManagerTest extends TestCase {
protected void tearDown() throws Exception {
super.tearDown();
//Delete project
//testProject.delete(true,monitor);
if (testProject.exists()){
testProject.delete(true,monitor);
}
}
public static Test suite() {
@ -144,7 +143,6 @@ public class IndexManagerTest extends TestCase {
//By doing this, we force the Index Manager to indexAll()
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.setEnabled(testProject,true);
Thread.sleep(15000);
IIndex ind = indexManager.getIndex(testProject.getFullPath(),true,true);
char[] prefix = "typeDecl/".toCharArray();
@ -171,5 +169,90 @@ public class IndexManagerTest extends TestCase {
}
}
public void testAddNewFileToIndex() throws Exception{
//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(15000);
//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);
//Add a new file to the project, give it some time to index
importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
Thread.sleep(10000);
ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/C/CDocumentManager/".toCharArray();
String [] entryResultModel ={"EntryResult: word=typeDecl/C/CDocumentManager/, refs={ 1 }"};
IEntryResult[] eresults =ind.queryEntries(prefix);
if (eresults.length != entryResultModel.length)
fail("Entry Result length different from model");
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultModel[i],eresults[i].toString());
}
}
public void testRemoveProjectFromIndex() throws Exception{
//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(15000);
//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);
//Delete the project
testProject.delete(true,monitor);
//See if the index is still there
ind = indexManager.getIndex(testProjectPath,true,true);
assertTrue("Index deleted",ind == null);
}
public void testRemoveFileFromIndex() throws Exception{
//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(15000);
//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);
//Add a new file to the project
importFile("DocumentManager.h","resources/indexer/DocumentManager.h");
Thread.sleep(10000);
//Do a "before" deletion comparison
ind = indexManager.getIndex(testProjectPath,true,true);
char[] prefix = "typeDecl/".toCharArray();
IEntryResult[] eresults = ind.queryEntries(prefix);
String [] entryResultBeforeModel ={"EntryResult: word=typeDecl/C/CDocumentManager/, refs={ 1 }", "EntryResult: word=typeDecl/C/Mail/, refs={ 2 }", "EntryResult: word=typeDecl/C/Unknown/, refs={ 2 }", "EntryResult: word=typeDecl/C/container/, refs={ 2 }", "EntryResult: word=typeDecl/C/first_class/, refs={ 2 }", "EntryResult: word=typeDecl/C/postcard/, refs={ 2 }"};
if (eresults.length != entryResultBeforeModel.length)
fail("Entry Result length different from model");
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultBeforeModel[i],eresults[i].toString());
}
//Delete mail.cpp from the project, give some time to remove index
IResource resourceHdl = testProject.findMember("mail.cpp") ;
resourceHdl.delete(true,monitor);
Thread.sleep(10000);
//See if the index is still there
ind = indexManager.getIndex(testProjectPath,true,true);
eresults = ind.queryEntries(prefix);
String [] entryResultAfterModel ={"EntryResult: word=typeDecl/C/CDocumentManager/, refs={ 1 }"};
if (eresults.length != entryResultAfterModel.length)
fail("Entry Result length different from model");
for (int i=0;i<eresults.length; i++)
{
assertEquals(entryResultAfterModel[i],eresults[i].toString());
}
}
}

View file

@ -0,0 +1,25 @@
#include "StdAfx.h"
#include "documentmanager.h"
CDocumentManager::CDocumentManager(void)
{
}
CDocumentManager::~CDocumentManager(void)
{
}
void CDocumentManager::addToControlMap(UINT threadID, IUnknown * theControl)
{
_controlMap.insert(MUL2IUnk_Pair(threadID,theControl));
}
void CDocumentManager::getControl(ULONG threadID, IUnknown ** theControl)
{
if (_controlMap.find(threadID) != _controlMap.end())
{
theControl = &_controlMap[threadID];
}
}

View file

@ -0,0 +1,20 @@
#pragma once
#include <map>
typedef map<ULONG, IUnknown *> MUL2IUnk;
typedef pair <ULONG, IUnknown *> MUL2IUnk_Pair;
class CDocumentManager
{
public:
CDocumentManager(void);
~CDocumentManager(void);
private:
MUL2IUnk _controlMap;
public:
void addToControlMap(UINT threadID, IUnknown * theControl);
void getControl(ULONG threadID, IUnknown ** theControl);
};