Commit 7051f49a authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

CppEditor: Tests: Auto configure projects for file/token tests.



Change-Id: Ic781fcbd3bdc1619db38e282ec7d4b9aecdb5bbc
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 98a58c9d
......@@ -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<QPointer<ProjectExplorer::Project> > &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<QPointer<ProjectExplorer::Project> > projects;
const QList<CppModelManagerInterface::ProjectInfo> 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<ProjectExplorer::Project> 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<QPointer<ProjectExplorer::Project> >
&projects)
{
foreach (const QPointer<ProjectExplorer::Project> &project, projects) {
qDebug() << "*** Configuring project" << project->displayName();
project->configureAsExampleProject(QStringList());
}
}
class NoOpTokenAction : public TestActionsTestCase::AbstractAction
{
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment