diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp index 0877dc092ef..e4c74eb2aca 100644 --- a/src/plugins/cppeditor/fileandtokenactions_test.cpp +++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp @@ -116,8 +116,17 @@ private: CPPEditor *editor, const Actions &tokenActions); static void undoAllChangesAndCloseAllEditors(); + + /// This function expects: + /// (1) Only Qt4 projects are loaded (qmake in PATH should point to Qt4/bin). + /// (2) No *.pro.user file exists for the projects. + static void configureAllProjects(const QList > &projects); + + static bool allProjectsConfigured; }; +bool TestActionsTestCase::allProjectsConfigured = false; + typedef TestActionsTestCase::Actions Actions; typedef TestActionsTestCase::ActionPointer ActionPointer; @@ -128,17 +137,27 @@ void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileAc // Collect files to process QStringList filesToOpen; + QList > projects; const QList projectInfos = mm->projectInfos(); if (projectInfos.isEmpty()) MSKIP_SINGLE("No project(s) loaded. Test operates only on loaded projects."); foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) { + QPointer project = info.project(); + if (!projects.contains(project)) + projects << project; qDebug() << "Project" << info.project()->displayName() << "- files to process:" << info.sourceFiles().size(); foreach (const QString &sourceFile, info.sourceFiles()) filesToOpen << sourceFile; } + // Configure all projects on first execution of this function (= very first test) + if (!TestActionsTestCase::allProjectsConfigured) { + configureAllProjects(projects); + TestActionsTestCase::allProjectsConfigured = true; + } + qSort(filesToOpen); // Process all files from the projects @@ -288,6 +307,15 @@ void TestActionsTestCase::undoAllChangesAndCloseAllEditors() QCOMPARE(em->openedEditors().size(), 0); } +void TestActionsTestCase::configureAllProjects(const QList > + &projects) +{ + foreach (const QPointer &project, projects) { + qDebug() << "*** Configuring project" << project->displayName(); + project->configureAsExampleProject(QStringList()); + } +} + class NoOpTokenAction : public TestActionsTestCase::AbstractAction { public: