From bd5743f1d8472e70aeeccd08858130d4781bde41 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 3 Dec 2014 12:09:50 +0100 Subject: Make tst_qwindow::positioning more reliable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 33 +++++++++------------------ 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index fac16ff8a3..46b33e5d39 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -233,17 +233,11 @@ void tst_QWindow::resizeEventAfterResize() void tst_QWindow::positioning_data() { QTest::addColumn("windowflags"); - QTest::addColumn("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()); -- cgit v1.2.3