diff options
author | Martin Smith <msmith@trolltech.com> | 2010-05-12 13:12:13 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-05-12 13:12:13 (GMT) |
commit | bd11cdf472674af3b00d7d64c64023adbf5ee725 (patch) | |
tree | 99eb333a12f7e0d109b9ce9ff51120c612669d7a /tests/auto/declarative/qdeclarativeitem | |
parent | 50fa9ebe8fc0e7eca7536a8663c86cd6b98b2c04 (diff) | |
parent | 0ebc9783d8ca0c4b27208bbc002c53c52c19ab4c (diff) | |
download | Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.zip Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.gz Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'tests/auto/declarative/qdeclarativeitem')
-rw-r--r-- | tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml | 27 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 28 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml new file mode 100644 index 0000000..f351b53 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +Rectangle { + width: 400 + height: 400 + + property int childCount: 0; + + Item { + objectName: "testItem" + width: childrenRect.width + height: childrenRect.height + + Repeater { + id: repeater + model: childCount + delegate: Rectangle { + x: index*10 + y: index*20 + width: 10 + height: 20 + + color: "red" + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index d2c328e..e0ca746 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -63,6 +63,7 @@ private slots: void propertyChanges(); void transforms(); void transforms_data(); + void childrenRect(); void childrenProperty(); void resourcesProperty(); @@ -537,6 +538,33 @@ void tst_QDeclarativeItem::propertyChanges() delete canvas; } +void tst_QDeclarativeItem::childrenRect() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml")); + canvas->show(); + + QGraphicsObject *o = canvas->rootObject(); + QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("testItem"); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + o->setProperty("childCount", 1); + QCOMPARE(item->width(), qreal(10)); + QCOMPARE(item->height(), qreal(20)); + + o->setProperty("childCount", 5); + QCOMPARE(item->width(), qreal(50)); + QCOMPARE(item->height(), qreal(100)); + + o->setProperty("childCount", 0); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + delete o; +} + template<typename T> T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { |