From 0554341d9f684e6867b36a9ce6af7c846c64057d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 18 Mar 2013 17:08:17 +0100 Subject: [PATCH] Tests: stabilize tst_qwidget::scroll on small screens The test has been recently failing in CI. The problem was easy to reproduce in a virtual machine by resizing the window of the virtual machine small enough. This change makes sure that the requested size hint is significantly smaller than the desktop size, to avoid the window manager stepping in and limiting the window size. Change-Id: Ie319892747bee60ea6f11e27b6c1bfb4731ef587 Reviewed-by: Caroline Chao --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 78fce7661e..f9ee2e485a 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4239,8 +4239,11 @@ void tst_QWidget::isOpaque() */ void tst_QWidget::scroll() { + const int w = qMin(500, qApp->desktop()->availableGeometry().width() / 2); + const int h = qMin(500, qApp->desktop()->availableGeometry().height() / 2); + UpdateWidget updateWidget; - updateWidget.resize(500, 500); + updateWidget.resize(w, h); updateWidget.reset(); updateWidget.show(); qApp->setActiveWindow(&updateWidget); @@ -4251,8 +4254,8 @@ void tst_QWidget::scroll() updateWidget.reset(); updateWidget.scroll(10, 10); qApp->processEvents(); - QRegion dirty(QRect(0, 0, 500, 10)); - dirty += QRegion(QRect(0, 10, 10, 490)); + QRegion dirty(QRect(0, 0, w, 10)); + dirty += QRegion(QRect(0, 10, 10, h - 10)); QCOMPARE(updateWidget.paintedRegion, dirty); } @@ -4261,11 +4264,14 @@ void tst_QWidget::scroll() updateWidget.update(0, 0, 10, 10); updateWidget.scroll(0, 10); qApp->processEvents(); - QRegion dirty(QRect(0, 0, 500, 10)); + QRegion dirty(QRect(0, 0, w, 10)); dirty += QRegion(QRect(0, 10, 10, 10)); QCOMPARE(updateWidget.paintedRegion, dirty); } + if (updateWidget.width() < 200 || updateWidget.height() < 200) + QSKIP("Skip this test due to too small screen geometry."); + { updateWidget.reset(); updateWidget.update(0, 0, 100, 100);