summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-05-27 15:28:26 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-05-27 16:01:52 +0200
commit2c54f49584023633c5992579d23dc6819ec79c9e (patch)
tree9a0478fccf23b8de47f85a838a2fee04a8ec325f /tests
parentddf119a57001edd71eb6b84dffc7cda4a8ca2c0e (diff)
Wrong QGraphicsItem::childrenBoundingRect() when applying effects.
Problem was that we used the children's raw bounding rect instead of using their effective bounding rect when calculating the bounds. Auto test included. Task-number: QTBUG-10756
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 300afc3ffe..5547b02820 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -348,6 +348,7 @@ private slots:
void childrenBoundingRect2();
void childrenBoundingRect3();
void childrenBoundingRect4();
+ void childrenBoundingRect5();
void group();
void setGroup();
void setGroup2();
@@ -3369,6 +3370,34 @@ void tst_QGraphicsItem::childrenBoundingRect4()
QCOMPARE(rect2->childrenBoundingRect(), rect3->boundingRect());
}
+void tst_QGraphicsItem::childrenBoundingRect5()
+{
+ QGraphicsScene scene;
+
+ QGraphicsRectItem *parent = scene.addRect(QRectF(0, 0, 100, 100));
+ QGraphicsRectItem *child = scene.addRect(QRectF(0, 0, 100, 100));
+ child->setParentItem(parent);
+
+ QGraphicsView view(&scene);
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ // Try to mess up the cached bounding rect.
+ QRectF expectedChildrenBoundingRect = parent->boundingRect();
+ QCOMPARE(parent->childrenBoundingRect(), expectedChildrenBoundingRect);
+
+ // Apply some effects.
+ QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect;
+ dropShadow->setOffset(25, 25);
+ child->setGraphicsEffect(dropShadow);
+ parent->setGraphicsEffect(new QGraphicsOpacityEffect);
+
+ QVERIFY(parent->childrenBoundingRect() != expectedChildrenBoundingRect);
+ expectedChildrenBoundingRect |= dropShadow->boundingRect();
+ QCOMPARE(parent->childrenBoundingRect(), expectedChildrenBoundingRect);
+}
+
void tst_QGraphicsItem::group()
{
QGraphicsScene scene;