diff options
Diffstat (limited to 'tests/baseline/painting/tst_baseline_painting.cpp')
-rw-r--r-- | tests/baseline/painting/tst_baseline_painting.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/tests/baseline/painting/tst_baseline_painting.cpp b/tests/baseline/painting/tst_baseline_painting.cpp index a5d787f6ce..f486b33430 100644 --- a/tests/baseline/painting/tst_baseline_painting.cpp +++ b/tests/baseline/painting/tst_baseline_painting.cpp @@ -1,30 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// 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> @@ -66,7 +43,8 @@ private: }; void setupTestSuite(const QStringList& blacklist = QStringList()); - void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat()); + void runTestSuite(GraphicsEngine engine, QImage::Format format, + const QSurfaceFormat &contextFormat = QSurfaceFormat::defaultFormat()); void paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath); QStringList qpsFiles; @@ -76,7 +54,7 @@ private: private slots: void initTestCase(); - void cleanupTestCase() {} + void init(); void testRasterARGB32PM_data(); void testRasterARGB32PM(); @@ -112,6 +90,7 @@ private slots: void testCoreOpenGL_data(); void testCoreOpenGL(); private: + void initOpenGL(); bool checkSystemGLSupport(); bool checkSystemCoreGLSupport(); #endif @@ -143,13 +122,22 @@ 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)); } + +#ifndef QT_NO_OPENGL + initOpenGL(); +#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() { @@ -292,6 +280,14 @@ void tst_Lancelot::testPdf() #ifndef QT_NO_OPENGL +void tst_Lancelot::initOpenGL() +{ + // Stencil buffer is needed for clipping + QSurfaceFormat glFormat; + glFormat.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(glFormat); +} + bool tst_Lancelot::checkSystemGLSupport() { QWindow win; @@ -315,7 +311,7 @@ bool tst_Lancelot::checkSystemCoreGLSupport() if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) return false; - QSurfaceFormat coreFormat; + QSurfaceFormat coreFormat(QSurfaceFormat::defaultFormat()); coreFormat.setVersion(3, 2); coreFormat.setProfile(QSurfaceFormat::CoreProfile); QWindow win; @@ -370,7 +366,7 @@ void tst_Lancelot::testCoreOpenGL_data() void tst_Lancelot::testCoreOpenGL() { - QSurfaceFormat coreFormat; + QSurfaceFormat coreFormat(QSurfaceFormat::defaultFormat()); coreFormat.setVersion(3, 2); coreFormat.setProfile(QSurfaceFormat::CoreProfile); runTestSuite(OpenGL, QImage::Format_RGB32, coreFormat); @@ -427,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 @@ -480,7 +479,8 @@ QTEST_MAIN(tst_Lancelot) int main(int argc, char *argv[]) { - qSetGlobalQHashSeed(0); // Avoid rendering variations caused by QHash randomization + // Avoid rendering variations caused by QHash randomization + QHashSeed::setDeterministicGlobalSeed(); QBaselineTest::handleCmdLineArgs(&argc, &argv); return _realmain(argc, argv); |