Make tst_qwindow::positioning more reliable
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>
This commit is contained in:
parent
ab6d645850
commit
bd5743f1d8
@ -233,17 +233,11 @@ void tst_QWindow::resizeEventAfterResize()
|
|||||||
void tst_QWindow::positioning_data()
|
void tst_QWindow::positioning_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<int>("windowflags");
|
QTest::addColumn<int>("windowflags");
|
||||||
QTest::addColumn<int>("resizecount");
|
|
||||||
|
|
||||||
QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint)
|
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
|
|
||||||
|
|
||||||
#ifdef Q_OS_OSX
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +256,6 @@ void tst_QWindow::positioning()
|
|||||||
const QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
|
const QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
|
||||||
|
|
||||||
QFETCH(int, windowflags);
|
QFETCH(int, windowflags);
|
||||||
QFETCH(int, resizecount);
|
|
||||||
Window window((Qt::WindowFlags)windowflags);
|
Window window((Qt::WindowFlags)windowflags);
|
||||||
window.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20), m_testWindowSize));
|
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.
|
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();
|
window.showNormal();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
QTRY_COMPARE(window.received(QEvent::Resize), 1);
|
QTest::qWaitForWindowExposed(&window);
|
||||||
QTRY_VERIFY(window.received(QEvent::Expose) > 0);
|
|
||||||
|
|
||||||
QMargins originalMargins = window.frameMargins();
|
QMargins originalMargins = window.frameMargins();
|
||||||
|
|
||||||
@ -284,25 +276,22 @@ void tst_QWindow::positioning()
|
|||||||
QPoint originalPos = window.position();
|
QPoint originalPos = window.position();
|
||||||
QPoint originalFramePos = window.framePosition();
|
QPoint originalFramePos = window.framePosition();
|
||||||
|
|
||||||
|
window.reset();
|
||||||
window.setWindowState(Qt::WindowFullScreen);
|
window.setWindowState(Qt::WindowFullScreen);
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
|
// On BB10 the window is the root window and fullscreen, so nothing is resized.
|
||||||
// so we only expect one resize event
|
#if !defined(Q_OS_BLACKBERRY)
|
||||||
Q_UNUSED(resizecount);
|
QTRY_VERIFY(window.received(QEvent::Resize) > 0);
|
||||||
QTRY_COMPARE(window.received(QEvent::Resize), 1);
|
|
||||||
#else
|
|
||||||
QTRY_COMPARE(window.received(QEvent::Resize), 2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QTest::qWait(2000);
|
QTest::qWait(2000);
|
||||||
|
|
||||||
|
window.reset();
|
||||||
window.setWindowState(Qt::WindowNoState);
|
window.setWindowState(Qt::WindowNoState);
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
|
// On BB10 the window is the root window and fullscreen, so nothing is resized.
|
||||||
// so we only expect one resize event
|
#if !defined(Q_OS_BLACKBERRY)
|
||||||
QTRY_COMPARE(window.received(QEvent::Resize), 1);
|
QTRY_VERIFY(window.received(QEvent::Resize) > 0);
|
||||||
#else
|
|
||||||
QTRY_COMPARE(window.received(QEvent::Resize), resizecount);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QTRY_COMPARE(originalPos, window.position());
|
QTRY_COMPARE(originalPos, window.position());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user