tst_qmdiarea: Prevent scrollbars from messing up expected viewport calculation

With scrollbars enabled we would get two resize events when tiling the windows.
First one with the expected viewport size, and then a second one with a bigger
viewport when the QMdiArea calculated that the space it set off for scrollbars
was not needed after all. Depending on whether or not the geometry propagation
of the platform plugin was synchronous or not, we would get one or both of the
events before evaluating the viewport size against the expected size, resulting
in flakeyness, and an expected fail on OS X.

We now explicitly disable the scrollbars during the test, and restore them for
the latter test that verifies that scrollbars show up when the area is resized
below the minimum size of the combined child widgets. This allows us to unskip
the expected failure on OS X, and should make the test less flakey.

Change-Id: Ief767456cfd79f5cd0bb0e220c40e5995674ff71
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
bb10
Tor Arne Vestbø 2013-05-14 13:45:46 +02:00 committed by The Qt Project
parent 27cbb58a92
commit 8be5103d29
1 changed files with 9 additions and 3 deletions

View File

@ -1705,6 +1705,11 @@ void tst_QMdiArea::tileSubWindows()
subWindow->setMinimumSize(minSize);
QCOMPARE(workspace.size(), QSize(350, 150));
// Prevent scrollbars from messing up the expected viewport calculation below
workspace.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
workspace.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
workspace.tileSubWindows();
// The sub-windows are now tiled like this:
// | win 1 || win 2 || win 3 |
@ -1722,12 +1727,13 @@ void tst_QMdiArea::tileSubWindows()
const QSize expectedViewportSize(3 * minSize.width() + spacing, 3 * minSize.height() + spacing);
#ifdef Q_OS_WINCE
QSKIP("Not fixed yet! See task 197453");
#endif
#ifdef Q_OS_MAC
QEXPECT_FAIL("", "QTBUG-25298", Abort);
#endif
QTRY_COMPARE(workspace.viewport()->rect().size(), expectedViewportSize);
// Restore original scrollbar behavior for test below
workspace.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
workspace.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// Not enough space for all sub-windows to be visible -> provide scroll bars.
workspace.resize(160, 150);
qApp->processEvents();