diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2012-04-27 16:45:24 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-27 22:52:01 +0200 |
commit | 394bafefacbc2473fe4f7f6ad0c4445e64059445 (patch) | |
tree | fe2dfbff10724b784c93de948d34bf8e5e2c87a4 /tests/auto/gui/kernel | |
parent | 0c3a0dd799a5ffefdececd31be8d9dc778223b4f (diff) |
Fix QWindow autotest for Windows.
The test was flawed, as it didn't process queued events before checking
for received event counts, which caused window minimum size enforcement
triggered resizes to be missed. Added event processing steps before
critical checks and also increased the size of the windows so that
event counts are predictable also on Windows.
Note that this might also fix the issues this test has on Mac, but I
can't test that.
Task-number: QTBUG-24904
Change-Id: I01a4bd1ddabcf3650a8abff67b03c75b9c40a626
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/qwindow.pro | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 27 |
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index fb8132afab..363f7dd92e 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -6,5 +6,4 @@ QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp mac: CONFIG += insignificant_test # QTBUG-23059 -win32: CONFIG += insignificant_test # QTBUG-24904 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 642a4da091..ae5bf55b72 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -142,11 +142,14 @@ private: void tst_QWindow::eventOrderOnShow() { - QRect geometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + QRect geometry(80, 80, 300, 40); Window window; window.setGeometry(geometry); window.show(); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Show), 1); QTRY_COMPARE(window.received(QEvent::Resize), 1); @@ -158,12 +161,15 @@ void tst_QWindow::eventOrderOnShow() void tst_QWindow::positioning() { - QRect geometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + QRect geometry(80, 80, 300, 40); Window window; window.setGeometry(geometry); QCOMPARE(window.geometry(), geometry); window.show(); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_VERIFY(window.received(QEvent::Expose) > 0); @@ -177,12 +183,11 @@ void tst_QWindow::positioning() QPoint originalFramePos = window.framePos(); window.setWindowState(Qt::WindowFullScreen); -#ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTBUG-24904 - Too many resize events on setting window state", Continue); -#endif + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 2); window.setWindowState(Qt::WindowNoState); + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 3); QTRY_COMPARE(originalPos, window.pos()); @@ -219,12 +224,14 @@ void tst_QWindow::isExposed() window.setGeometry(geometry); QCOMPARE(window.geometry(), geometry); window.show(); + QCoreApplication::processEvents(); QTRY_VERIFY(window.received(QEvent::Expose) > 0); QTRY_VERIFY(window.isExposed()); window.hide(); + QCoreApplication::processEvents(); #ifdef Q_OS_MAC QEXPECT_FAIL("", "This test fails on Mac OS X, see QTBUG-23059", Abort); #endif @@ -236,8 +243,11 @@ void tst_QWindow::isExposed() void tst_QWindow::isActive() { Window window; - window.setGeometry(80, 80, 40, 40); + // Some platforms enforce minimum widths for windows, which can cause extra resize + // events, so set the width to suitably large value to avoid those. + window.setGeometry(80, 80, 300, 40); window.show(); + QCoreApplication::processEvents(); QTRY_VERIFY(window.isExposed()); QTRY_COMPARE(window.received(QEvent::Resize), 1); @@ -257,6 +267,7 @@ void tst_QWindow::isActive() QVERIFY(child.isActive()); // parent shouldn't receive new resize events from child being shown + QCoreApplication::processEvents(); QTRY_COMPARE(window.received(QEvent::Resize), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 1); QTRY_COMPARE(window.received(QEvent::FocusOut), 1); @@ -267,12 +278,13 @@ void tst_QWindow::isActive() Window dialog; dialog.setTransientParent(&window); - dialog.setGeometry(110, 110, 30, 30); + dialog.setGeometry(110, 110, 300, 30); dialog.show(); dialog.requestActivateWindow(); QTRY_VERIFY(dialog.isExposed()); + QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::Resize), 1); QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog); QVERIFY(dialog.isActive()); @@ -286,6 +298,7 @@ void tst_QWindow::isActive() window.requestActivateWindow(); QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 2); |