summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-14 11:03:10 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-14 11:32:47 (GMT)
commita2bad25383e565233a0c2527e04cef9f6b577f14 (patch)
treee62e3c89500eaccedb19b864b1351f0d19a8b910 /tests/auto
parent9210e8cdc83b6812d10f5f5847d05703ef2e5f7c (diff)
downloadQt-a2bad25383e565233a0c2527e04cef9f6b577f14.zip
Qt-a2bad25383e565233a0c2527e04cef9f6b577f14.tar.gz
Qt-a2bad25383e565233a0c2527e04cef9f6b577f14.tar.bz2
Make sure QGraphicsScene::update() only requires one event-loop
iteration before the views are updated. A full scene update (scene.update()) already supported it because the scene called update() on the views directly. However, partially scene updates (scene.update(rect)) required two event-loop iterations before the views were updated. Auto-test included.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index e9d6f1d..f7ea4ce 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -236,6 +236,7 @@ private slots:
void contextMenuEvent();
void contextMenuEvent_ItemIgnoresTransformations();
void update();
+ void update2();
void views();
void event();
void eventsToDisabledItems();
@@ -2779,6 +2780,32 @@ void tst_QGraphicsScene::update()
QCOMPARE(region, QRectF(-100, -100, 200, 200));
}
+void tst_QGraphicsScene::update2()
+{
+ QGraphicsScene scene;
+ scene.setSceneRect(-200, -200, 200, 200);
+ CustomView view;
+ view.setScene(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
+ view.repaints = 0;
+
+ // Make sure QGraphicsScene::update only requires one event-loop iteration
+ // before the view is updated.
+ scene.update();
+ qApp->processEvents();
+ QCOMPARE(view.repaints, 1);
+ view.repaints = 0;
+
+ // The same for partial scene updates.
+ scene.update(QRectF(-100, -100, 100, 100));
+ qApp->processEvents();
+ QCOMPARE(view.repaints, 1);
+}
+
void tst_QGraphicsScene::views()
{
QGraphicsScene scene;