forked from qt-creator/qt-creator
CppTools: Fix test_modelmanager_extraeditorsupport_uiFiles
The test was broken since the QmakeProject was changed to work asynchronously. FAIL! : CppTools::Internal::CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles() Compared values are not the same Actual (workingCopy.size()): 1 Expected (2) : 2 Change-Id: I6f7d05fb70af3def5fc371a9783b606309686e32 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
ef403a4515
commit
b94b7b3ee6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user