Baseline testing: use a full screen background behind the test window
Some tests are flaky on macOS because the background desktop shows through the rounded corner of the test window. We cannot reliably control this on each platform, so instead make the test window a secondary window with a second, fullscreen and frameless window as the transient parent. This way, we have full control over the background pixels that might show through (semi-)transparent parts of the test window. Pick-to: 6.7 Change-Id: I44b7e834797b46fa8b44d776f6b91c99536a6cc9 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
a030795bc9
commit
a623293a13
@ -77,11 +77,14 @@ void QWidgetBaselineTest::initTestCase()
|
||||
void QWidgetBaselineTest::init()
|
||||
{
|
||||
QVERIFY(!window);
|
||||
window = new QWidget;
|
||||
background = new QWidget(nullptr, Qt::FramelessWindowHint);
|
||||
window = new QWidget(background, Qt::Window);
|
||||
window->setWindowTitle(QTest::currentDataTag());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
background->setScreen(QGuiApplication::primaryScreen());
|
||||
window->setScreen(QGuiApplication::primaryScreen());
|
||||
#endif
|
||||
background->move(QGuiApplication::primaryScreen()->availableGeometry().topLeft());
|
||||
window->move(QGuiApplication::primaryScreen()->availableGeometry().topLeft());
|
||||
|
||||
doInit();
|
||||
@ -91,13 +94,15 @@ void QWidgetBaselineTest::cleanup()
|
||||
{
|
||||
doCleanup();
|
||||
|
||||
delete window;
|
||||
delete background;
|
||||
background = nullptr;
|
||||
window = nullptr;
|
||||
}
|
||||
|
||||
void QWidgetBaselineTest::makeVisible()
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
background->showMaximized();
|
||||
window->show();
|
||||
QApplicationPrivate::setActiveWindow(window);
|
||||
QVERIFY(QTest::qWaitForWindowActive(window));
|
||||
|
@ -35,6 +35,7 @@ protected:
|
||||
QImage takeScreenSnapshot(const QRect& rect = QRect());
|
||||
|
||||
private:
|
||||
QWidget *background = nullptr;
|
||||
QWidget *window = nullptr;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user