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>
43 lines
751 B
C++
43 lines
751 B
C++
// Copyright (C) 2021 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QImage>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QWidget;
|
|
|
|
class QWidgetBaselineTest : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QWidgetBaselineTest();
|
|
|
|
void takeStandardSnapshots();
|
|
QWidget *testWindow() const { return window; }
|
|
|
|
protected:
|
|
virtual void doInit() {}
|
|
virtual void doCleanup() {}
|
|
|
|
private slots:
|
|
void initTestCase();
|
|
void init();
|
|
void cleanup();
|
|
|
|
protected:
|
|
void makeVisible();
|
|
QImage takeSnapshot();
|
|
QImage takeScreenSnapshot(const QRect& rect = QRect());
|
|
|
|
private:
|
|
QWidget *background = nullptr;
|
|
QWidget *window = nullptr;
|
|
};
|
|
|
|
QT_END_NAMESPACE
|