From 54226926faa44ec532efd0745e0ff64781202844 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 26 Aug 2009 10:56:49 +0200 Subject: Regression found in 4.5.2 and 4.6: artifacts when scrolling during animation. Auto-test submitted. Task-number: 259503 Reviewed-by: bnilsen --- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 505f9a4..3b6e8a7 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -217,6 +217,7 @@ private slots: void task245469_itemsAtPointWithClip(); void task253415_reconnectUpdateSceneOnSceneChanged(); void task255529_transformationAnchorMouseAndViewportMargins(); + void task259503_scrollingArtifacts(); }; void tst_QGraphicsView::initTestCase() @@ -3663,6 +3664,65 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack); } +void tst_QGraphicsView::task259503_scrollingArtifacts() +{ + QGraphicsScene scene(0, 0, 800, 600); + + QGraphicsRectItem card; + card.setRect(0, 0, 50, 50); + card.setPen(QPen(Qt::darkRed)); + card.setBrush(QBrush(Qt::cyan)); + card.setZValue(2.0); + card.setPos(300, 300); + scene.addItem(&card); + + class SAGraphicsView: public QGraphicsView + { + public: + SAGraphicsView(QGraphicsScene *scene) + : QGraphicsView(scene) + , itSTimeToTest(false) + { + setViewportUpdateMode( QGraphicsView::MinimalViewportUpdate ); + resize(QSize(640, 480)); + } + + QRegion updateRegion; + bool itSTimeToTest; + + void paintEvent(QPaintEvent *event) + { + QGraphicsView::paintEvent(event); + + if (itSTimeToTest) + { + qDebug() << event->region(); + qDebug() << updateRegion; + QCOMPARE(event->region(), updateRegion); + } + } + }; + + SAGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + + int hsbValue = view.horizontalScrollBar()->value(); + view.horizontalScrollBar()->setValue(hsbValue / 2); + QTest::qWait(10); + view.horizontalScrollBar()->setValue(0); + QTest::qWait(10); + + QRect itemDeviceBoundingRect = card.deviceTransform(view.viewportTransform()).mapRect(card.boundingRect()).toRect(); + itemDeviceBoundingRect.adjust(-2, -2, 2, 2); + view.updateRegion = itemDeviceBoundingRect; + view.updateRegion += itemDeviceBoundingRect.translated(-100, 0); + view.itSTimeToTest = true; + card.setPos(200, 300); + QTest::qWait(10); +} QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" -- cgit v0.12