diff options
Diffstat (limited to 'src/plugins/cpptools/cpptoolstestcase.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolstestcase.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp index 0102384aa8..271410bf4c 100644 --- a/src/plugins/cpptools/cpptoolstestcase.cpp +++ b/src/plugins/cpptools/cpptoolstestcase.cpp @@ -30,6 +30,8 @@ #include "cpptoolstestcase.h" +#include "cppworkingcopy.h" + #include <coreplugin/editormanager/editormanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/session.h> @@ -214,18 +216,30 @@ bool TestCase::writeFile(const QString &filePath, const QByteArray &contents) return true; } -ProjectOpenerAndCloser::ProjectOpenerAndCloser() +ProjectOpenerAndCloser::ProjectOpenerAndCloser(bool waitForFinishedGcOnDestruction) + : m_waitForFinishedGcOnDestruction(waitForFinishedGcOnDestruction) + , m_gcFinished(false) { QVERIFY(!SessionManager::hasProjects()); + if (m_waitForFinishedGcOnDestruction) { + CppModelManager *mm = CppModelManager::instance(); + connect(mm, &CppModelManager::gcFinished, this, &ProjectOpenerAndCloser::onGcFinished); + } } ProjectOpenerAndCloser::~ProjectOpenerAndCloser() { foreach (Project *project, m_openProjects) ProjectExplorerPlugin::unloadProject(project); + + if (m_waitForFinishedGcOnDestruction) { + m_gcFinished = false; + while (!m_gcFinished) + QCoreApplication::processEvents(); + } } -ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile) +ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool configureAsExampleProject) { QString error; Project *project = ProjectExplorerPlugin::openProject(projectFile, &error); @@ -235,12 +249,20 @@ ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile) return ProjectInfo(); m_openProjects.append(project); + if (configureAsExampleProject) + project->configureAsExampleProject(QStringList()); + if (TestCase::waitUntilCppModelManagerIsAwareOf(project)) return CppModelManager::instance()->projectInfo(project); return ProjectInfo(); } +void ProjectOpenerAndCloser::onGcFinished() +{ + m_gcFinished = true; +} + TemporaryCopiedDir::TemporaryCopiedDir(const QString &sourceDirPath) : m_temporaryDir(QDir::tempPath() + QLatin1String("/qtcreator-tests-XXXXXX")) , m_isValid(m_temporaryDir.isValid()) @@ -301,5 +323,18 @@ IAssistProposalScopedPointer::~IAssistProposalScopedPointer() delete d->model(); } +void VerifyCleanCppModelManager::verify() +{ + CppModelManager *mm = CppModelManager::instance(); + QVERIFY(mm); + QVERIFY(mm->projectInfos().isEmpty()); + QVERIFY(mm->headerPaths().isEmpty()); + QVERIFY(mm->definedMacros().isEmpty()); + QVERIFY(mm->projectFiles().isEmpty()); + QVERIFY(mm->snapshot().isEmpty()); + QCOMPARE(mm->workingCopy().size(), 1); + QVERIFY(mm->workingCopy().contains(mm->configurationFileName())); +} + } // namespace Tests } // namespace CppTools |