summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-03-24 01:12:47 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-03-24 08:29:00 (GMT)
commitc8fa23a5edd790d9eed0620068a29e03e4202cac (patch)
tree777391f86bbdf5f8b65f381d5304cf5816a489c0 /tests/auto
parentb6b1dee9460d6fdde0b8ad005301c0a315ad30bf (diff)
downloadQt-c8fa23a5edd790d9eed0620068a29e03e4202cac.zip
Qt-c8fa23a5edd790d9eed0620068a29e03e4202cac.tar.gz
Qt-c8fa23a5edd790d9eed0620068a29e03e4202cac.tar.bz2
Invalidate the cache of QGraphicsEffect if a child becomes visible.
The effect might rely on a child to draw itself. So we need to redraw if a child become visible or invisible. Task-number:QTBUG-7843 Reviewed-by:janarve
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
index 1007d61..02899ae 100644
--- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -46,6 +46,7 @@
#include <QtGui/qgraphicsview.h>
#include <QtGui/qgraphicsscene.h>
#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qgraphicswidget.h>
#include <QtGui/qstyleoption.h>
#include "../../shared/util.h"
@@ -73,6 +74,7 @@ private slots:
void deviceCoordinateTranslateCaching();
void inheritOpacity();
void dropShadowClipping();
+ void childrenVisibilityShouldInvalidateCache();
};
void tst_QGraphicsEffect::initTestCase()
@@ -613,6 +615,47 @@ void tst_QGraphicsEffect::dropShadowClipping()
QCOMPARE(img.pixel(x, y), img.pixel(x, y-1));
}
+class MyGraphicsItem : public QGraphicsWidget
+{
+public:
+ MyGraphicsItem(QGraphicsItem *parent = 0) :
+ QGraphicsWidget(parent), nbPaint(0)
+ {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ nbPaint++;
+ QGraphicsWidget::paint(painter, option, widget);
+ }
+ int nbPaint;
+};
+
+void tst_QGraphicsEffect::childrenVisibilityShouldInvalidateCache()
+{
+ QGraphicsScene scene;
+ MyGraphicsItem parent;
+ parent.resize(200, 200);
+ QGraphicsWidget child(&parent);
+ child.resize(200, 200);
+ child.setVisible(false);
+ scene.addItem(&parent);
+ QGraphicsView view(&scene);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(parent.nbPaint, 1);
+ //we set an effect on the parent
+ parent.setGraphicsEffect(new QGraphicsDropShadowEffect(&parent));
+ //flush the events
+ QApplication::processEvents();
+ //new effect applied->repaint
+ QCOMPARE(parent.nbPaint, 2);
+ child.setVisible(true);
+ //flush the events
+ QApplication::processEvents();
+ //a new child appears we need to redraw the effect.
+ QCOMPARE(parent.nbPaint, 3);
+}
+
QTEST_MAIN(tst_QGraphicsEffect)
#include "tst_qgraphicseffect.moc"