summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-06-15 05:23:28 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-06-15 05:23:28 (GMT)
commitb18a343cc63f93a8e97a8c6c623e56a666775b57 (patch)
tree7a35d17235f26ed971f4367756a280ebfbc8e6a3 /tests
parent7390cfbcbd5000a7da3eb5dbef790d114b06d042 (diff)
downloadQt-b18a343cc63f93a8e97a8c6c623e56a666775b57.zip
Qt-b18a343cc63f93a8e97a8c6c623e56a666775b57.tar.gz
Qt-b18a343cc63f93a8e97a8c6c623e56a666775b57.tar.bz2
Fix bug with childrenRect resizing on startup.
This also optimizes the implementation. Task-number: QTBUG-11383
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp17
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml
new file mode 100644
index 0000000..4a2f056
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml
@@ -0,0 +1,23 @@
+import Qt 4.7
+
+Rectangle {
+ width: 400
+ height: 200
+
+ Item {
+ objectName: "theItem"
+ anchors.centerIn: parent
+ width: childrenRect.width
+ height: childrenRect.height
+ Rectangle {
+ id: text1
+ anchors.verticalCenter: parent.verticalCenter
+ width: 100; height: 100; color: "green"
+ }
+ Rectangle {
+ anchors.left: text1.right
+ anchors.verticalCenter: parent.verticalCenter
+ width: 100; height: 100; color: "green"
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index c2d3660..0a66245 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -72,6 +72,7 @@ private slots:
void transforms();
void transforms_data();
void childrenRect();
+ void childrenRectBug();
void childrenProperty();
void resourcesProperty();
@@ -736,6 +737,22 @@ void tst_QDeclarativeItem::childrenRect()
delete o;
}
+// QTBUG-11383
+void tst_QDeclarativeItem::childrenRectBug()
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug.qml"));
+ canvas->show();
+
+ QGraphicsObject *o = canvas->rootObject();
+ QDeclarativeItem *item = o->findChild<QDeclarativeItem*>("theItem");
+ QCOMPARE(item->width(), qreal(200));
+ QCOMPARE(item->height(), qreal(100));
+ QCOMPARE(item->x(), qreal(100));
+
+ delete canvas;
+}
+
template<typename T>
T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName)
{