summaryrefslogtreecommitdiffstats
path: root/tests/baseline/shared/qwidgetbaselinetest.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <[email protected]>2024-12-10 16:35:07 +0100
committerVolker Hilsheimer <[email protected]>2024-12-10 23:45:41 +0100
commit3dc28cfae96a02e430060dead3a92f6b151fa863 (patch)
treebe453119a95ae2ef608aa2b3f65b0066b9a725e5 /tests/baseline/shared/qwidgetbaselinetest.cpp
parentb340fb69828bdbb101c3eeb0c773f554014bba77 (diff)
Baseline tests: prefer a screen with a DPR of 1.0
Move the windows to a screen with a 1.0 DPR, if the primary screen has a different ratio. This makes sure that we get reproducible runs also locally, no matter where e.g. the mouse pointer is (which on macOS defines which screen the window opens up). Change-Id: Iab7708c4abc0c97486f00a44a4b0a4c2b9406a62 Reviewed-by: Eirik Aavitsland <[email protected]>
Diffstat (limited to 'tests/baseline/shared/qwidgetbaselinetest.cpp')
-rw-r--r--tests/baseline/shared/qwidgetbaselinetest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/baseline/shared/qwidgetbaselinetest.cpp b/tests/baseline/shared/qwidgetbaselinetest.cpp
index 32fd3eef9b7..d5f03984ca0 100644
--- a/tests/baseline/shared/qwidgetbaselinetest.cpp
+++ b/tests/baseline/shared/qwidgetbaselinetest.cpp
@@ -109,7 +109,26 @@ void QWidgetBaselineTest::cleanupTestCase()
void QWidgetBaselineTest::makeVisible()
{
Q_ASSERT(window);
+
+ // prefer a screen with a 1.0 DPR
+ QScreen *preferredScreen = QGuiApplication::primaryScreen();
+ if (!qFuzzyCompare(QGuiApplication::primaryScreen()->devicePixelRatio(), 1.0)) {
+ for (const auto screen : QGuiApplication::screens()) {
+ if (qFuzzyCompare(screen->devicePixelRatio(), 1.0)) {
+ preferredScreen = screen;
+ break;
+ }
+ }
+ }
+
+ Q_ASSERT(preferredScreen);
+ const QRect preferredScreenRect = preferredScreen->availableGeometry();
+
+ background->setScreen(preferredScreen);
+ background->move(preferredScreenRect.topLeft());
background->showMaximized();
+ window->setScreen(preferredScreen);
+ window->move(preferredScreenRect.topLeft());
window->show();
QApplicationPrivate::setActiveWindow(window);
QVERIFY(QTest::qWaitForWindowActive(window));