summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager_test.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2014-12-09 17:09:45 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2014-12-19 10:24:55 +0100
commitb94b7b3ee6cbec6df86ebb959d788b9b09933c7e (patch)
tree1c621c3ca53e4426d6d605550d9b920a39730ba0 /src/plugins/cpptools/cppmodelmanager_test.cpp
parentef403a4515aa93272f6e5155b2897ddd02fb128e (diff)
downloadqt-creator-b94b7b3ee6cbec6df86ebb959d788b9b09933c7e.tar.gz
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>
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager_test.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp64
1 files changed, 12 insertions, 52 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index b160251875..2f176dd433 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -49,9 +49,10 @@
#include <QTemporaryDir>
#include <QtTest>
+using namespace CppTools;
using namespace CppTools::Internal;
+using namespace CppTools::Tests;
using namespace ProjectExplorer;
-using namespace CppTools;
typedef CPlusPlus::Document Document;
@@ -112,46 +113,6 @@ public:
QStringList projectFiles;
};
-/// Open and configure given project as example project and remove
-/// generated *.user file on destruction.
-///
-/// Requirement: No *.user file exists for the project.
-class ExampleProjectConfigurator
-{
-public:
- ExampleProjectConfigurator(const QString &projectFile)
- {
- const QString projectUserFile = projectFile + _(".user");
- QVERIFY(!QFileInfo::exists(projectUserFile));
-
- // Open project
- QString errorOpeningProject;
- m_project = ProjectExplorerPlugin::openProject(projectFile, &errorOpeningProject);
- QVERIFY(m_project);
- QVERIFY(errorOpeningProject.isEmpty());
-
- // Configure project
- m_project->configureAsExampleProject(QStringList());
-
- m_fileToRemove = projectUserFile;
- }
-
- ~ExampleProjectConfigurator()
- {
- QVERIFY(!m_fileToRemove.isEmpty());
- QVERIFY(QFile::remove(m_fileToRemove));
- }
-
- Project *project() const
- {
- return m_project;
- }
-
-private:
- Project *m_project;
- QString m_fileToRemove;
-};
-
/// Changes a file on the disk and restores its original contents on destruction
class FileChangerAndRestorer
{
@@ -657,16 +618,19 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
/// is added for the ui_* file.
/// Check: (2) The CppSourceProcessor can successfully resolve the ui_* file
/// though it might not be actually generated in the build dir.
+///
+
void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
{
- ModelManagerTestHelper helper;
+ VerifyCleanCppModelManager verify;
- MyTestDataDir testDataDirectory(_("testdata_guiproject1"));
- const QString projectFile = testDataDirectory.file(_("testdata_guiproject1.pro"));
+ TemporaryCopiedDir temporaryDir(MyTestDataDir(QLatin1String("testdata_guiproject1")).path());
+ QVERIFY(temporaryDir.isValid());
+ const QString projectFile = temporaryDir.absolutePath("testdata_guiproject1.pro");
- // Open project with *.ui file
- ExampleProjectConfigurator exampleProjectConfigurator(projectFile);
- Project *project = exampleProjectConfigurator.project();
+ ProjectOpenerAndCloser projects(/*waitForFinishedGcOnDestruction=*/ true);
+ ProjectInfo projectInfo = projects.open(projectFile, /*configureAsExampleProject=*/ true);
+ QVERIFY(projectInfo.isValid());
// Check working copy.
// An AbstractEditorSupport object should have been added for the ui_* file.
@@ -688,7 +652,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
// Check CppSourceProcessor / includes.
// The CppSourceProcessor is expected to find the ui_* file in the working copy.
- const QString fileIncludingTheUiFile = testDataDirectory.file(_("mainwindow.cpp"));
+ const QString fileIncludingTheUiFile = temporaryDir.absolutePath("mainwindow.cpp");
while (!mm->snapshot().document(fileIncludingTheUiFile))
QCoreApplication::processEvents();
@@ -699,10 +663,6 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
QCOMPARE(includedFiles.size(), 2);
QCOMPARE(QFileInfo(includedFiles.at(0)).fileName(), _("mainwindow.h"));
QCOMPARE(QFileInfo(includedFiles.at(1)).fileName(), _("ui_mainwindow.h"));
-
- // Close Project
- SessionManager::removeProject(project);
- helper.waitForFinishedGc();
}
/// QTCREATORBUG-9828: Locator shows symbols of closed files