CppEditor/CppTools: Introduce Test{Case,Document}

Move common functionality of the 12 test classes into base classes.

Change-Id: If64d3cec876807ac6f991151189860a99b8ff4ca
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2013-12-16 16:02:45 +01:00
parent 5aa8a63f90
commit 5c8df5fa4e
25 changed files with 814 additions and 659 deletions

View File

@@ -31,6 +31,7 @@
#include "builtinindexingsupport.h"
#include "cppmodelmanager.h"
#include "cpptoolstestcase.h"
#include "searchsymbols.h"
#include <coreplugin/testdatadir.h>
@@ -43,14 +44,7 @@ using namespace CppTools::Internal;
namespace {
class MyTestDataDir : public Core::Internal::Tests::TestDataDir
{
public:
MyTestDataDir(const QString &testDataDirectory)
: TestDataDir(QLatin1String(SRCDIR "/../../../tests/cppsymbolsearcher/")
+ testDataDirectory)
{}
};
QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/")
class ResultData
{
@@ -90,21 +84,16 @@ public:
typedef ResultData::ResultDataList ResultDataList;
class SymbolSearcherTest
class SymbolSearcherTest : public CppTools::Tests::TestCase
{
public:
/// Takes no ownership of indexingSupportToUse
SymbolSearcherTest(const QString &testFile, CppIndexingSupport *indexingSupportToUse)
: m_modelManager(CppModelManager::instance())
, m_indexingSupportToUse(indexingSupportToUse)
: m_indexingSupportToUse(indexingSupportToUse)
, m_testFile(testFile)
{
QVERIFY(m_indexingSupportToUse);
QVERIFY(m_modelManager->snapshot().isEmpty());
m_modelManager->updateSourceFiles(QStringList(m_testFile)).waitForFinished();
QCoreApplication::processEvents();
QVERIFY(m_modelManager->snapshot().contains(m_testFile));
QVERIFY(parseFiles(m_testFile));
m_indexingSupportToRestore = m_modelManager->indexingSupport();
m_modelManager->setIndexingSupport(m_indexingSupportToUse);
}
@@ -124,12 +113,9 @@ public:
~SymbolSearcherTest()
{
m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
m_modelManager->GC();
QVERIFY(m_modelManager->snapshot().isEmpty());
}
private:
CppModelManager *m_modelManager;
CppIndexingSupport *m_indexingSupportToRestore;
CppIndexingSupport *m_indexingSupportToUse;
const QString m_testFile;