diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-04 07:11:21 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-04 07:11:21 (GMT) |
commit | c2ddba154e9a27599449d897d858d75d31e58c00 (patch) | |
tree | 30903770e34322c41986bd0661e645bd6e4a04ed | |
parent | 578b31d7c95f9de3a6cfe699d78ff401c708aeee (diff) | |
parent | b55c5cdbf2303fe27da1ab4c0ea8f6d38d222c16 (diff) | |
download | Qt-c2ddba154e9a27599449d897d858d75d31e58c00.zip Qt-c2ddba154e9a27599449d897d858d75d31e58c00.tar.gz Qt-c2ddba154e9a27599449d897d858d75d31e58c00.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | tests/auto/declarative/qfxloader/SetSourceComponent.qml | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/tst_qfxloader.cpp | 68 |
2 files changed, 70 insertions, 2 deletions
diff --git a/tests/auto/declarative/qfxloader/SetSourceComponent.qml b/tests/auto/declarative/qfxloader/SetSourceComponent.qml index c5dd7ff..1db56c4 100644 --- a/tests/auto/declarative/qfxloader/SetSourceComponent.qml +++ b/tests/auto/declarative/qfxloader/SetSourceComponent.qml @@ -1,6 +1,6 @@ import Qt 4.6 Item { - Component { id: Comp; Rectangle { width: 120; height: 60 } } - Loader { sourceComponent: Comp } + Component { id: comp; Rectangle { width: 100; height: 50 } } + Loader { sourceComponent: comp } } diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp index 38d06b8..9a8f8f1 100644 --- a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp +++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp @@ -53,6 +53,9 @@ public: private slots: void url(); void component(); + void clear(); + void urlToComponent(); + void componentToUrl(); void sizeLoaderToItem(); void sizeItemToLoader(); void noResize(); @@ -86,6 +89,8 @@ void tst_qfxloader::url() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + delete loader; } void tst_qfxloader::component() @@ -99,6 +104,69 @@ void tst_qfxloader::component() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + delete loader; +} + +void tst_qfxloader::clear() +{ + QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/")); + QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); + QVERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + loader->setSource(QUrl("")); + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); + + delete loader; +} + +void tst_qfxloader::urlToComponent() +{ + QmlComponent component(&engine, QByteArray("import Qt 4.6\n" + "Loader {\n" + " id: loader\n" + " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n" + " source: \"Rect120x60.qml\"\n" + " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" + "}" ) + , QUrl("file://" SRCDIR "/")); + QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); + QTest::qWait(1000); + QVERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + QCOMPARE(loader->width(), 10.0); + QCOMPARE(loader->height(), 10.0); + + delete loader; +} + +void tst_qfxloader::componentToUrl() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); + QVERIFY(item); + + QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(item->QGraphicsObject::children().at(1)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + loader->setSource(QUrl("file://" SRCDIR "/Rect120x60.qml")); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + QCOMPARE(loader->width(), 120.0); + QCOMPARE(loader->height(), 60.0); + + delete loader; } void tst_qfxloader::sizeLoaderToItem() |