summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsproxywidget
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicsproxywidget')
-rw-r--r--tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 1ee8e51..626a691 100644
--- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -786,7 +786,9 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
+ QApplication::setActiveWindow(&view);
QTest::qWait(250);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
if (hasScene) {
scene.addItem(proxy);
proxy->show();
@@ -836,8 +838,9 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
QApplication::setActiveWindow(&view);
view.activateWindow();
view.setFocus();
- QTRY_VERIFY(view.isVisible());
QTest::qWait(125);
+ QTRY_VERIFY(view.isVisible());
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
QWidget *widget = new QWidget;
widget->setFocusPolicy(Qt::WheelFocus);
@@ -1098,7 +1101,9 @@ void tst_QGraphicsProxyWidget::keyPressEvent()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
+ QApplication::setActiveWindow(&view);
QTest::qWait(250);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
@@ -1108,7 +1113,7 @@ void tst_QGraphicsProxyWidget::keyPressEvent()
view.resize(100, 100);
if (hasWidget) {
proxy->setWidget(widget);
- proxy->show();
+ proxy->show();
}
proxy->setPos(50, 0);
scene.addItem(proxy);
@@ -1140,7 +1145,10 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
+ QApplication::setActiveWindow(&view);
QTest::qWait(250);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
+
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
@@ -1150,7 +1158,7 @@ void tst_QGraphicsProxyWidget::keyReleaseEvent()
view.resize(100, 100);
if (hasWidget) {
proxy->setWidget(widget);
- proxy->show();
+ proxy->show();
}
proxy->setPos(50, 0);
scene.addItem(proxy);
@@ -1181,6 +1189,10 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
QGraphicsView view(&scene);
view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWait(250);
+ QTRY_COMPARE(QApplication::activeWindow(), &view);
+
SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget;
proxy->setFlag(QGraphicsItem::ItemIsFocusable, true); // ### remove me!!!
QLineEdit *widget = new QLineEdit;
@@ -1189,7 +1201,7 @@ void tst_QGraphicsProxyWidget::mouseDoubleClickEvent()
view.resize(100, 100);
if (hasWidget) {
proxy->setWidget(widget);
- proxy->show();
+ proxy->show();
}
proxy->setPos(50, 0);
scene.addItem(proxy);
@@ -1495,7 +1507,8 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(200);
+ QTRY_COMPARE(view.npaints, 1);
+ QTest::qWait(20);
widget->paintEventRegion = QRegion();
widget->npaints = 0;
view.paintEventRegion = QRegion();
@@ -1709,7 +1722,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -1793,7 +1806,7 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
EventSpy eventSpy2(edit2);
@@ -1927,7 +1940,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
@@ -2061,7 +2074,7 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
@@ -2197,7 +2210,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -2269,7 +2282,7 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit);
@@ -2348,7 +2361,7 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets()
leftDial->setFocus();
QTest::qWait(125);
- QVERIFY(leftDial->hasFocus());
+ QTRY_VERIFY(leftDial->hasFocus());
EventSpy eventSpy(edit1);
EventSpy eventSpy2(edit2);
@@ -3249,7 +3262,8 @@ void tst_QGraphicsProxyWidget::updateAndDelete()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
- QTest::qWait(200);
+ QTest::qWait(20);
+ QTRY_VERIFY(view.npaints > 0);
const QRect itemDeviceBoundingRect = proxy->deviceTransform(view.viewportTransform())
.mapRect(proxy->boundingRect()).toRect();
@@ -3346,9 +3360,10 @@ void tst_QGraphicsProxyWidget::clickFocus()
QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0);
QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0);
- // Spontaneous mouse click sets focus on a clickable widget.
QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center());
- QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter));
+ // Spontaneous mouse click sets focus on a clickable widget.
+ for (int retry = 0; retry < 50 && !proxy->hasFocus(); retry++)
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter));
QVERIFY(proxy->hasFocus());
QVERIFY(proxy->widget()->hasFocus());
QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1);