Skip to content

Commit

Permalink
Baseline tests: prefer a screen with a DPR of 1.0
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
vohi committed Dec 10, 2024
1 parent b340fb6 commit 3dc28cf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/baseline/shared/qwidgetbaselinetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 3dc28cf

Please sign in to comment.