2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef BASELINETEST_H
|
|
|
|
#define BASELINETEST_H
|
|
|
|
|
|
|
|
#include <QTest>
|
2021-11-23 12:36:59 +00:00
|
|
|
#include <QString>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
namespace QBaselineTest {
|
2012-08-13 12:13:40 +00:00
|
|
|
void setAutoMode(bool mode);
|
|
|
|
void setSimFail(bool fail);
|
|
|
|
void handleCmdLineArgs(int *argcp, char ***argvp);
|
2022-01-10 14:16:18 +00:00
|
|
|
void setProject(const QString &projectName); // Selects server config settings and top level dir
|
|
|
|
void setProjectImageKeys(const QStringList &keys); // Overrides the ItemPathKeys config setting
|
2012-08-13 12:13:40 +00:00
|
|
|
void addClientProperty(const QString& key, const QString& value);
|
2022-03-15 14:44:34 +00:00
|
|
|
bool connectToBaselineServer(QByteArray *msg = nullptr);
|
2012-08-13 12:13:40 +00:00
|
|
|
bool checkImage(const QImage& img, const char *name, quint16 checksum, QByteArray *msg, bool *error, int manualdatatag = 0);
|
2011-04-27 10:05:43 +00:00
|
|
|
bool testImage(const QImage& img, QByteArray *msg, bool *error);
|
|
|
|
QTestData &newRow(const char *dataTag, quint16 checksum = 0);
|
2012-08-13 12:13:40 +00:00
|
|
|
bool disconnectFromBaselineServer();
|
2021-11-23 12:36:59 +00:00
|
|
|
bool shouldAbortIfUnstable();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define QBASELINE_CHECK_SUM(image, name, checksum)\
|
|
|
|
do {\
|
|
|
|
QByteArray _msg;\
|
|
|
|
bool _err = false;\
|
|
|
|
if (!QBaselineTest::checkImage((image), (name), (checksum), &_msg, &_err)) {\
|
|
|
|
QFAIL(_msg.constData());\
|
|
|
|
} else if (_err) {\
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP(_msg.constData());\
|
2011-04-27 10:05:43 +00:00
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
2022-01-14 08:04:31 +00:00
|
|
|
#define QBASELINE_CHECK_SUM_DEFERRED(image, name, checksum)\
|
|
|
|
do {\
|
|
|
|
QByteArray _msg;\
|
|
|
|
bool _err = false;\
|
|
|
|
if (!QBaselineTest::checkImage((image), (name), (checksum), &_msg, &_err)) {\
|
|
|
|
QTest::qFail(_msg.constData(), __FILE__, __LINE__);\
|
|
|
|
} else if (_err) {\
|
|
|
|
QSKIP(_msg.constData());\
|
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#define QBASELINE_CHECK(image, name) QBASELINE_CHECK_SUM(image, name, 0)
|
|
|
|
|
2022-01-14 08:04:31 +00:00
|
|
|
#define QBASELINE_CHECK_DEFERRED(image, name) QBASELINE_CHECK_SUM_DEFERRED(image, name, 0)
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#define QBASELINE_TEST(image)\
|
|
|
|
do {\
|
|
|
|
QByteArray _msg;\
|
|
|
|
bool _err = false;\
|
|
|
|
if (!QBaselineTest::testImage((image), &_msg, &_err)) {\
|
|
|
|
QFAIL(_msg.constData());\
|
|
|
|
} else if (_err) {\
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP(_msg.constData());\
|
2011-04-27 10:05:43 +00:00
|
|
|
}\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#endif // BASELINETEST_H
|