C++: test for walking includes in frameworks.

Change-Id: Id31ce6b40d72351cfaefa5035469b87662526853
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Erik Verbruggen
2012-12-20 15:53:12 +01:00
parent fcf586974f
commit fa7ab13f30
14 changed files with 101 additions and 0 deletions
@@ -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"));
}
}
+1
View File
@@ -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();
+1
View File
@@ -0,0 +1 @@
Versions/A/Frameworks
+1
View File
@@ -0,0 +1 @@
Versions/A/Headers
@@ -0,0 +1 @@
Versions/Current/Headers
@@ -0,0 +1,4 @@
#ifndef IncorrectVersion_h
#define IncorrectVersion_h
#endif // IncorrectVersion_h
@@ -0,0 +1,6 @@
#ifndef Nested_h
#define Nested_h
#include "IncorrectVersion.h"
#endif // Nested_h
@@ -0,0 +1,4 @@
#ifndef CorrectVersion_h
#define CorrectVersion_h
#endif // CorrectVersion_h
@@ -0,0 +1,6 @@
#ifndef Nested_h
#define Nested_h
#include "CorrectVersion.h"
#endif // Nested_h
@@ -0,0 +1,6 @@
#ifndef MyHeader_h
#define MyHeader_h
#include <Nested/Nested.h>
#endif // MyHeader_h
@@ -0,0 +1 @@
A
+4
View File
@@ -0,0 +1,4 @@
#ifndef HEADER_H
#define HEADER_H
#endif // HEADER_H
@@ -0,0 +1,19 @@
#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