Baseline tests: avoid rendering items that are blacklisted on the server

Blacklisting items on the baseline server would avoid any mismatch
failures for such items. However, they would still be rendered. That
is undesirable if the rendering itself has unwanted side effects for
such items, e.g. crashing the test executable.

Fix by adding new functionality in the baseline testing framework to
allow checking blacklisting status ahead of time, and add a new macro
QBASELINE_SKIP_IF_BLACKLISTED to do just that.

Add usage of that macro to the QPainter baseline test.

Pick-to: 6.5 6.2
Change-Id: I35f6df8cff2c6cb985c25ab5470cd42b53d44940
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 4449dbe73704e328c4645f1e9ae7455622b8968f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eirik Aavitsland 2024-02-09 14:39:12 +01:00 committed by Qt Cherry-pick Bot
parent 4b5e899114
commit 7fb362ab59
3 changed files with 35 additions and 10 deletions

View File

@ -54,7 +54,7 @@ private:
private slots: private slots:
void initTestCase(); void initTestCase();
void cleanupTestCase() {} void init();
void testRasterARGB32PM_data(); void testRasterARGB32PM_data();
void testRasterARGB32PM(); void testRasterARGB32PM();
@ -133,6 +133,11 @@ void tst_Lancelot::initTestCase()
#endif #endif
} }
void tst_Lancelot::init()
{
// This gets called for every row. QSKIP if current item is blacklisted on the baseline server:
QBASELINE_SKIP_IF_BLACKLISTED;
}
void tst_Lancelot::testRasterARGB32PM_data() void tst_Lancelot::testRasterARGB32PM_data()
{ {

View File

@ -372,22 +372,21 @@ QTestData &newRow(const char *dataTag, quint16 checksum)
return QTest::newRow(dataTag); return QTest::newRow(dataTag);
} }
const ImageItem *findCurrentItem(QByteArray *msg, bool *error)
bool testImage(const QImage& img, QByteArray *msg, bool *error)
{ {
if (!connected && !connect(msg, error)) if (!connected && !connect(msg, error))
return true; return nullptr;
if (QTest::currentTestFunction() != curFunction || itemList.isEmpty()) { if (QTest::currentTestFunction() != curFunction || itemList.isEmpty()) {
qWarning() << "Usage error: QBASELINE_TEST used without corresponding QBaselineTest::newRow()"; qWarning() << "Usage error: QBASELINE_ macro used without corresponding QBaselineTest::newRow()";
return true; return nullptr;
} }
if (!gotBaselines) { if (!gotBaselines) {
if (!proto.requestBaselineChecksums(QString::fromLatin1(QTest::currentTestFunction()), &itemList) || itemList.isEmpty()) { if (!proto.requestBaselineChecksums(QString::fromLatin1(QTest::currentTestFunction()), &itemList) || itemList.isEmpty()) {
*msg = "Communication with baseline server failed: " + proto.errorMessage().toLatin1(); *msg = "Communication with baseline server failed: " + proto.errorMessage().toLatin1();
*error = true; *error = true;
return true; return nullptr;
} }
gotBaselines = true; gotBaselines = true;
} }
@ -397,10 +396,24 @@ bool testImage(const QImage& img, QByteArray *msg, bool *error)
while (it != itemList.constEnd() && it->itemName != curTag) while (it != itemList.constEnd() && it->itemName != curTag)
++it; ++it;
if (it == itemList.constEnd()) { if (it == itemList.constEnd()) {
qWarning() << "Usage error: QBASELINE_TEST used without corresponding QBaselineTest::newRow() for row" << curTag; qWarning() << "Usage error: QBASELINE_ macro used without corresponding QBaselineTest::newRow() for row" << curTag;
return true; return nullptr;
} }
return compareItem(*it, img, msg, error); return &(*it);
}
bool testImage(const QImage &img, QByteArray *msg, bool *error)
{
const ImageItem *item = findCurrentItem(msg, error);
return item ? compareItem(*item, img, msg, error) : true;
}
bool isCurrentItemBlacklisted()
{
QByteArray msg;
bool error = false;
const ImageItem *item = findCurrentItem(&msg, &error);
return item ? (item->status == ImageItem::IgnoreItem) : false;
} }
} }

View File

@ -18,6 +18,7 @@ bool connectToBaselineServer(QByteArray *msg = nullptr);
bool checkImage(const QImage& img, const char *name, quint16 checksum, QByteArray *msg, bool *error, int manualdatatag = 0); bool checkImage(const QImage& img, const char *name, quint16 checksum, QByteArray *msg, bool *error, int manualdatatag = 0);
bool testImage(const QImage& img, QByteArray *msg, bool *error); bool testImage(const QImage& img, QByteArray *msg, bool *error);
QTestData &newRow(const char *dataTag, quint16 checksum = 0); QTestData &newRow(const char *dataTag, quint16 checksum = 0);
bool isCurrentItemBlacklisted();
bool disconnectFromBaselineServer(); bool disconnectFromBaselineServer();
bool shouldAbortIfUnstable(); bool shouldAbortIfUnstable();
} }
@ -59,4 +60,10 @@ do {\
}\ }\
} while (0) } while (0)
#define QBASELINE_SKIP_IF_BLACKLISTED \
do {\
if (QBaselineTest::isCurrentItemBlacklisted())\
QSKIP("Blacklisted on baseline server.");\
} while (0)
#endif // BASELINETEST_H #endif // BASELINETEST_H