Commit c5c57dca authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Tests: Allow to check only project relevant state

Needed for ClangCodeModel.

If editors are open, the global snapshot and working copy will not be
empty.

Change-Id: I0d1bab8e082a7f41630c7b1b78febe2da009298b
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 94258120
......@@ -363,16 +363,18 @@ VerifyCleanCppModelManager::~VerifyCleanCppModelManager() {
#define RETURN_FALSE_IF_NOT(check) if (!(check)) return false;
bool VerifyCleanCppModelManager::isClean()
bool VerifyCleanCppModelManager::isClean(bool testOnlyForCleanedProjects)
{
CppModelManager *mm = CppModelManager::instance();
RETURN_FALSE_IF_NOT(mm->projectInfos().isEmpty());
RETURN_FALSE_IF_NOT(mm->headerPaths().isEmpty());
RETURN_FALSE_IF_NOT(mm->definedMacros().isEmpty());
RETURN_FALSE_IF_NOT(mm->projectFiles().isEmpty());
RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty());
RETURN_FALSE_IF_NOT(mm->workingCopy().size() == 1);
RETURN_FALSE_IF_NOT(mm->workingCopy().contains(mm->configurationFileName()));
if (!testOnlyForCleanedProjects) {
RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty());
RETURN_FALSE_IF_NOT(mm->workingCopy().size() == 1);
RETURN_FALSE_IF_NOT(mm->workingCopy().contains(mm->configurationFileName()));
}
return true;
}
......
......@@ -161,7 +161,7 @@ class CPPTOOLS_EXPORT VerifyCleanCppModelManager
public:
VerifyCleanCppModelManager();
~VerifyCleanCppModelManager();
static bool isClean();
static bool isClean(bool testCleanedProjects = true);
};
class FileWriterAndRemover
......
......@@ -54,8 +54,10 @@ TestProject::~TestProject()
{
}
ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) :
QObject(parent)
ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent,
bool testOnlyForCleanedProjects)
: QObject(parent)
, m_testOnlyForCleanedProjects(testOnlyForCleanedProjects)
{
CppModelManager *mm = CppModelManager::instance();
......@@ -69,13 +71,13 @@ ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) :
this, &ModelManagerTestHelper::gcFinished);
cleanup();
QVERIFY(Tests::VerifyCleanCppModelManager::isClean());
QVERIFY(Tests::VerifyCleanCppModelManager::isClean(m_testOnlyForCleanedProjects));
}
ModelManagerTestHelper::~ModelManagerTestHelper()
{
cleanup();
QVERIFY(Tests::VerifyCleanCppModelManager::isClean());
QVERIFY(Tests::VerifyCleanCppModelManager::isClean(m_testOnlyForCleanedProjects));
}
void ModelManagerTestHelper::cleanup()
......
......@@ -75,7 +75,8 @@ class CPPTOOLS_EXPORT ModelManagerTestHelper: public QObject
public:
typedef ProjectExplorer::Project Project;
explicit ModelManagerTestHelper(QObject *parent = 0);
explicit ModelManagerTestHelper(QObject *parent = 0,
bool testOnlyForCleanedProjects = true);
~ModelManagerTestHelper();
void cleanup();
......@@ -99,6 +100,7 @@ public slots:
private:
bool m_gcFinished;
bool m_refreshHappened;
bool m_testOnlyForCleanedProjects;
QSet<QString> m_lastRefreshedSourceFiles;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment