diff options
Diffstat (limited to 'tests/auto/declarative')
3 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml new file mode 100644 index 00000000..9ba0d612 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/MyComponentType.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +Item { + property int test: 11 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml new file mode 100644 index 00000000..532bc319 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlComponentType.qml @@ -0,0 +1,4 @@ +import QtQuick 1.0 +import Test 1.0 + +MyComponentType {} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index edbfeeb8..5dbcf456 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -99,6 +99,7 @@ private slots: void assignLiteralToVariant(); void customParserTypes(); void rootAsQmlComponent(); + void qmlComponentType(); void inlineQmlComponents(); void idProperty(); void autoNotifyConnection(); @@ -628,6 +629,16 @@ void tst_qdeclarativelanguage::rootAsQmlComponent() QCOMPARE(object->getChildren()->count(), 2); } +// Tests that types can be specified from a QML only component +void tst_qdeclarativelanguage::qmlComponentType() +{ + QDeclarativeComponent component(&engine, testFileUrl("qmlComponentType.qml")); + VERIFY_ERRORS(0); + QObject *object = qobject_cast<QObject *>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->property("test"), QVariant(11)); +} + // Tests that components can be specified inline void tst_qdeclarativelanguage::inlineQmlComponents() { @@ -1965,6 +1976,8 @@ void tst_qdeclarativelanguage::initTestCase() { QDeclarativeDataTest::initTestCase(); registerTypes(); + // Registered here because it uses testFileUrl + qmlRegisterType(testFileUrl("MyComponentType.qml"), "Test", 1, 0, "MyComponentType"); // Registering the TestType class in other modules should have no adverse effects qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test"); |