summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-24 16:30:46 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:05 -0300
commit2236d656664f6a07e52ffde474b5c7d6e5b78467 (patch)
treeba1be453eb0cf05585c35cd28bf9eb222515bd61
parentfa32db5bfb6247407aa25af0d30b5c939cc8e04d (diff)
Created test for namespace resolution name.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>, Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--tests/testtemplates.cpp43
-rw-r--r--tests/testtemplates.h1
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/testtemplates.cpp b/tests/testtemplates.cpp
index d52eed15..19bc32ec 100644
--- a/tests/testtemplates.cpp
+++ b/tests/testtemplates.cpp
@@ -23,8 +23,51 @@
#include "testtemplates.h"
#include <QtTest/QTest>
+#include <QTemporaryFile>
#include "testutil.h"
+void TestTemplates::testTemplateWithNamespace()
+{
+ const char cppCode[] = "\
+ struct Url {\
+ void name();\
+ };\
+ namespace Internet {\
+ struct Url{};\
+ struct Bookmarks {\
+ QList<Url> list();\
+ };\
+ }";
+ const char xmlCode0[] = "\
+ <typesystem package='Pakcage.Network'>\
+ <value-type name='Url' />\
+ </typesystem>";
+
+ QTemporaryFile file;
+ QVERIFY(file.open());
+ file.write(xmlCode0);
+ file.close();
+
+ QString xmlCode1 = QString("\
+ <typesystem package='Package.Internet'>\
+ <load-typesystem name='%1' generate='no'/>\
+ <container-type name='QList' type='list'/> \
+ <namespace-type name='Internet' generate='no' />\
+ <value-type name='Internet::Url'/>\
+ <value-type name='Internet::Bookmarks'/>\
+ </typesystem>").arg(file.fileName());
+
+ TestUtil t(cppCode, qPrintable(xmlCode1), false);
+ AbstractMetaClassList classes = t.builder()->classes();
+
+ AbstractMetaClass* classB = classes.findClass("Bookmarks");
+ QVERIFY(classB);
+ const AbstractMetaFunction* func = classB->findFunction("list");
+ AbstractMetaType* funcType = func->type();
+ QVERIFY(funcType);
+ QCOMPARE(funcType->cppSignature(), QString("QList<Internet::Url >"));
+}
+
void TestTemplates::testTemplateOnContainers()
{
const char cppCode[] = "\
diff --git a/tests/testtemplates.h b/tests/testtemplates.h
index 5c6e85a0..b04002a7 100644
--- a/tests/testtemplates.h
+++ b/tests/testtemplates.h
@@ -31,6 +31,7 @@ class TestTemplates : public QObject
Q_OBJECT
private slots:
void testTemplateOnContainers();
+ void testTemplateWithNamespace();
};
#endif