diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-20 00:05:39 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-20 00:05:39 (GMT) |
commit | 1b80a6bc28cb49b9f6e1a2132d929819924aa604 (patch) | |
tree | d0de1b7639a4b9259af5b97488e339f604f83e46 /tests/auto/declarative | |
parent | 18cbadd8edd233b843d04441a05788264da0a67b (diff) | |
download | Qt-1b80a6bc28cb49b9f6e1a2132d929819924aa604.zip Qt-1b80a6bc28cb49b9f6e1a2132d929819924aa604.tar.gz Qt-1b80a6bc28cb49b9f6e1a2132d929819924aa604.tar.bz2 |
Allow Loader sourceComponent to be set to undefeined.
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp | 20 |
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml index 1db56c4..f600e85 100644 --- a/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml +++ b/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml @@ -1,6 +1,9 @@ import Qt 4.6 Item { + function clear() { + loader.sourceComponent = undefined + } Component { id: comp; Rectangle { width: 100; height: 50 } } - Loader { sourceComponent: comp } + Loader { id: loader; sourceComponent: comp } } diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 1b17a56..a5f75bd 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -198,6 +198,26 @@ void tst_QDeclarativeLoader::clear() delete item; } + { + QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); + + QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + QMetaObject::invokeMethod(item, "clear"); + + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->status(), QDeclarativeLoader::Null); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); + + delete item; + } } void tst_QDeclarativeLoader::urlToComponent() |