diff options
author | Andreas Kling <andreas.kling@nokia.com> | 2010-01-20 08:34:08 (GMT) |
---|---|---|
committer | Andreas Kling <andreas.kling@nokia.com> | 2010-01-20 08:34:08 (GMT) |
commit | 01f733a64e45363e74bea62e4cae8a658bc09383 (patch) | |
tree | ea39b38552a063e7e10bd432b1155a7abae61620 /tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | |
parent | fdf463ba74b2e00ba5f9db10f43585e8b15054f7 (diff) | |
parent | b906feddf1593a837785bc41d65e837e64d31284 (diff) | |
download | Qt-01f733a64e45363e74bea62e4cae8a658bc09383.zip Qt-01f733a64e45363e74bea62e4cae8a658bc09383.tar.gz Qt-01f733a64e45363e74bea62e4cae8a658bc09383.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp')
-rw-r--r-- | tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 95de70e..51e2a57 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -70,6 +70,7 @@ private slots: void grayscale(); void colorize(); void drawPixmapItem(); + void deviceCoordinateTranslateCaching(); }; void tst_QGraphicsEffect::initTestCase() @@ -514,6 +515,51 @@ void tst_QGraphicsEffect::drawPixmapItem() QTRY_VERIFY(effect->repaints >= 2); } +class DeviceEffect : public QGraphicsEffect +{ +public: + QRectF boundingRectFor(const QRectF &rect) const + { return rect; } + + void draw(QPainter *painter) + { + QPoint offset; + QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad); + + if (pixmap.isNull()) + return; + + painter->save(); + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + painter->restore(); + } +}; + +void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() +{ + QGraphicsScene scene; + CustomItem *item = new CustomItem(0, 0, 10, 10); + scene.addItem(item); + scene.setSceneRect(0, 0, 50, 0); + + item->setGraphicsEffect(new DeviceEffect); + item->setPen(Qt::NoPen); + item->setBrush(Qt::red); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTRY_VERIFY(item->numRepaints >= 1); + int numRepaints = item->numRepaints; + + item->translate(10, 0); + QTest::qWait(50); + + QVERIFY(item->numRepaints == numRepaints); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" |