diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-09 05:14:21 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-09 05:14:21 (GMT) |
commit | 6878a0b7c507d21366cacee0a09bafeb81726d82 (patch) | |
tree | 457c32d1ec3044efe99c5950bce1cca6db41e41a /tests/auto/declarative | |
parent | 7731e5f7d33d3ec251299c7651e777d7e0054573 (diff) | |
download | Qt-6878a0b7c507d21366cacee0a09bafeb81726d82.zip Qt-6878a0b7c507d21366cacee0a09bafeb81726d82.tar.gz Qt-6878a0b7c507d21366cacee0a09bafeb81726d82.tar.bz2 |
Move ComponentInstance functionality into Loader
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qfxloader/NoResize.qml | 7 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/Rect120x60.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/SetSourceComponent.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/SizeToItem.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/SizeToLoader.qml | 7 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/qfxloader.pro | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qfxloader/tst_qfxloader.cpp | 103 |
7 files changed, 140 insertions, 0 deletions
diff --git a/tests/auto/declarative/qfxloader/NoResize.qml b/tests/auto/declarative/qfxloader/NoResize.qml new file mode 100644 index 0000000..cfbb55a --- /dev/null +++ b/tests/auto/declarative/qfxloader/NoResize.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Loader { + resizeMode: "NoResize" + width: 200; height: 80 + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/Rect120x60.qml b/tests/auto/declarative/qfxloader/Rect120x60.qml new file mode 100644 index 0000000..aa4b0c2 --- /dev/null +++ b/tests/auto/declarative/qfxloader/Rect120x60.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Rectangle { + width: 120 + height:60 +} diff --git a/tests/auto/declarative/qfxloader/SetSourceComponent.qml b/tests/auto/declarative/qfxloader/SetSourceComponent.qml new file mode 100644 index 0000000..c5dd7ff --- /dev/null +++ b/tests/auto/declarative/qfxloader/SetSourceComponent.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Item { + Component { id: Comp; Rectangle { width: 120; height: 60 } } + Loader { sourceComponent: Comp } +} diff --git a/tests/auto/declarative/qfxloader/SizeToItem.qml b/tests/auto/declarative/qfxloader/SizeToItem.qml new file mode 100644 index 0000000..b52fa03 --- /dev/null +++ b/tests/auto/declarative/qfxloader/SizeToItem.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Loader { + resizeMode: "SizeLoaderToItem" + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/SizeToLoader.qml b/tests/auto/declarative/qfxloader/SizeToLoader.qml new file mode 100644 index 0000000..1a107e1 --- /dev/null +++ b/tests/auto/declarative/qfxloader/SizeToLoader.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Loader { + resizeMode: "SizeItemToLoader" + width: 200; height: 80 + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/qfxloader.pro b/tests/auto/declarative/qfxloader/qfxloader.pro new file mode 100644 index 0000000..643c18c --- /dev/null +++ b/tests/auto/declarative/qfxloader/qfxloader.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +SOURCES += tst_qfxloader.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp new file mode 100644 index 0000000..2109898 --- /dev/null +++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp @@ -0,0 +1,103 @@ +#include <qtest.h> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcomponent.h> +#include <QtDeclarative/qfxloader.h> + +class tst_qfxloader : public QObject + +{ + Q_OBJECT +public: + tst_qfxloader(); + +private slots: + void url(); + void component(); + void sizeLoaderToItem(); + void sizeItemToLoader(); + void noResize(); + +private: + QmlEngine engine; +}; + +/* +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); +} + +inline QUrl TEST_FILE(const char *filename) +{ + return TEST_FILE(QLatin1String(filename)); +} +*/ + +tst_qfxloader::tst_qfxloader() +{ +} + +void tst_qfxloader::url() +{ + QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); +} + +void tst_qfxloader::component() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QFxItem *item = qobject_cast<QFxItem*>(component.create()); + QVERIFY(item); + + QFxLoader *loader = qobject_cast<QFxLoader*>(item->QGraphicsObject::children().at(1)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); +} + +void tst_qfxloader::sizeLoaderToItem() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToItem.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 120.0); + QCOMPARE(loader->height(), 60.0); +} + +void tst_qfxloader::sizeItemToLoader() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToLoader.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(loader->height(), 80.0); + + QFxItem *rect = loader->item(); + QVERIFY(rect); + QCOMPARE(rect->width(), 200.0); + QCOMPARE(rect->height(), 80.0); +} + +void tst_qfxloader::noResize() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/NoResize.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(loader->height(), 80.0); + + QFxItem *rect = loader->item(); + QVERIFY(rect); + QCOMPARE(rect->width(), 120.0); + QCOMPARE(rect->height(), 60.0); +} + +QTEST_MAIN(tst_qfxloader) + +#include "tst_qfxloader.moc" |