Commit fa7ab13f authored by Erik Verbruggen's avatar Erik Verbruggen

C++: test for walking includes in frameworks.

Change-Id: Id31ce6b40d72351cfaefa5035469b87662526853
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent fcf58697
......@@ -28,6 +28,7 @@
****************************************************************************/
#include "cpptoolsplugin.h"
#include "CppDocument.h"
#include "cppmodelmanager.h"
#include "modelmanagertesthelper.h"
......@@ -36,6 +37,7 @@
using namespace CppTools::Internal;
typedef CPlusPlus::Document Document;
typedef CPlusPlus::CppModelManagerInterface::ProjectInfo ProjectInfo;
typedef CPlusPlus::CppModelManagerInterface::ProjectPart ProjectPart;
typedef ProjectExplorer::Project Project;
......@@ -61,6 +63,11 @@ QString testFrameworksDir(bool cleaned = true)
{
return testDataDir(QLatin1String("frameworks"), cleaned);
}
QString testSource(const QString &fileName)
{
return testDataDir(QLatin1String("sources")) + fileName;
}
} // anonymous namespace
void CppToolsPlugin::test_modelmanager_paths()
......@@ -90,3 +97,42 @@ void CppToolsPlugin::test_modelmanager_paths()
QCOMPARE(frameworkPaths.size(), 1);
QVERIFY(frameworkPaths.contains(testFrameworksDir()));
}
void CppToolsPlugin::test_modelmanager_framework_headers()
{
ModelManagerTestHelper helper;
CppModelManager *mm = CppModelManager::instance();
Project *project = helper.createProject(QLatin1String("test_modelmanager_framework_headers"));
ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project);
ProjectPart::Ptr part(new ProjectPart);
pi.appendProjectPart(part);
part->language = ProjectPart::CXX;
part->qtVersion = ProjectPart::Qt5;
part->defines = QByteArray("#define OH_BEHAVE -1\n");
part->includePaths << testIncludeDir();
part->frameworkPaths << testFrameworksDir();
part->sourceFiles << testSource(QLatin1String("test_modelmanager_framework_headers.cpp"));
mm->updateProjectInfo(pi);
mm->updateSourceFiles(part->sourceFiles).waitForFinished();
QCoreApplication::processEvents();
QVERIFY(mm->snapshot().contains(part->sourceFiles.first()));
Document::Ptr doc = mm->snapshot().document(part->sourceFiles.first());
QVERIFY(!doc.isNull());
CPlusPlus::Namespace *ns = doc->globalNamespace();
QVERIFY(ns);
QVERIFY(ns->memberCount() > 0);
for (unsigned i = 0, ei = ns->memberCount(); i < ei; ++i) {
CPlusPlus::Symbol *s = ns->memberAt(i);
QVERIFY(s);
QVERIFY(s->name());
const CPlusPlus::Identifier *id = s->name()->asNameId();
QVERIFY(id);
QByteArray chars = id->chars();
QVERIFY(chars.startsWith("success"));
}
}
......@@ -115,6 +115,7 @@ private slots:
void test_completion_instantiate_nested_of_nested_class_when_enclosing_is_template();
void test_modelmanager_paths();
void test_modelmanager_framework_headers();
private:
void test_completion();
......
Versions/A/Frameworks
\ No newline at end of file
Versions/A/Headers
\ No newline at end of file
#ifndef Nested_h
#define Nested_h
#include "IncorrectVersion.h"
#endif // Nested_h
#ifndef MyHeader_h
#define MyHeader_h
#include <Nested/Nested.h>
#endif // MyHeader_h
#ifndef HEADER_H
#define HEADER_H
#endif // HEADER_H
#include <My/MyHeader.h>
#ifndef MyHeader_h
bool failure_MyHeader_not_included;
#endif
#ifndef Nested_h
bool failure_Nested_header_not_included;
#endif
#ifdef IncorrectVersion_h
bool failure_Incorrect_version_of_nested_header_included;
#endif
#ifdef CorrectVersion_h
bool success_is_the_only_option;
#endif
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