tst_QMdiSubWindow: fix flaky setOpaqueResizeAndMove test

tst_QMdiSubWindow::setOpaqueResizeAndMove checks if a resize of the mdi
subwindow works as expected by simulating mouse events. Those events are
sent to fast and therefore the operationMap of QMdiSubWindowPrivate is
not yet updated which let the test fail. There was already a call to
qWait(250) to wait for the 200ms timer but sometimes (esp. in virtual
environments) the timer was not triggered after this period.
Fix it by checking if resizeTimerId is set back to -1 which means that
updateDirtyRegions() was called.

Change-Id: I961ba80589d2f725a6858ba70b84fb35750a6964
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
This commit is contained in:
Christian Ehrlicher 2018-09-15 14:35:24 +02:00 committed by Tony Sarajärvi
parent f4dd670fe9
commit 6bb0cbc686
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qmdisubwindow
QT += widgets testlib
QT += widgets widgets-private testlib
INCLUDEPATH += .
SOURCES += tst_qmdisubwindow.cpp
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII

View File

@ -30,6 +30,7 @@
#include <QtTest/QtTest>
#include "qmdisubwindow.h"
#include "private/qmdisubwindow_p.h"
#include "qmdiarea.h"
#include <QLayout>
@ -723,7 +724,9 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove()
resizeSpy.clear();
QCOMPARE(resizeSpy.count(), 0);
QTest::qWait(250); // delayed update of dirty regions
// we need to wait for the resizeTimer to make sure updateDirtyRegions is called
auto priv = static_cast<QMdiSubWindowPrivate*>(qt_widget_private(window));
QTRY_COMPARE(priv->resizeTimerId, -1);
// Enter resize mode.
int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2;