Commit c5c57dca authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

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() { ...@@ -363,16 +363,18 @@ VerifyCleanCppModelManager::~VerifyCleanCppModelManager() {
#define RETURN_FALSE_IF_NOT(check) if (!(check)) return false; #define RETURN_FALSE_IF_NOT(check) if (!(check)) return false;
bool VerifyCleanCppModelManager::isClean() bool VerifyCleanCppModelManager::isClean(bool testOnlyForCleanedProjects)
{ {
CppModelManager *mm = CppModelManager::instance(); CppModelManager *mm = CppModelManager::instance();
RETURN_FALSE_IF_NOT(mm->projectInfos().isEmpty()); RETURN_FALSE_IF_NOT(mm->projectInfos().isEmpty());
RETURN_FALSE_IF_NOT(mm->headerPaths().isEmpty()); RETURN_FALSE_IF_NOT(mm->headerPaths().isEmpty());
RETURN_FALSE_IF_NOT(mm->definedMacros().isEmpty()); RETURN_FALSE_IF_NOT(mm->definedMacros().isEmpty());
RETURN_FALSE_IF_NOT(mm->projectFiles().isEmpty()); RETURN_FALSE_IF_NOT(mm->projectFiles().isEmpty());
RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty()); if (!testOnlyForCleanedProjects) {
RETURN_FALSE_IF_NOT(mm->workingCopy().size() == 1); RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty());
RETURN_FALSE_IF_NOT(mm->workingCopy().contains(mm->configurationFileName())); RETURN_FALSE_IF_NOT(mm->workingCopy().size() == 1);
RETURN_FALSE_IF_NOT(mm->workingCopy().contains(mm->configurationFileName()));
}
return true; return true;
} }
......
...@@ -161,7 +161,7 @@ class CPPTOOLS_EXPORT VerifyCleanCppModelManager ...@@ -161,7 +161,7 @@ class CPPTOOLS_EXPORT VerifyCleanCppModelManager
public: public:
VerifyCleanCppModelManager(); VerifyCleanCppModelManager();
~VerifyCleanCppModelManager(); ~VerifyCleanCppModelManager();
static bool isClean(); static bool isClean(bool testCleanedProjects = true);
}; };
class FileWriterAndRemover class FileWriterAndRemover
......
...@@ -54,8 +54,10 @@ TestProject::~TestProject() ...@@ -54,8 +54,10 @@ TestProject::~TestProject()
{ {
} }
ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) : ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent,
QObject(parent) bool testOnlyForCleanedProjects)
: QObject(parent)
, m_testOnlyForCleanedProjects(testOnlyForCleanedProjects)
{ {
CppModelManager *mm = CppModelManager::instance(); CppModelManager *mm = CppModelManager::instance();
...@@ -69,13 +71,13 @@ ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) : ...@@ -69,13 +71,13 @@ ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) :
this, &ModelManagerTestHelper::gcFinished); this, &ModelManagerTestHelper::gcFinished);
cleanup(); cleanup();
QVERIFY(Tests::VerifyCleanCppModelManager::isClean()); QVERIFY(Tests::VerifyCleanCppModelManager::isClean(m_testOnlyForCleanedProjects));
} }
ModelManagerTestHelper::~ModelManagerTestHelper() ModelManagerTestHelper::~ModelManagerTestHelper()
{ {
cleanup(); cleanup();
QVERIFY(Tests::VerifyCleanCppModelManager::isClean()); QVERIFY(Tests::VerifyCleanCppModelManager::isClean(m_testOnlyForCleanedProjects));
} }
void ModelManagerTestHelper::cleanup() void ModelManagerTestHelper::cleanup()
......
...@@ -75,7 +75,8 @@ class CPPTOOLS_EXPORT ModelManagerTestHelper: public QObject ...@@ -75,7 +75,8 @@ class CPPTOOLS_EXPORT ModelManagerTestHelper: public QObject
public: public:
typedef ProjectExplorer::Project Project; typedef ProjectExplorer::Project Project;
explicit ModelManagerTestHelper(QObject *parent = 0); explicit ModelManagerTestHelper(QObject *parent = 0,
bool testOnlyForCleanedProjects = true);
~ModelManagerTestHelper(); ~ModelManagerTestHelper();
void cleanup(); void cleanup();
...@@ -99,6 +100,7 @@ public slots: ...@@ -99,6 +100,7 @@ public slots:
private: private:
bool m_gcFinished; bool m_gcFinished;
bool m_refreshHappened; bool m_refreshHappened;
bool m_testOnlyForCleanedProjects;
QSet<QString> m_lastRefreshedSourceFiles; 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