summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-07-18 13:12:59 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-20 09:27:28 +0200
commit87618403976aa82450895da6196a944195980de7 (patch)
tree906d035678d8a31e57a94c01e8756b0085b3e1e4 /tests/auto/widgets/kernel
parentc081107206cb1d31415539c4429f7896b997cf71 (diff)
Implement waitForWindowExposed and friends for widget windows.
- Implement waitForWindowExposed() for toplevel windows. - Implement waitForWindowShown(QWidget *) and mark as deprecated in line with waitForWindowShown(QWindow*). - Use in tests. - Simplify tests (collapse waitForExposed, setActive into setActiveWindow, waitForActive), remove most hard-coded timeouts. - Stabilize graphicsview tests by using waitForWindowActive. Change-Id: Ic7c061e2745b36f71a715ee4e47c0346b11a91e8 Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp6
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp4
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp13
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp18
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp32
5 files changed, 25 insertions, 48 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index e0028be780..aebe416ed6 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -274,10 +274,8 @@ void tst_QApplication::alert()
app.alert(&widget, 100);
widget.show();
widget2.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&widget);
- qt_x11_wait_for_window_manager(&widget2);
-#endif
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QVERIFY(QTest::qWaitForWindowExposed(&widget2));
QTest::qWait(100);
app.alert(&widget, -1);
app.alert(&widget, 250);
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index fc47e09d4f..8ec0ef8a5f 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -348,9 +348,7 @@ void tst_QFormLayout::contentsRect()
w.setLayout(&form);
form.addRow("Label", new QPushButton(&w));
w.show();
-/*#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(&w); // wait for the show
-#endif*/
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
int l, t, r, b;
form.getContentsMargins(&l, &t, &r, &b);
QRect geom = form.geometry();
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 6b424ab4b4..be2d49ab7e 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -906,10 +906,7 @@ void tst_QGridLayout::minMaxSize()
}
m_toplevel->show();
-#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(m_toplevel); // wait for the show
-#endif
- QTest::qWait(40);
+ QVERIFY(QTest::qWaitForWindowExposed(m_toplevel));
m_toplevel->adjustSize();
QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
@@ -1462,9 +1459,7 @@ void tst_QGridLayout::layoutSpacingImplementation()
widget->setParent(&toplevel);
widget->resize(widget->sizeHint());
toplevel.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&toplevel); // wait for the show
-#endif
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
QLayout *layout = widget->layout();
QVERIFY(layout);
@@ -1586,9 +1581,7 @@ void tst_QGridLayout::contentsRect()
w.setLayout(&grid);
grid.addWidget(new QPushButton(&w));
w.show();
-#if defined(Q_WS_X11)
- qt_x11_wait_for_window_manager(&w); // wait for the show
-#endif
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
int l, t, r, b;
grid.getContentsMargins(&l, &t, &r, &b);
QRect geom = grid.geometry();
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 971f60bb3e..dd91e6968f 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -1004,9 +1004,7 @@ void tst_QShortcut::context()
layout->addWidget(other1);
layout->addWidget(other2);
myBox.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&myBox);
-#endif
+ QVERIFY(QTest::qWaitForWindowExposed(&myBox));
setupShortcut(other1, "ActiveWindow", TriggerSlot1, QKeySequence("Alt+1"), Qt::WindowShortcut);
setupShortcut(other2, "Focus", TriggerSlot2, QKeySequence("Alt+2"), Qt::WidgetShortcut);
@@ -1076,11 +1074,7 @@ void tst_QShortcut::context()
other2->activateWindow();
other2->setFocus(); // ###
qApp->syncX();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(other2);
-#endif
- QTest::qWait(100);
- QCOMPARE(qApp->activeWindow(), other2->window());
+ QTRY_COMPARE(qApp->activeWindow(), other2->window());
QCOMPARE(qApp->focusWidget(), (QWidget *)other2);
currentResult = NoResult;
@@ -1097,14 +1091,6 @@ void tst_QShortcut::context()
QCOMPARE(other2->toPlainText(), QString(""));
clearAllShortcuts();
- delete other1;
- delete other2;
- edit->activateWindow();
- qApp->syncX();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(edit);
-#endif
- QTest::qWait(100);
}
// ------------------------------------------------------------------
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index cf65556a1a..37e945ddb1 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -4874,7 +4874,8 @@ void tst_QWidget::showAndMoveChild()
parent.setGeometry(desktopDimensions);
parent.setPalette(Qt::red);
parent.show();
- QTest::qWaitForWindowShown(&parent);
+ qApp->setActiveWindow(&parent);
+ QVERIFY(QTest::qWaitForWindowActive(&parent));
QTest::qWait(10);
const QPoint tlwOffset = parent.geometry().topLeft();
@@ -4976,25 +4977,23 @@ void tst_QWidget::multipleToplevelFocusCheck()
w1.resize(200, 200);
w1.show();
- QTest::qWaitForWindowShown(&w1);
+ QVERIFY(QTest::qWaitForWindowExposed(&w1));
w2.resize(200,200);
w2.show();
- QTest::qWaitForWindowShown(&w2);
-
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowExposed(&w2));
QApplication::setActiveWindow(&w1);
w1.activateWindow();
- QApplication::processEvents();
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+ QVERIFY(QTest::qWaitForWindowActive(&w1));
+ QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
QTest::qWait(50);
QTest::mouseDClick(&w1, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
w2.activateWindow();
QApplication::setActiveWindow(&w2);
- QApplication::processEvents();
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+ QVERIFY(QTest::qWaitForWindowActive(&w2));
+ QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
QTest::mouseClick(&w2, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0);
@@ -5003,15 +5002,15 @@ void tst_QWidget::multipleToplevelFocusCheck()
w1.activateWindow();
QApplication::setActiveWindow(&w1);
- QApplication::processEvents();
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+ QVERIFY(QTest::qWaitForWindowActive(&w1));
+ QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
QTest::mouseDClick(&w1, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
w2.activateWindow();
QApplication::setActiveWindow(&w2);
- QApplication::processEvents();
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+ QVERIFY(QTest::qWaitForWindowActive(&w2));
+ QCOMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
QTest::mouseClick(&w2, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), (QWidget *)0);
}
@@ -7531,7 +7530,8 @@ void tst_QWidget::resizeInPaintEvent()
QWidget window;
UpdateWidget widget(&window);
window.show();
- QTest::qWaitForWindowShown(&window);
+ qApp->setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
QTRY_VERIFY(widget.numPaintEvents > 0);
widget.reset();
@@ -8132,7 +8132,8 @@ void tst_QWidget::setClearAndResizeMask()
UpdateWidget topLevel;
topLevel.resize(150, 150);
topLevel.show();
- QTest::qWaitForWindowShown(&topLevel);
+ qApp->setActiveWindow(&topLevel);
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
QTRY_VERIFY(topLevel.numPaintEvents > 0);
topLevel.reset();
@@ -8919,6 +8920,7 @@ void tst_QWidget::focusProxyAndInputMethods()
toplevel->show();
QTest::qWaitForWindowShown(toplevel);
QApplication::setActiveWindow(toplevel);
+ QVERIFY(QTest::qWaitForWindowActive(toplevel));
QVERIFY(toplevel->hasFocus());
QVERIFY(child->hasFocus());