summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicseffect
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-09-16 12:38:51 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2010-09-16 18:25:57 +0200
commite76564e8a3b305f4fe69135bebb409e357f29f57 (patch)
tree56c2557f519b5936d6357fac57f6a486925f146c /tests/auto/qgraphicseffect
parent3d7ef01963f2e15b7fd8fd23ffe22198ced00c87 (diff)
Wrong bounding rect returned by QGraphicsEffect::boundingRect().
Regression after: f5c5e20a Problem was that the cached bounding rect was never invalidated. We can also remove the cached bounding rect in QGraphicsEffectSource because QGraphicsItem::childrenBoundingRect now clips by default. This basically means partially reverting above commit and invalidate whenever ItemClipsChildrenToShape flag changes. Auto test included. Task-number: Discovered while investigating QT-3633 Reviewed-by: samuel
Diffstat (limited to 'tests/auto/qgraphicseffect')
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index e1bfb7985e..985d466358 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -66,6 +66,7 @@ private slots:
void source();
void boundingRectFor();
void boundingRect();
+ void boundingRect2();
void draw();
void opacity();
void grayscale();
@@ -264,6 +265,31 @@ void tst_QGraphicsEffect::boundingRect()
delete item;
}
+void tst_QGraphicsEffect::boundingRect2()
+{
+ CustomEffect *effect = new CustomEffect;
+ QGraphicsRectItem *root = new QGraphicsRectItem;
+ root->setGraphicsEffect(effect);
+
+ QGraphicsRectItem *child = new QGraphicsRectItem;
+ QRectF childRect(0, 0, 100, 100);
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ child->setRect(childRect);
+ child->setParentItem(root);
+
+ QGraphicsRectItem *grandChild = new QGraphicsRectItem;
+ QRectF grandChildRect(0, 0, 200, 200);
+ grandChild->setRect(grandChildRect);
+ grandChild->setParentItem(child);
+
+ // Make sure the effect's bounding rect is clipped to the child's bounding rect.
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect));
+
+ // Disable ItemClipsChildrenToShape; effect's bounding rect is no longer clipped.
+ child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect));
+}
+
void tst_QGraphicsEffect::draw()
{
QGraphicsScene scene;