summaryrefslogtreecommitdiffstats
path: root/tests/baseline/shared/qwidgetbaselinetest.h
blob: 0a1a7f92f0dbc5513799ac48c45e432483cebd36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#pragma once

#include <QObject>
#include <QImage>
#include <QJsonObject>

QT_BEGIN_NAMESPACE

class QWidget;

class QWidgetBaselineTest : public QObject
{
    Q_OBJECT

public:
    QWidgetBaselineTest();

    void takeStandardSnapshots();
    QWidget *testWindow() const { return window; }

    void reportDebugRect(const QString &type, const QColor &color,
        const QString &label, QRect widgetRect, const QWidget *widget, QPainter *painter);

protected:
    virtual void doInit() {}
    virtual void doCleanup() {}

protected slots:
    void initTestCase();
    void init();
    void cleanup();
    void cleanupTestCase();

protected:
    void makeVisible();
    QImage takeSnapshot();
    QImage takeScreenSnapshot(const QRect& rect = QRect());

    QJsonObject debugRects;
private:
    QWidget *background = nullptr;
    QWidget *window = nullptr;
};

QT_END_NAMESPACE