summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-10 11:03:11 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-10 11:05:16 +0200
commit2c232cdbce3eba095da26362b964f411a9d3ba80 (patch)
tree7473deb69a14cc01128350593b22a1d212b9f126 /tests/auto/qgraphicsview
parentb8d44332bbbca1d065a07cba79ad179bd9c0197c (diff)
Stabilize Graphics View tests
Reviewed-by: Jesper
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 0b731d53a5..6c1ac54dfd 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -379,7 +379,7 @@ void tst_QGraphicsView::interactive()
view.show();
QTestEventLoop::instance().enterLoop(1);
- QCOMPARE(item->events.size(), 1); // activate
+ QTRY_COMPARE(item->events.size(), 1); // activate
QPoint itemPoint = view.mapFromScene(item->scenePos());
@@ -1869,6 +1869,9 @@ void tst_QGraphicsView::sendEvent()
QGraphicsView view(&scene);
view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWait(20);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
QTestEventLoop::instance().enterLoop(1);
@@ -1938,7 +1941,10 @@ void tst_QGraphicsView::wheelEvent()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(250);
+ QApplication::setActiveWindow(&view);
+ QTest::qWait(20);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
+
// Send a wheel event with horizontal orientation.
{
@@ -3128,12 +3134,15 @@ void tst_QGraphicsView::moveItemWhileScrolling()
setScene(new QGraphicsScene(0, 0, 1000, 1000));
rect = scene()->addRect(0, 0, 10, 10);
rect->setPos(50, 50);
+ painted = false;
}
QRegion lastPaintedRegion;
QGraphicsItem *rect;
+ bool painted;
protected:
void paintEvent(QPaintEvent *event)
{
+ painted = true;
lastPaintedRegion = event->region();
QGraphicsView::paintEvent(event);
}
@@ -3152,12 +3161,15 @@ void tst_QGraphicsView::moveItemWhileScrolling()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(200);
+ QTest::qWait(100);
+ QTRY_VERIFY(view.painted);
+ view.painted = false;
view.lastPaintedRegion = QRegion();
view.horizontalScrollBar()->setValue(view.horizontalScrollBar()->value() + 10);
view.rect->moveBy(0, 10);
QTest::qWait(100);
+ QTRY_VERIFY(view.painted);
QRegion expectedRegion;
expectedRegion += QRect(0, 0, 200, 200);
@@ -3509,7 +3521,9 @@ void tst_QGraphicsView::inputMethodSensitivity()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(300);
+ QApplication::setActiveWindow(&view);
+ QTest::qWait(250);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
QGraphicsRectItem *item = new QGraphicsRectItem;
@@ -3599,7 +3613,9 @@ void tst_QGraphicsView::inputContextReset()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(300);
+ QApplication::setActiveWindow(&view);
+ QTest::qWait(20);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
QGraphicsItem *item1 = new QGraphicsRectItem;
item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);