diff options
author | Alan Alpert <aalpert@rim.com> | 2013-01-24 12:13:57 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-18 19:46:02 +0100 |
commit | 99ad368cf810723643ae76bba6a1adba3321b18f (patch) | |
tree | e87c708650931c8863a1affed20befd1578aff35 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | d0491c87a9f0f2dadc9ef0e0a267b8c241c08b41 (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/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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() { |