diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeloader')
-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() |