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 <eirik.aavitsland@qt.io>
This commit is contained in:
parent
b340fb6982
commit
3dc28cfae9
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user