Make tst_qwindow::positioning more reliable
authorSimon Hausmann <simon.hausmann@theqtcompany.com>
Wed, 3 Dec 2014 11:09:50 +0000 (12:09 +0100)
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>
Thu, 4 Dec 2014 11:00:43 +0000 (12:00 +0100)
Don't check for absolute counts of resize events but just check if we
were resized. Also use QTest::qWaitForWindowExposed instead of QTRY_COMPARE
and checking for QEvent::Expose.

Change-Id: Ie383493a8ce6d88cad50bd6375d432ad1578449c
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp

index fac16ff8a354aac039adbd7344399e5a65c86906..46b33e5d3999e088193df949f1796820f6e90015 100644 (file)
@@ -233,17 +233,11 @@ void tst_QWindow::resizeEventAfterResize()
 void tst_QWindow::positioning_data()
 {
     QTest::addColumn<int>("windowflags");
-    QTest::addColumn<int>("resizecount");
 
-    QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint)
-#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-                             << 4;
-#else
-                             << 3;
-#endif
+    QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint);
 
 #ifdef Q_OS_OSX
-    QTest::newRow("fake") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) << 4;
+    QTest::newRow("fake") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
 #endif
 }
 
@@ -262,7 +256,6 @@ void tst_QWindow::positioning()
     const QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
 
     QFETCH(int, windowflags);
-    QFETCH(int, resizecount);
     Window window((Qt::WindowFlags)windowflags);
     window.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20), m_testWindowSize));
     window.setFramePosition(m_availableTopLeft + QPoint(40, 40)); // Move window around before show, size must not change.
@@ -273,8 +266,7 @@ void tst_QWindow::positioning()
     window.showNormal();
     QCoreApplication::processEvents();
 
-    QTRY_COMPARE(window.received(QEvent::Resize), 1);
-    QTRY_VERIFY(window.received(QEvent::Expose) > 0);
+    QTest::qWaitForWindowExposed(&window);
 
     QMargins originalMargins = window.frameMargins();
 
@@ -284,25 +276,22 @@ void tst_QWindow::positioning()
     QPoint originalPos = window.position();
     QPoint originalFramePos = window.framePosition();
 
+    window.reset();
     window.setWindowState(Qt::WindowFullScreen);
     QCoreApplication::processEvents();
-#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
-                              // so we only expect one resize event
-    Q_UNUSED(resizecount);
-    QTRY_COMPARE(window.received(QEvent::Resize), 1);
-#else
-    QTRY_COMPARE(window.received(QEvent::Resize), 2);
+    // On BB10 the window is the root window and fullscreen, so nothing is resized.
+#if !defined(Q_OS_BLACKBERRY)
+    QTRY_VERIFY(window.received(QEvent::Resize) > 0);
 #endif
 
     QTest::qWait(2000);
 
+    window.reset();
     window.setWindowState(Qt::WindowNoState);
     QCoreApplication::processEvents();
-#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
-                              // so we only expect one resize event
-    QTRY_COMPARE(window.received(QEvent::Resize), 1);
-#else
-    QTRY_COMPARE(window.received(QEvent::Resize), resizecount);
+    // On BB10 the window is the root window and fullscreen, so nothing is resized.
+#if !defined(Q_OS_BLACKBERRY)
+    QTRY_VERIFY(window.received(QEvent::Resize) > 0);
 #endif
 
     QTRY_COMPARE(originalPos, window.position());