From deb8be93e1e09ab1926fe2c4cea5f77e1c02c713 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 23 Mar 2022 10:37:10 +0100 Subject: Android: enable tst_QScreen::grabWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things are done here: - use showNormal() instead of show() to get an expected widget size. - skip the test if HighDPI scaling is enabled with non-integer scaling factor, because there can be rounding errors. Also had to backport the unconditional delay after showing the window (introduced in 6.3), because the emulator was not fast enough to actually render the window. Fixes: QTBUG-87390 Change-Id: I653a17bac2142838b03a328e1629582384b6c7b3 Reviewed-by: Qt CI Bot Reviewed-by: Morten Johan Sørvig Reviewed-by: Assam Boudjelthia (cherry picked from commit aa451b13b0914e3c33a4e05e792aa8c5effa7a3a) --- tests/auto/gui/kernel/qscreen/BLACKLIST | 2 -- tests/auto/gui/kernel/qscreen/tst_qscreen.cpp | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/auto/gui/kernel/qscreen/BLACKLIST b/tests/auto/gui/kernel/qscreen/BLACKLIST index 51fd672239..ca3136fdb2 100644 --- a/tests/auto/gui/kernel/qscreen/BLACKLIST +++ b/tests/auto/gui/kernel/qscreen/BLACKLIST @@ -1,5 +1,3 @@ -# QTBUG-87390 [grabWindow] -android # QTBUG-100412 windows diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp index 789069381b..5ae5028797 100644 --- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp +++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -279,18 +280,26 @@ void tst_QScreen::grabWindow() QCOMPARE(screen->name().toUtf8(), screenName); const double screenDpr = screen->devicePixelRatio(); + if (QHighDpiScaling::isActive()) { + const float rawFactor = QHighDpiScaling::factor(screen); + const float roundedFactor = qRound(rawFactor); + if (!qFuzzyCompare(roundedFactor, rawFactor)) + QSKIP("HighDPI enabled with non-integer factor. Skip due to possible rounding errors."); + } + Window window(screen); window.setGeometry(windowRect); +#ifndef Q_OS_ANDROID window.show(); +#else + window.showNormal(); +#endif if (!QTest::qWaitForWindowExposed(&window)) QSKIP("Failed to expose window - aborting"); - if (QGuiApplication::platformName().startsWith(QLatin1String("xcb"), Qt::CaseInsensitive)) - QTest::qWait(1500); // this is ridiculously necessary because of effects combined with slowness of VMs -#ifdef Q_OS_MACOS // wait for desktop on screen to scroll into place - QTest::qWait(1000); -#endif + // this is necessary because of scrolling effects combined with potential slowness of VMs + QTest::qWait(1500); QSize expectedGrabSize = grabRect.isValid() ? grabRect.size() : (grabWindow ? windowRect.size() : screen->size()); // we ask for pixel coordinates, but will get a pixmap with device-specific DPR -- cgit v1.2.3