forked from qt-creator/qt-creator
CppEditor: Tests: Auto configure projects for file/token tests.
Change-Id: Ic781fcbd3bdc1619db38e282ec7d4b9aecdb5bbc Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -116,8 +116,17 @@ private:
|
|||||||
CPPEditor *editor, const Actions &tokenActions);
|
CPPEditor *editor, const Actions &tokenActions);
|
||||||
|
|
||||||
static void undoAllChangesAndCloseAllEditors();
|
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<QPointer<ProjectExplorer::Project> > &projects);
|
||||||
|
|
||||||
|
static bool allProjectsConfigured;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TestActionsTestCase::allProjectsConfigured = false;
|
||||||
|
|
||||||
typedef TestActionsTestCase::Actions Actions;
|
typedef TestActionsTestCase::Actions Actions;
|
||||||
typedef TestActionsTestCase::ActionPointer ActionPointer;
|
typedef TestActionsTestCase::ActionPointer ActionPointer;
|
||||||
|
|
||||||
@@ -128,17 +137,27 @@ void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileAc
|
|||||||
|
|
||||||
// Collect files to process
|
// Collect files to process
|
||||||
QStringList filesToOpen;
|
QStringList filesToOpen;
|
||||||
|
QList<QPointer<ProjectExplorer::Project> > projects;
|
||||||
const QList<CppModelManagerInterface::ProjectInfo> projectInfos = mm->projectInfos();
|
const QList<CppModelManagerInterface::ProjectInfo> projectInfos = mm->projectInfos();
|
||||||
if (projectInfos.isEmpty())
|
if (projectInfos.isEmpty())
|
||||||
MSKIP_SINGLE("No project(s) loaded. Test operates only on loaded projects.");
|
MSKIP_SINGLE("No project(s) loaded. Test operates only on loaded projects.");
|
||||||
|
|
||||||
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
|
foreach (const CppModelManagerInterface::ProjectInfo &info, projectInfos) {
|
||||||
|
QPointer<ProjectExplorer::Project> project = info.project();
|
||||||
|
if (!projects.contains(project))
|
||||||
|
projects << project;
|
||||||
qDebug() << "Project" << info.project()->displayName() << "- files to process:"
|
qDebug() << "Project" << info.project()->displayName() << "- files to process:"
|
||||||
<< info.sourceFiles().size();
|
<< info.sourceFiles().size();
|
||||||
foreach (const QString &sourceFile, info.sourceFiles())
|
foreach (const QString &sourceFile, info.sourceFiles())
|
||||||
filesToOpen << sourceFile;
|
filesToOpen << sourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure all projects on first execution of this function (= very first test)
|
||||||
|
if (!TestActionsTestCase::allProjectsConfigured) {
|
||||||
|
configureAllProjects(projects);
|
||||||
|
TestActionsTestCase::allProjectsConfigured = true;
|
||||||
|
}
|
||||||
|
|
||||||
qSort(filesToOpen);
|
qSort(filesToOpen);
|
||||||
|
|
||||||
// Process all files from the projects
|
// Process all files from the projects
|
||||||
@@ -288,6 +307,15 @@ void TestActionsTestCase::undoAllChangesAndCloseAllEditors()
|
|||||||
QCOMPARE(em->openedEditors().size(), 0);
|
QCOMPARE(em->openedEditors().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestActionsTestCase::configureAllProjects(const QList<QPointer<ProjectExplorer::Project> >
|
||||||
|
&projects)
|
||||||
|
{
|
||||||
|
foreach (const QPointer<ProjectExplorer::Project> &project, projects) {
|
||||||
|
qDebug() << "*** Configuring project" << project->displayName();
|
||||||
|
project->configureAsExampleProject(QStringList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class NoOpTokenAction : public TestActionsTestCase::AbstractAction
|
class NoOpTokenAction : public TestActionsTestCase::AbstractAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user