summaryrefslogtreecommitdiffstats
path: root/tests/baseline
diff options
context:
space:
mode:
Diffstat (limited to 'tests/baseline')
-rw-r--r--tests/baseline/CMakeLists.txt2
-rw-r--r--tests/baseline/painting/CMakeLists.txt2
-rw-r--r--tests/baseline/painting/scripts/aliasing.qps13
-rw-r--r--tests/baseline/painting/tst_baseline_painting.cpp37
-rw-r--r--tests/baseline/shared/baselineprotocol.cpp15
-rw-r--r--tests/baseline/shared/baselineprotocol.h5
-rw-r--r--tests/baseline/shared/lookup3.cpp2
-rw-r--r--tests/baseline/shared/paintcommands.cpp11
-rw-r--r--tests/baseline/shared/paintcommands.h4
-rw-r--r--tests/baseline/shared/qbaselinetest.cpp75
-rw-r--r--tests/baseline/shared/qbaselinetest.h14
-rw-r--r--tests/baseline/shared/qwidgetbaselinetest.cpp49
-rw-r--r--tests/baseline/shared/qwidgetbaselinetest.h3
-rw-r--r--tests/baseline/stylesheet/qss/qheaderview/selectedFontWeight.qss16
-rw-r--r--tests/baseline/stylesheet/tst_baseline_stylesheet.cpp30
-rw-r--r--tests/baseline/text/data/colored_list.html68
-rw-r--r--tests/baseline/text/tst_baseline_text.cpp32
-rw-r--r--tests/baseline/widgets/tst_baseline_widgets.cpp15
18 files changed, 284 insertions, 109 deletions
diff --git a/tests/baseline/CMakeLists.txt b/tests/baseline/CMakeLists.txt
index 97d0a13e3e..037ffd9e0e 100644
--- a/tests/baseline/CMakeLists.txt
+++ b/tests/baseline/CMakeLists.txt
@@ -1,7 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-if(TARGET Qt::Gui AND TARGET Qt::Network)
+if(TARGET Qt::Gui AND TARGET Qt::Network AND QT_FEATURE_pdf)
add_subdirectory(painting)
endif()
if(TARGET Qt::Network AND TARGET Qt::Widgets)
diff --git a/tests/baseline/painting/CMakeLists.txt b/tests/baseline/painting/CMakeLists.txt
index 1c2100b596..72e737d227 100644
--- a/tests/baseline/painting/CMakeLists.txt
+++ b/tests/baseline/painting/CMakeLists.txt
@@ -17,6 +17,8 @@ qt_internal_add_test(tst_baseline_painting
../shared/qbaselinetest.cpp ../shared/qbaselinetest.h
../shared/paintcommands.cpp ../shared/paintcommands.h
tst_baseline_painting.cpp
+ NO_PCH_SOURCES
+ tst_baseline_painting.cpp # undef QT_NO_FOREACH
INCLUDE_DIRECTORIES
../shared
LIBRARIES
diff --git a/tests/baseline/painting/scripts/aliasing.qps b/tests/baseline/painting/scripts/aliasing.qps
index 59878f9c4d..1fb0113396 100644
--- a/tests/baseline/painting/scripts/aliasing.qps
+++ b/tests/baseline/painting/scripts/aliasing.qps
@@ -19,6 +19,17 @@ begin_block drawing
setPen black
drawText 0 68 "QwErTy@"
+ setPen green 1 SolidLine
+ drawLine 0 75 10 75
+ setPen 800000ff 1
+ drawPoint 0 75
+ drawPoint 10 75
+
+ setPen green 2 SolidLine
+ drawLine 20 75 30 75
+ setPen 800000ff 2
+ drawPoint 20 75
+ drawPoint 30 75
setPen black 1
setBrush 7f7fff
@@ -153,4 +164,4 @@ drawText 15 185 "1.0"
resetMatrix
drawText 430 95 "Aliased"
-drawText 430 275 "Anti-Aliased" \ No newline at end of file
+drawText 430 275 "Anti-Aliased"
diff --git a/tests/baseline/painting/tst_baseline_painting.cpp b/tests/baseline/painting/tst_baseline_painting.cpp
index f9738b61e8..c8de08e7d2 100644
--- a/tests/baseline/painting/tst_baseline_painting.cpp
+++ b/tests/baseline/painting/tst_baseline_painting.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "paintcommands.h"
#include <qbaselinetest.h>
@@ -52,7 +54,7 @@ private:
private slots:
void initTestCase();
- void cleanupTestCase() {}
+ void init();
void testRasterARGB32PM_data();
void testRasterARGB32PM();
@@ -120,7 +122,7 @@ void tst_Lancelot::initTestCase()
std::sort(qpsFiles.begin(), qpsFiles.end());
foreach (const QString& fileName, qpsFiles) {
QFile file(scriptsDir + fileName);
- file.open(QFile::ReadOnly);
+ QVERIFY(file.open(QFile::ReadOnly));
QByteArray cont = file.readAll();
scripts.insert(fileName, QString::fromUtf8(cont).split(QLatin1Char('\n'), Qt::SkipEmptyParts));
scriptChecksums.insert(fileName, qChecksum(cont));
@@ -131,6 +133,11 @@ void tst_Lancelot::initTestCase()
#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()
{
@@ -416,19 +423,22 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4));
QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf"));
- pdfFile.open();
+ QVERIFY(pdfFile.open());
QPdfWriter writer(&pdfFile);
writer.setPdfVersion(QPdfWriter::PdfVersion_1_6);
- writer.setResolution(150);
+ QPageSize pageSize(QSize(800, 800), QStringLiteral("LancePage"), QPageSize::ExactMatch);
+ writer.setPageSize(pageSize);
+ writer.setPageMargins(QMarginsF());
+ writer.setResolution(72);
paint(&writer, engine, format, script, QFileInfo(filePath).absoluteFilePath());
pdfFile.close();
// Convert pdf to something we can read into a QImage, using macOS' sips utility
QTemporaryFile pngFile(tempStem + QLatin1String(".png"));
- pngFile.open(); // Just create the file name
+ QVERIFY(pngFile.open()); // Just create the file name
pngFile.close();
QProcess proc;
- const char *rawArgs = "-s format png --cropOffset 20 20 -c 800 800 -o";
+ const char *rawArgs = "-s format png -o";
QStringList argList = QString::fromLatin1(rawArgs).split(QLatin1Char(' '));
proc.start(QLatin1String("sips"), argList << pngFile.fileName() << pdfFile.fileName());
proc.waitForFinished(2 * 60 * 1000); // May need some time
@@ -463,17 +473,6 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Fo
p.end();
}
-#define main _realmain
-QTEST_MAIN(tst_Lancelot)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Lancelot);
#include "tst_baseline_painting.moc"
diff --git a/tests/baseline/shared/baselineprotocol.cpp b/tests/baseline/shared/baselineprotocol.cpp
index b77d3fc6cf..311b003c07 100644
--- a/tests/baseline/shared/baselineprotocol.cpp
+++ b/tests/baseline/shared/baselineprotocol.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "baselineprotocol.h"
#include <QLibraryInfo>
#include <QImage>
@@ -261,18 +261,21 @@ bool BaselineProtocol::disconnect()
}
-bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const PlatformInfo& clientInfo)
+bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const PlatformInfo &clientInfo, const QString &server)
{
errMsg.clear();
- QByteArray serverName(qgetenv("QT_LANCELOT_SERVER"));
- if (serverName.isNull())
- serverName = "lancelot.test.qt-project.org";
+ QString serverName = server;
+ if (serverName.isEmpty()) {
+ serverName = qEnvironmentVariable("QT_LANCELOT_SERVER");
+ if (serverName.isEmpty())
+ serverName = QStringLiteral("lancelot.test.qt-project.org");
+ }
socket.connectToHost(serverName, ServerPort);
if (!socket.waitForConnected(Timeout)) {
QThread::sleep(std::chrono::seconds{3}); // Wait a bit and try again, the server might just be restarting
if (!socket.waitForConnected(Timeout)) {
- errMsg += QLS("TCP connectToHost failed. Host:") + QLS(serverName) + QLS(" port:") + QString::number(ServerPort);
+ errMsg += QLS("TCP connectToHost failed. Host:") + serverName + QLS(" port:") + QString::number(ServerPort);
return false;
}
}
diff --git a/tests/baseline/shared/baselineprotocol.h b/tests/baseline/shared/baselineprotocol.h
index 4696900d91..93d416fcd8 100644
--- a/tests/baseline/shared/baselineprotocol.h
+++ b/tests/baseline/shared/baselineprotocol.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef BASELINEPROTOCOL_H
#define BASELINEPROTOCOL_H
@@ -115,7 +115,8 @@ public:
// For client:
// For advanced client:
- bool connect(const QString &testCase, bool *dryrun = nullptr, const PlatformInfo& clientInfo = PlatformInfo());
+ bool connect(const QString &testCase, bool *dryrun = nullptr,
+ const PlatformInfo &clientInfo = PlatformInfo(), const QString &server = QString());
bool disconnect();
bool requestBaselineChecksums(const QString &testFunction, ImageItemList *itemList);
bool submitMatch(const ImageItem &item, QByteArray *serverMsg);
diff --git a/tests/baseline/shared/lookup3.cpp b/tests/baseline/shared/lookup3.cpp
index bb91b3ac06..7964a184ae 100644
--- a/tests/baseline/shared/lookup3.cpp
+++ b/tests/baseline/shared/lookup3.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/*
diff --git a/tests/baseline/shared/paintcommands.cpp b/tests/baseline/shared/paintcommands.cpp
index 1af6de1e08..2cb3cd3bba 100644
--- a/tests/baseline/shared/paintcommands.cpp
+++ b/tests/baseline/shared/paintcommands.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "paintcommands.h"
#include <qdir.h>
@@ -173,6 +173,7 @@ const char *PaintCommands::imageFormatTable[] = {
"RGBx32FPx4",
"RGBA32FPx4",
"RGBA32FPx4_Premultiplied",
+ "CMYK32",
};
const char *PaintCommands::renderHintTable[] = {
@@ -449,10 +450,12 @@ void PaintCommands::staticInit()
"^drawGlyphRun\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
"drawGlyphRun <x> <y> <text> - Will create glyph run using QTextLayout and draw this",
"drawGlyphRun 10 10 \"my text\"");
+#ifndef QT_NO_TEXTHTMLPARSER
DECL_PAINTCOMMAND("drawTextDocument", command_drawTextDocument,
"^drawTextDocument\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
"drawTextDocument <x> <y> <html>",
"drawTextDocument 10 10 \"html\"");
+#endif
DECL_PAINTCOMMAND("drawTiledPixmap", command_drawTiledPixmap,
"^drawTiledPixmap\\s+([\\w.:\\/]*)"
"\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)\\s*(-?\\w*)"
@@ -745,8 +748,8 @@ void PaintCommands::runCommand(const QString &scriptLine)
return;
}
QString firstWord = scriptLine.section(separators, 0, 0);
- QList<int> indices = s_commandHash.values(firstWord);
- foreach(int idx, indices) {
+ const QList<int> indices = s_commandHash.values(firstWord);
+ for (int idx : indices) {
PaintCommandInfos command = s_commandInfoTable.at(idx);
Q_ASSERT(command.regExp.isValid());
QRegularExpressionMatch match = command.regExp.match(scriptLine);
@@ -1403,6 +1406,7 @@ void PaintCommands::command_drawGlyphRun(QRegularExpressionMatch re)
m_painter->drawGlyphRun(QPointF(x, y), glyphRun);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re)
{
if (!m_shouldDrawText)
@@ -1424,6 +1428,7 @@ void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re)
doc.drawContents(m_painter);
m_painter->restore();
}
+#endif
/***************************************************************************************************/
void PaintCommands::command_fillRect(QRegularExpressionMatch re)
diff --git a/tests/baseline/shared/paintcommands.h b/tests/baseline/shared/paintcommands.h
index a243ef1d75..de412e246e 100644
--- a/tests/baseline/shared/paintcommands.h
+++ b/tests/baseline/shared/paintcommands.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PAINTCOMMANDS_H
#define PAINTCOMMANDS_H
@@ -179,7 +179,9 @@ private:
void command_drawText(QRegularExpressionMatch re);
void command_drawStaticText(QRegularExpressionMatch re);
void command_drawGlyphRun(QRegularExpressionMatch re);
+#ifndef QT_NO_TEXTHTMLPARSER
void command_drawTextDocument(QRegularExpressionMatch re);
+#endif
void command_drawTiledPixmap(QRegularExpressionMatch re);
void command_fillRect(QRegularExpressionMatch re);
void command_fillRectF(QRegularExpressionMatch re);
diff --git a/tests/baseline/shared/qbaselinetest.cpp b/tests/baseline/shared/qbaselinetest.cpp
index 197b13a288..964266f1b4 100644
--- a/tests/baseline/shared/qbaselinetest.cpp
+++ b/tests/baseline/shared/qbaselinetest.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qbaselinetest.h"
#include "baselineprotocol.h"
@@ -11,6 +11,7 @@
namespace QBaselineTest {
static char *fargv[MAXCMDLINEARGS];
+static QString server;
static bool simfail = false;
static PlatformInfo customInfo;
static bool customAutoModeSet = false;
@@ -33,6 +34,7 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
return;
bool showHelp = false;
+ bool abortOnHelp = true;
int fargc = 0;
int numArgs = *argcp;
@@ -41,7 +43,16 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
QByteArray arg = (*argvp)[i];
QByteArray nextArg = (i+1 < numArgs) ? (*argvp)[i+1] : nullptr;
- if (arg == "-simfail") {
+ if (arg == "-server") {
+ i++;
+ if (!nextArg.isEmpty()) {
+ server = QString::fromLocal8Bit(nextArg);
+ } else {
+ qWarning() << "-server requires parameter";
+ showHelp = true;
+ break;
+ }
+ } else if (arg == "-simfail") {
simfail = true;
} else if (arg == "-fuzzlevel") {
i++;
@@ -77,10 +88,13 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
}
customInfo.addOverride(key, value);
} else {
- if ( (arg == "-help") || (arg == "--help") )
+ if ( (arg == "-help") || (arg == "--help") ) {
showHelp = true;
+ abortOnHelp = false;
+ }
if (fargc >= MAXCMDLINEARGS) {
qWarning() << "Too many command line arguments!";
+ showHelp = true;
break;
}
fargv[fargc++] = (*argvp)[i];
@@ -93,7 +107,9 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
// TBD: arrange for this to be printed *after* QTest's help
QTextStream out(stdout);
out << "\n Baseline testing (lancelot) options:\n";
- out << " -simfail : Force an image comparison mismatch. For testing purposes.\n";
+ out << " -server <host> : Set the network baseline server to connect to.\n";
+ out << " The default is taken from the environment variable QT_LANCELOT_SERVER.\n";
+ out << " -simfail : Force an image comparison mismatch. For development purposes.\n";
out << " -fuzzlevel <int> : Specify the percentage of fuzziness in comparison. Overrides server default. 0 means exact match.\n";
out << " -auto : Inform server that this run is done by a daemon, CI system or similar.\n";
out << " -adhoc (default) : The inverse of -auto; this run is done by human, e.g. for testing.\n";
@@ -104,6 +120,9 @@ void handleCmdLineArgs(int *argcp, char ***argvp)
out << " for example: -compareto QtVersion=4.8.0\n";
out << " Multiple -compareto client specifications may be given.\n";
out << "\n";
+ out.flush();
+ if (abortOnHelp)
+ std::exit(1);
}
}
@@ -182,7 +201,7 @@ bool connect(QByteArray *msg, bool *error)
return false;
}
- if (!proto.connect(testCase, &dryRunMode, clientInfo)) {
+ if (!proto.connect(testCase, &dryRunMode, clientInfo, server)) {
*msg += "Failed to connect to baseline server: " + proto.errorMessage().toLatin1();
*error = true;
return false;
@@ -249,6 +268,7 @@ void modifyImage(QImage *img)
bool compareItem(const ImageItem &baseline, const QImage &img, QByteArray *msg, bool *error)
{
+ *error = false;
ImageItem item = baseline;
if (simfail) {
// Simulate test failure by forcing image mismatch; for testing purposes
@@ -259,6 +279,7 @@ bool compareItem(const ImageItem &baseline, const QImage &img, QByteArray *msg,
} else {
item.image = img;
}
+ bool isNewItem = false;
item.imageChecksums.clear();
item.imageChecksums.prepend(ImageItem::computeChecksum(item.image));
QByteArray srvMsg;
@@ -270,9 +291,11 @@ bool compareItem(const ImageItem &baseline, const QImage &img, QByteArray *msg,
return true;
break;
case ImageItem::BaselineNotFound:
- if (!customInfo.overrides().isEmpty() || baselinePolicy == UploadNone) {
- qWarning() << "Cannot compare to baseline: No such baseline found on server.";
+ if (!customInfo.overrides().isEmpty())
return true;
+ if (baselinePolicy == UploadNone) {
+ isNewItem = true;
+ break;
}
if (proto.submitNewBaseline(item, &srvMsg))
qDebug() << msg->constData() << "Baseline not found on server. New baseline uploaded.";
@@ -285,7 +308,6 @@ bool compareItem(const ImageItem &baseline, const QImage &img, QByteArray *msg,
return true;
break;
}
- *error = false;
// The actual comparison of the given image with the baseline:
if (baseline.imageChecksums.contains(item.imageChecksums.at(0))) {
if (!proto.submitMatch(item, &srvMsg))
@@ -306,7 +328,11 @@ bool compareItem(const ImageItem &baseline, const QImage &img, QByteArray *msg,
qInfo() << "Baseline server reports:" << srvMsg;
return true; // The server decides: a fuzzy match means no mismatch
}
- *msg += "Mismatch. See report:\n " + srvMsg;
+ if (isNewItem)
+ *msg += "No baseline on server, so cannot compare.";
+ else
+ *msg += "Mismatch.";
+ *msg += " See report:\n " + srvMsg;
if (dryRunMode) {
qDebug() << "Dryrun, so ignoring" << *msg;
return true;
@@ -372,22 +398,21 @@ QTestData &newRow(const char *dataTag, quint16 checksum)
return QTest::newRow(dataTag);
}
-
-bool testImage(const QImage& img, QByteArray *msg, bool *error)
+const ImageItem *findCurrentItem(QByteArray *msg, bool *error)
{
if (!connected && !connect(msg, error))
- return true;
+ return nullptr;
if (QTest::currentTestFunction() != curFunction || itemList.isEmpty()) {
- qWarning() << "Usage error: QBASELINE_TEST used without corresponding QBaselineTest::newRow()";
- return true;
+ qWarning() << "Usage error: QBASELINE_ macro used without corresponding QBaselineTest::newRow()";
+ return nullptr;
}
if (!gotBaselines) {
if (!proto.requestBaselineChecksums(QString::fromLatin1(QTest::currentTestFunction()), &itemList) || itemList.isEmpty()) {
*msg = "Communication with baseline server failed: " + proto.errorMessage().toLatin1();
*error = true;
- return true;
+ return nullptr;
}
gotBaselines = true;
}
@@ -397,10 +422,24 @@ bool testImage(const QImage& img, QByteArray *msg, bool *error)
while (it != itemList.constEnd() && it->itemName != curTag)
++it;
if (it == itemList.constEnd()) {
- qWarning() << "Usage error: QBASELINE_TEST used without corresponding QBaselineTest::newRow() for row" << curTag;
- return true;
+ qWarning() << "Usage error: QBASELINE_ macro used without corresponding QBaselineTest::newRow() for row" << curTag;
+ 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;
}
}
diff --git a/tests/baseline/shared/qbaselinetest.h b/tests/baseline/shared/qbaselinetest.h
index 2d605b0e2b..73bb5dfda9 100644
--- a/tests/baseline/shared/qbaselinetest.h
+++ b/tests/baseline/shared/qbaselinetest.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef BASELINETEST_H
#define BASELINETEST_H
@@ -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 testImage(const QImage& img, QByteArray *msg, bool *error);
QTestData &newRow(const char *dataTag, quint16 checksum = 0);
+bool isCurrentItemBlacklisted();
bool disconnectFromBaselineServer();
bool shouldAbortIfUnstable();
}
@@ -59,4 +60,15 @@ do {\
}\
} while (0)
+#define QBASELINE_SKIP_IF_BLACKLISTED \
+do {\
+ if (QBaselineTest::isCurrentItemBlacklisted())\
+ QSKIP("Blacklisted on baseline server.");\
+} while (0)
+
+#define QBASELINETEST_MAIN(TestObject) QTEST_MAIN_WRAPPER(TestObject, \
+ QHashSeed::setDeterministicGlobalSeed(); \
+ QBaselineTest::handleCmdLineArgs(&argc, &argv); \
+ QTEST_MAIN_SETUP())
+
#endif // BASELINETEST_H
diff --git a/tests/baseline/shared/qwidgetbaselinetest.cpp b/tests/baseline/shared/qwidgetbaselinetest.cpp
index 9d49be5e73..72a074e268 100644
--- a/tests/baseline/shared/qwidgetbaselinetest.cpp
+++ b/tests/baseline/shared/qwidgetbaselinetest.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qwidgetbaselinetest.h"
@@ -77,11 +77,15 @@ 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());
+ window->setFocusPolicy(Qt::StrongFocus);
#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,19 +95,21 @@ 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));
- // explicitly unset focus, the test needs to control when focus is shown
- if (window->focusWidget())
- window->focusWidget()->clearFocus();
+ // explicitly set focus on the window so that the test widget doesn't have it
+ window->setFocus(Qt::OtherFocusReason);
+ QTRY_COMPARE(window->focusWidget(), window);
}
/*
@@ -124,8 +130,9 @@ QImage QWidgetBaselineTest::takeSnapshot()
*/
QImage QWidgetBaselineTest::takeScreenSnapshot(const QRect& windowRect)
{
- // make sure all effects are done
- QTest::qWait(250);
+ // make sure all effects are done - wait longer here because entire
+ // windows might be fading in and out.
+ QTest::qWait(750);
return window->screen()->grabWindow(0, windowRect.x(), windowRect.y(),
windowRect.width(), windowRect.height()).toImage();
}
@@ -140,23 +147,25 @@ QImage QWidgetBaselineTest::takeScreenSnapshot(const QRect& windowRect)
void QWidgetBaselineTest::takeStandardSnapshots()
{
makeVisible();
- struct PublicWidget : QWidget {
- bool focusNextPrevChild(bool next) override { return QWidget::focusNextPrevChild(next); }
- };
+ QWidget *oldFocusWidget = testWindow()->focusWidget();
+ QCOMPARE(oldFocusWidget, testWindow());
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "default");
// try hard to set focus
- static_cast<PublicWidget*>(window)->focusNextPrevChild(true);
- if (!window->focusWidget()) {
- QWidget *firstChild = window->findChild<QWidget*>();
- if (firstChild)
- firstChild->setFocus();
- }
-
- if (testWindow()->focusWidget()) {
+ QWidget *testWidget = window->nextInFocusChain();
+ if (!testWidget)
+ testWidget = window->findChild<QWidget*>();
+ QVERIFY(testWidget);
+ // use TabFocusReason, some widgets handle that specifically to e.g. select
+ testWidget->setFocus(Qt::TabFocusReason);
+
+ if (testWindow()->focusWidget() != oldFocusWidget) {
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "focused");
- testWindow()->focusWidget()->clearFocus();
+ // set focus back
+ oldFocusWidget->setFocus(Qt::OtherFocusReason);
+ } else {
+ qWarning() << "Couldn't set focus on tested widget" << testWidget;
}
// this disables all children
diff --git a/tests/baseline/shared/qwidgetbaselinetest.h b/tests/baseline/shared/qwidgetbaselinetest.h
index 9f029e7a75..2142217c09 100644
--- a/tests/baseline/shared/qwidgetbaselinetest.h
+++ b/tests/baseline/shared/qwidgetbaselinetest.h
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
@@ -35,6 +35,7 @@ protected:
QImage takeScreenSnapshot(const QRect& rect = QRect());
private:
+ QWidget *background = nullptr;
QWidget *window = nullptr;
};
diff --git a/tests/baseline/stylesheet/qss/qheaderview/selectedFontWeight.qss b/tests/baseline/stylesheet/qss/qheaderview/selectedFontWeight.qss
new file mode 100644
index 0000000000..1c45a99767
--- /dev/null
+++ b/tests/baseline/stylesheet/qss/qheaderview/selectedFontWeight.qss
@@ -0,0 +1,16 @@
+QHeaderView::section {
+ background-color: red;
+ font-size: 10px;
+}
+
+QHeaderView::section:checked {
+ background-color: green;
+ font-size: 20px;
+ font-weight: bold;
+}
+
+QHeaderView::section:first {
+ background-color: yellow;
+ font-size: 20px;
+ font-weight: normal;
+}
diff --git a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
index 3a4d8e8f15..1028c68250 100644
--- a/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
+++ b/tests/baseline/stylesheet/tst_baseline_stylesheet.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qbaselinetest.h>
#include <qwidgetbaselinetest.h>
@@ -27,6 +27,9 @@ private slots:
void tst_QTreeView_data();
void tst_QTreeView();
+ void tst_QHeaderView_data();
+ void tst_QHeaderView();
+
private:
QDir styleSheetDir;
};
@@ -63,7 +66,7 @@ void tst_Stylesheet::loadTestFiles()
for (const auto &qssFile : qssFiles) {
QFileInfo fileInfo(qssFile);
QFile file(qssFile);
- file.open(QFile::ReadOnly);
+ QVERIFY(file.open(QFile::ReadOnly));
QString styleSheet = QString::fromUtf8(file.readAll());
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << styleSheet;
}
@@ -205,17 +208,22 @@ void tst_Stylesheet::tst_QTreeView()
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "itemSelected");
}
-#define main _realmain
-QTEST_MAIN(tst_Stylesheet)
-#undef main
-
-int main(int argc, char *argv[])
+void tst_Stylesheet::tst_QHeaderView_data()
{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
+ loadTestFiles();
+}
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
+void tst_Stylesheet::tst_QHeaderView()
+{
+ QHBoxLayout *layout = new QHBoxLayout;
+ QTableWidget *tw = new QTableWidget(10, 10);
+ tw->setCurrentCell(1, 1);
+ layout->addWidget(tw);
+ testWindow()->setLayout(layout);
+ makeVisible();
+ QBASELINE_TEST(takeSnapshot());
}
+QBASELINETEST_MAIN(tst_Stylesheet)
+
#include "tst_baseline_stylesheet.moc"
diff --git a/tests/baseline/text/data/colored_list.html b/tests/baseline/text/data/colored_list.html
new file mode 100644
index 0000000000..d1cca94460
--- /dev/null
+++ b/tests/baseline/text/data/colored_list.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html>
+<head>
+<style type="text/css">
+p, li { white-space: pre-wrap; }
+hr { height: 1px; border-width: 0; }
+li.unchecked::marker { content: "\2610"; }
+li.checked::marker { content: "\2612"; }
+body { background-color: #111155; color: #ffffff; }
+</style>
+</head>
+<body>
+
+<ul>
+<li>disc</li>
+<li style=" color:#a58d47;">bronze</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red bullet, pink text</span></li>
+<li style=" color:#dddddd;" class="checked">checked</li>
+<li style=" color:#dddddd;" class="unchecked">unchecked</li>
+</ul>
+
+<ul type="circle">
+<li>circle</li>
+<li style=" color:#dddddd;">silver</li>
+<li style=" color:lightgrey;"><span style=" color:#ffcdb9;">grey bullet, pink text</span></li>
+<li style=" color:#dddddd;" class="checked">checked</li>
+<li style=" color:#dddddd;" class="unchecked">unchecked</li>
+</ul>
+
+<ul type="square">
+<li style=" color:#ffffff;">square</li>
+<li style=" color:#fceebb;">gold</li>
+<li style=" color:yellow;"><span style=" color:#ffcdb9;">yellow bullet, pink text</span></li>
+<li style=" color:#dddddd;" class="checked">checked</li>
+<li style=" color:#dddddd;" class="unchecked">unchecked</li>
+</ul>
+
+<ol>
+<li>decimal</li>
+<li style=" color:#a58d47;">bronze decimal</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red number, pink text</span></li>
+</ol>
+
+<ol type="A">
+<li>uppercase</li>
+<li style=" color:#a58d47;">bronze uppercase</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red letter, pink text</span></li>
+</ol>
+
+<ol type="a">
+<li>lowercase</li>
+<li style=" color:#a58d47;">bronze lowercase</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red letter, pink text</span></li>
+</ol>
+
+<ol type="i">
+<li>lower roman</li>
+<li style=" color:#a58d47;">bronze roman</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red number, pink text</span></li>
+</ol>
+
+<ol type="I">
+<li>upper roman</li>
+<li style=" color:#a58d47;">bronze roman</li>
+<li style=" color:red;"><span style=" color:#ffcdb9;">red number, pink text</span></li>
+</ol>
+</body>
+</html>
diff --git a/tests/baseline/text/tst_baseline_text.cpp b/tests/baseline/text/tst_baseline_text.cpp
index 0d2c2d47f5..45c709b92f 100644
--- a/tests/baseline/text/tst_baseline_text.cpp
+++ b/tests/baseline/text/tst_baseline_text.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qbaselinetest.h>
#include <qwidgetbaselinetest.h>
@@ -17,6 +17,7 @@ public:
private slots:
void tst_render_data();
void tst_render();
+ void tst_differentScriptsBackgrounds();
private:
QDir htmlDir;
@@ -48,7 +49,7 @@ void tst_Text::loadTestFiles()
for (const auto &htmlFile : htmlFiles) {
QFileInfo fileInfo(htmlFile);
QFile file(htmlFile);
- file.open(QFile::ReadOnly);
+ QVERIFY(file.open(QFile::ReadOnly));
QString html = QString::fromUtf8(file.readAll());
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << html;
}
@@ -81,18 +82,27 @@ void tst_Text::tst_render()
QBASELINE_TEST(image);
}
+void tst_Text::tst_differentScriptsBackgrounds()
+{
+ QTextDocument textDocument;
+ textDocument.setPageSize(QSizeF(800, 600));
+ textDocument.setHtml(QString::fromUtf8("<i><font style=\"font-size:72px\"><font style=\"background:#FFFF00\">イ雨エ</font></font></i>"));
-#define main _realmain
-QTEST_MAIN(tst_Text)
-#undef main
+ QImage image(800, 600, QImage::Format_ARGB32);
+ image.fill(Qt::white);
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
+ {
+ QPainter painter(&image);
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
+ QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setColor(QPalette::Text, Qt::black);
+ textDocument.documentLayout()->draw(&painter, context);
+ }
+
+ QBASELINE_CHECK(image, "tst_differentScriptsBackgrounds");
}
+
+QBASELINETEST_MAIN(tst_Text)
+
#include "tst_baseline_text.moc"
diff --git a/tests/baseline/widgets/tst_baseline_widgets.cpp b/tests/baseline/widgets/tst_baseline_widgets.cpp
index 366a170459..ffabf9e07e 100644
--- a/tests/baseline/widgets/tst_baseline_widgets.cpp
+++ b/tests/baseline/widgets/tst_baseline_widgets.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qbaselinetest.h>
#include <qwidgetbaselinetest.h>
@@ -1275,17 +1275,6 @@ void tst_Widgets::tst_QLCDNumber()
QBASELINE_CHECK_DEFERRED(takeSnapshot(), "lcdnumber");
}
-#define main _realmain
-QTEST_MAIN(tst_Widgets)
-#undef main
-
-int main(int argc, char *argv[])
-{
- // Avoid rendering variations caused by QHash randomization
- QHashSeed::setDeterministicGlobalSeed();
-
- QBaselineTest::handleCmdLineArgs(&argc, &argv);
- return _realmain(argc, argv);
-}
+QBASELINETEST_MAIN(tst_Widgets)
#include "tst_baseline_widgets.moc"