aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@rim.com>2013-01-24 12:13:57 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-18 19:46:02 +0100
commit99ad368cf810723643ae76bba6a1adba3321b18f (patch)
treee87c708650931c8863a1affed20befd1578aff35 /tests/auto/qml/qqmllanguage
parentd0491c87a9f0f2dadc9ef0e0a267b8c241c08b41 (diff)
Add qmlRegisterType for Composite Types
This is equivalent functionality to registering a composite type in a qmldir file, a type name in a versioned module is associated with a given file. This function now allows that to be done easily from C++. Change-Id: I1cf44b92c3ad7fee593f4f84773c35b56253e628 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage')
-rw-r--r--tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml3
-rw-r--r--tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml3
-rw-r--r--tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml3
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp19
6 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt
new file mode 100644
index 0000000000..7a75447a62
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.errors.txt
@@ -0,0 +1,2 @@
+3:1:Type RegisteredCompositeType2 unavailable
+-1:-1:File not found
diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml
new file mode 100644
index 0000000000..915a6138d9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.1.qml
@@ -0,0 +1,3 @@
+import Test 1.0
+
+RegisteredCompositeType2 {}
diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt
new file mode 100644
index 0000000000..0272619404
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.errors.txt
@@ -0,0 +1,2 @@
+3:1:Type RegisteredCompositeType3 unavailable
+1:1:Expected a qualified name id
diff --git a/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml
new file mode 100644
index 0000000000..43d7f3ee95
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/badCompositeRegistration.2.qml
@@ -0,0 +1,3 @@
+import Test 1.0
+
+RegisteredCompositeType3 {}
diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml
new file mode 100644
index 0000000000..f633a14fa7
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeType.qml
@@ -0,0 +1,3 @@
+import Test 1.0
+
+RegisteredCompositeType {}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 222548da29..3121d10265 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -139,6 +139,7 @@ private slots:
void registrationOrder();
void readonly();
void receivers();
+ void registeredCompositeType();
void basicRemote_data();
void basicRemote();
@@ -467,6 +468,9 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
+
+ QTest::newRow("badCompositeRegistration.1") << "badCompositeRegistration.1.qml" << "badCompositeRegistration.1.errors.txt" << false;
+ QTest::newRow("badCompositeRegistration.2") << "badCompositeRegistration.2.qml" << "badCompositeRegistration.2.errors.txt" << false;
}
@@ -2771,6 +2775,10 @@ void tst_qqmllanguage::initTestCase()
QQmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
registerTypes();
+ // Registered here because it uses testFileUrl
+ qmlRegisterType(testFileUrl("CompositeType.qml"), "Test", 1, 0, "RegisteredCompositeType");
+ qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2");
+ qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3");
// Registering the TestType class in other modules should have no adverse effects
qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test");
@@ -2915,6 +2923,17 @@ void tst_qqmllanguage::receivers()
delete o;
}
+void tst_qqmllanguage::registeredCompositeType()
+{
+ QQmlComponent component(&engine, testFileUrl("registeredCompositeType.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ delete o;
+}
+
// QTBUG-18268
void tst_qqmllanguage::remoteLoadCrash()
{