summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r--tests/auto/gui/painting/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qbrush/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp36
-rw-r--r--tests/auto/gui/painting/qcolor/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp203
-rw-r--r--tests/auto/gui/painting/qcolorspace/CMakeLists.txt40
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.iccbin0 -> 8464 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/VideoHD.iccbin0 -> 786 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.iccbin0 -> 360 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.iccbin0 -> 63868 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp524
-rw-r--r--tests/auto/gui/painting/qcolortransform/CMakeLists.txt20
-rw-r--r--tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp380
-rw-r--r--tests/auto/gui/painting/qpagelayout/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp278
-rw-r--r--tests/auto/gui/painting/qpageranges/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp33
-rw-r--r--tests/auto/gui/painting/qpagesize/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp31
-rw-r--r--tests/auto/gui/painting/qpaintengine/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp29
-rw-r--r--tests/auto/gui/painting/qpainter/BLACKLIST3
-rw-r--r--tests/auto/gui/painting/qpainter/CMakeLists.txt208
-rw-r--r--tests/auto/gui/painting/qpainter/testdata.qrc186
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp338
-rw-r--r--tests/auto/gui/painting/qpainter/utils/createImages/main.cpp29
-rw-r--r--tests/auto/gui/painting/qpainterpath/BLACKLIST2
-rw-r--r--tests/auto/gui/painting/qpainterpath/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp139
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp29
-rw-r--r--tests/auto/gui/painting/qpathclipper/CMakeLists.txt16
-rw-r--r--tests/auto/gui/painting/qpathclipper/pathcompare.h29
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.cpp29
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.h29
-rw-r--r--tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp57
-rw-r--r--tests/auto/gui/painting/qpdfwriter/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp29
-rw-r--r--tests/auto/gui/painting/qpen/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp29
-rw-r--r--tests/auto/gui/painting/qpolygon/CMakeLists.txt13
-rw-r--r--tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp45
-rw-r--r--tests/auto/gui/painting/qregion/CMakeLists.txt11
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp29
-rw-r--r--tests/auto/gui/painting/qtransform/CMakeLists.txt13
-rw-r--r--tests/auto/gui/painting/qtransform/tst_qtransform.cpp29
46 files changed, 1813 insertions, 1174 deletions
diff --git a/tests/auto/gui/painting/CMakeLists.txt b/tests/auto/gui/painting/CMakeLists.txt
index 4f933139ca..b49a80b180 100644
--- a/tests/auto/gui/painting/CMakeLists.txt
+++ b/tests/auto/gui/painting/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from painting.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qpainterpath)
add_subdirectory(qpainterpathstroker)
@@ -9,14 +10,18 @@ add_subdirectory(qpagelayout)
add_subdirectory(qpageranges)
add_subdirectory(qpagesize)
add_subdirectory(qpainter)
-add_subdirectory(qpdfwriter)
+if (QT_FEATURE_pdf)
+ add_subdirectory(qpdfwriter)
+endif()
add_subdirectory(qpen)
add_subdirectory(qpaintengine)
add_subdirectory(qtransform)
add_subdirectory(qpolygon)
-# QTBUG-87669 # special case
+
+# QTBUG-87669
if(NOT ANDROID)
add_subdirectory(qcolorspace)
+ add_subdirectory(qcolortransform)
endif()
if(QT_FEATURE_private_tests)
add_subdirectory(qpathclipper)
diff --git a/tests/auto/gui/painting/qbrush/CMakeLists.txt b/tests/auto/gui/painting/qbrush/CMakeLists.txt
index c8dad25d94..313bce20a4 100644
--- a/tests/auto/gui/painting/qbrush/CMakeLists.txt
+++ b/tests/auto/gui/painting/qbrush/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qbrush.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qbrush Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qbrush LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qbrush
SOURCES
tst_qbrush.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index 490d127efc..678c8d9b32 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
@@ -456,10 +431,9 @@ void tst_QBrush::textureBrushStream()
QCOMPARE(loadedBrush1.style(), Qt::TexturePattern);
QCOMPARE(loadedBrush2.style(), Qt::TexturePattern);
-#ifdef Q_OS_ANDROID
- QEXPECT_FAIL("", "QTBUG-69193", Continue);
-#endif
- QCOMPARE(loadedBrush1.texture(), pixmap_source);
+ // pixmaps may have been converted to system format
+ QCOMPARE(loadedBrush1.texture().toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied),
+ pixmap_source.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied));
QCOMPARE(loadedBrush2.textureImage(), image_source);
}
diff --git a/tests/auto/gui/painting/qcolor/CMakeLists.txt b/tests/auto/gui/painting/qcolor/CMakeLists.txt
index 87753803fb..52e551855c 100644
--- a/tests/auto/gui/painting/qcolor/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolor/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qcolor.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcolor Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolor LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qcolor
SOURCES
tst_qcolor.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index a5a2983ce7..f592db5544 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -38,6 +13,12 @@
#include <private/qdrawingprimitive_sse2_p.h>
#include <qrgba64.h>
+#if QT_DEPRECATED_SINCE(6, 6)
+# define DEPRECATED_IN_6_6(...) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED __VA_ARGS__ QT_WARNING_POP
+#else
+# define DEPRECATED_IN_6_6(...)
+#endif
+
class tst_QColor : public QObject
{
Q_OBJECT
@@ -54,8 +35,8 @@ private slots:
void name();
void namehex_data();
void namehex();
- void setNamedColor_data();
- void setNamedColor();
+ void fromString_data();
+ void fromString();
void constructNamedColorWithSpace();
@@ -92,7 +73,7 @@ private slots:
void toCmykNonDestructive();
void toHsl_data();
- void toHsl();;
+ void toHsl();
void toHslNonDestructive();
void convertTo();
@@ -139,11 +120,11 @@ void tst_QColor::getSetCheck()
// void QColor::setAlphaF(float)
obj1.setAlphaF(0.0);
QCOMPARE(obj1.alphaF(), 0.0f); // range<0.0, 1.0>
- obj1.setAlphaF(-0.2);
+ obj1.setAlphaF(-0.2f);
QCOMPARE(obj1.alphaF(), 0.0f); // range<0.0, 1.0>
- obj1.setAlphaF(1.0);
+ obj1.setAlphaF(1.0f);
QCOMPARE(obj1.alphaF(), 1.0f); // range<0.0, 1.0>
- obj1.setAlphaF(1.1);
+ obj1.setAlphaF(1.1f);
QCOMPARE(obj1.alphaF(), 1.0f); // range<0.0, 1.0>
// int QColor::red()
@@ -243,13 +224,13 @@ void tst_QColor::isValid_data()
QTest::newRow("defaultConstructor") << QColor() << false;
QTest::newRow("rgbConstructor-valid") << QColor(2,5,7) << true;
QTest::newRow("rgbConstructor-invalid") << QColor(2,5,999) << false;
- QTest::newRow("nameQStringConstructor-valid") << QColor(QString("#ffffff")) << true;
- QTest::newRow("nameQStringConstructor-invalid") << QColor(QString("#ffffgg")) << false;
- QTest::newRow("nameQStringConstructor-empty") << QColor(QString("")) << false;
- QTest::newRow("nameQStringConstructor-named") << QColor(QString("red")) << true;
- QTest::newRow("nameCharConstructor-valid") << QColor("#ffffff") << true;
- QTest::newRow("nameCharConstructor-invalid") << QColor("#ffffgg") << false;
- QTest::newRow("nameCharConstructor-invalid-2") << QColor("#fffffg") << false;
+ QTest::newRow("nameQStringConstructor-valid") << QColor::fromString("#ffffff") << true;
+ QTest::newRow("nameQStringConstructor-invalid") << QColor::fromString("#ffffgg") << false;
+ QTest::newRow("nameQStringConstructor-empty") << QColor::fromString("") << false;
+ QTest::newRow("nameQStringConstructor-named") << QColor::fromString("red") << true;
+ QTest::newRow("nameCharConstructor-valid") << QColor::fromString("#ffffff") << true;
+ QTest::newRow("nameCharConstructor-invalid") << QColor::fromString("#ffffgg") << false;
+ QTest::newRow("nameCharConstructor-invalid-2") << QColor::fromString("#fffffg") << false;
}
void tst_QColor::isValid()
@@ -335,7 +316,10 @@ void tst_QColor::namehex()
{
QFETCH(QString, hexcolor);
QFETCH(QColor, color);
+ DEPRECATED_IN_6_6(
QCOMPARE(QColor(hexcolor), color);
+ )
+ QCOMPARE(QColor::fromString(hexcolor), color);
}
void tst_QColor::globalColors_data()
@@ -721,25 +705,36 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
#undef rgb
-void tst_QColor::setNamedColor_data()
+void tst_QColor::fromString_data()
{
+#if QT_DEPRECATED_SINCE(6, 6)
QTest::addColumn<QColor>("byCtor");
QTest::addColumn<QColor>("bySetNamedColor");
+#endif
+ QTest::addColumn<QColor>("byFromString");
QTest::addColumn<QColor>("expected");
for (const auto e : rgbTbl) {
QColor expected;
expected.setRgba(e.value);
-#define ROW(expr) \
- do { \
- QColor bySetNamedColor; \
- bySetNamedColor.setNamedColor(expr); \
- auto byCtor = QColor(expr); \
- QTest::addRow("%s: %s", e.name, #expr) \
- << byCtor << bySetNamedColor << expected; \
- } while (0) \
- /*end*/
+#define ROW(expr) row(expr, #expr)
+ auto row = [&] (auto expr, const char *exprS) {
+ QT_WARNING_PUSH
+ #if QT_DEPRECATED_SINCE(6, 6)
+ QT_WARNING_DISABLE_DEPRECATED
+ QColor bySetNamedColor;
+ bySetNamedColor.setNamedColor(expr);
+ auto byCtor = QColor(expr);
+ #endif
+ QTest::addRow("%s: %s", e.name, exprS)
+ #if QT_DEPRECATED_SINCE(6, 6)
+ << byCtor << bySetNamedColor
+ #endif
+ << QColor::fromString(expr)
+ << expected;
+ QT_WARNING_POP
+ };
const auto l1 = QLatin1String(e.name);
const auto l1UpperBA = QByteArray(e.name).toUpper();
@@ -766,29 +761,42 @@ void tst_QColor::setNamedColor_data()
}
}
-void tst_QColor::setNamedColor()
+void tst_QColor::fromString()
{
+#if QT_DEPRECATED_SINCE(6, 6)
QFETCH(QColor, byCtor);
QFETCH(QColor, bySetNamedColor);
+#endif
+ QFETCH(QColor, byFromString);
QFETCH(QColor, expected);
+#if QT_DEPRECATED_SINCE(6, 6)
QCOMPARE(byCtor, expected);
QCOMPARE(bySetNamedColor, expected);
+#endif
+ QCOMPARE(byFromString, expected);
}
void tst_QColor::constructNamedColorWithSpace()
{
+ DEPRECATED_IN_6_6(
QColor whiteSmoke("white smoke");
QCOMPARE(whiteSmoke, QColor(245, 245, 245));
+ )
+ QCOMPARE(QColor::fromString("white smoke"), QColorConstants::Svg::whitesmoke);
}
void tst_QColor::colorNames()
{
- QStringList all = QColor::colorNames();
+ const QStringList all = QColor::colorNames();
QCOMPARE(all.size(), rgbTblSize);
for (int i = 0; i < all.size(); ++i)
QCOMPARE(all.at(i), QLatin1String(rgbTbl[i].name));
+ for (const QString &name : all)
+ QVERIFY(QColor::isValidColorName(name));
+ for (const auto &e : rgbTbl)
+ QVERIFY(QColor::isValidColorName(e.name));
}
void tst_QColor::spec()
@@ -1421,58 +1429,58 @@ void tst_QColor::toRgb_data()
QTest::addColumn<QColor>("hslColor");
QTest::newRow("black")
- << QColor::fromRgbF(0.0, 0.0, 0.0)
- << QColor::fromHsvF(-1.0, 0.0, 0.0)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 1.0)
- << QColor::fromHslF(-1.0, 0.0, 0.0);
+ << QColor::fromRgbF(0.0f, 0.0f, 0.0f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 0.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 1.0f)
+ << QColor::fromHslF(-1.0f, 0.0f, 0.0f);
QTest::newRow("white")
- << QColor::fromRgbF(1.0, 1.0, 1.0)
- << QColor::fromHsvF(-1.0, 0.0, 1.0)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 0.0)
- << QColor::fromHslF(-1.0, 0.0, 1.0);
+ << QColor::fromRgbF(1.0f, 1.0f, 1.0f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(-1.0f, 0.0f, 1.0f);
QTest::newRow("red")
- << QColor::fromRgbF(1.0, 0.0, 0.0)
- << QColor::fromHsvF(0.0, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 1.0, 1.0, 0.0)
- << QColor::fromHslF(0.0, 1.0, 0.5, 1.0);
+ << QColor::fromRgbF(1.0f, 0.0f, 0.0f)
+ << QColor::fromHsvF(0.0f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 1.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.0f, 1.0f, 0.5f, 1.0f);
QTest::newRow("green")
- << QColor::fromRgbF(0.0, 1.0, 0.0)
- << QColor::fromHsvF(0.33333, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 0.0, 1.0, 0.0)
- << QColor::fromHslF(0.33333, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 1.0f, 0.0f)
+ << QColor::fromHsvF(0.33333f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0, 0.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.33333f, 1.0f, 0.5f);
QTest::newRow("blue")
- << QColor::fromRgbF(0.0, 0.0, 1.0)
- << QColor::fromHsvF(0.66667, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 1.0, 0.0, 0.0)
- << QColor::fromHslF(0.66667, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 0.0f, 1.0f)
+ << QColor::fromHsvF(0.66667f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0f, 1.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.66667f, 1.0f, 0.5f);
QTest::newRow("cyan")
- << QColor::fromRgbF(0.0, 1.0, 1.0)
- << QColor::fromHsvF(0.5, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0)
- << QColor::fromHslF(0.5, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 1.0f, 1.0f)
+ << QColor::fromHsvF(0.5f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0f, 0.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.5f, 1.0f, 0.5f);
QTest::newRow("magenta")
- << QColor::fromRgbF(1.0, 0.0, 1.0)
- << QColor::fromHsvF(0.83333, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 1.0, 0.0, 0.0)
- << QColor::fromHslF(0.83333, 1.0, 0.5);
+ << QColor::fromRgbF(1.0f, 0.0f, 1.0f)
+ << QColor::fromHsvF(0.83333f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 1.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.83333f, 1.0f, 0.5f);
QTest::newRow("yellow")
- << QColor::fromRgbF(1.0, 1.0, 0.0)
- << QColor::fromHsvF(0.16667, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 0.0, 1.0, 0.0)
- << QColor::fromHslF(0.16667, 1.0, 0.5);
+ << QColor::fromRgbF(1.0f, 1.0f, 0.0f)
+ << QColor::fromHsvF(0.16667f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.16667f, 1.0f, 0.5f);
QTest::newRow("gray")
- << QColor::fromRgbF(0.6431375, 0.6431375, 0.6431375)
- << QColor::fromHsvF(-1.0, 0.0, 0.6431375)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 0.356863)
- << QColor::fromHslF(-1.0, 0.0, 0.6431375);
+ << QColor::fromRgbF(0.6431375f, 0.6431375f, 0.6431375f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 0.6431375f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 0.356863f)
+ << QColor::fromHslF(-1.0f, 0.0f, 0.6431375f);
// ### add colors using the 0-255 functions
}
@@ -1503,7 +1511,7 @@ void tst_QColor::toHsv_data()
<< QColor::fromHsv(300, 255, 255)
<< QColor(255, 0, 255)
<< QColor::fromCmyk(0, 255, 0, 0)
- << QColor::fromHslF(300./360., 1., 0.5, 1.0);
+ << QColor::fromHslF(300.f/360.f, 1.f, 0.5f, 1.0f);
QTest::newRow("data1")
<< QColor::fromHsvF(1., 1., 1., 1.)
@@ -1514,7 +1522,7 @@ void tst_QColor::toHsv_data()
void tst_QColor::toRgbNonDestructive()
{
- QColor aColor = QColor::fromRgbF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromRgbF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toRgb());
}
@@ -1534,7 +1542,7 @@ void tst_QColor::toHsv()
void tst_QColor::toHsvNonDestructive()
{
- QColor aColor = QColor::fromHsvF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromHsvF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toHsv());
}
@@ -1546,7 +1554,7 @@ void tst_QColor::toCmyk_data()
QTest::addColumn<QColor>("hslColor");
QTest::newRow("data0")
- << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0)
+ << QColor::fromCmykF(1.0f, 0.0f, 0.0f, 0.0f)
<< QColor(0, 255, 255)
<< QColor::fromHsv(180, 255, 255)
<< QColor::fromHslF(180./360., 1., 0.5, 1.0);
@@ -1574,7 +1582,7 @@ void tst_QColor::toCmyk()
void tst_QColor::toCmykNonDestructive()
{
- QColor aColor = QColor::fromCmykF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromCmykF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toCmyk());
}
@@ -1587,13 +1595,13 @@ void tst_QColor::toHsl_data()
QTest::newRow("data0")
- << QColor::fromHslF(300./360., 1., 0.5, 1.0)
+ << QColor::fromHslF(300.f/360.f, 1., 0.5f, 1.0)
<< QColor::fromHsv(300, 255, 255)
<< QColor(255, 0, 255)
<< QColor::fromCmyk(0, 255, 0, 0);
QTest::newRow("data1")
- << QColor::fromHslF(1., 1., 0.5, 1.0)
+ << QColor::fromHslF(1., 1., 0.5f, 1.0)
<< QColor::fromHsvF(1., 1., 1., 1.)
<< QColor(255, 0, 0, 255)
<< QColor::fromCmykF(0., 1., 1., 0.);
@@ -1618,7 +1626,7 @@ void tst_QColor::toHsl()
void tst_QColor::toHslNonDestructive()
{
- QColor aColor = QColor::fromHslF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromHslF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toHsl());
}
@@ -1861,7 +1869,7 @@ void tst_QColor::qcolorprofile()
{
QFETCH(float, gammaC);
QFETCH(int, tolerance);
- QColorTrcLut *cp = QColorTrcLut::fromGamma(gammaC);
+ std::shared_ptr cp = QColorTrcLut::fromGamma(gammaC);
// Test we are accurate for most values after converting through gamma-correction.
int error = 0;
@@ -1872,7 +1880,6 @@ void tst_QColor::qcolorprofile()
error += qAbs(qRed(cin) - qRed(cout));
}
QVERIFY(error <= tolerance);
- delete cp;
}
QTEST_MAIN(tst_QColor)
diff --git a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
index 9e3460d363..383c1bb890 100644
--- a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
@@ -1,39 +1,33 @@
-# Generated from qcolorspace.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcolorspace Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolorspace LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
-file(GLOB_RECURSE test_data_glob
+file(GLOB_RECURSE test_data
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- resources/*)
-list(APPEND test_data ${test_data_glob})
+ resources/*
+)
+
+foreach(file IN LISTS test_data)
+ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
+endforeach()
qt_internal_add_test(tst_qcolorspace
SOURCES
tst_qcolorspace.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
TESTDATA ${test_data}
+ BUILTIN_TESTDATA
)
-
-file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "resources/*")
-foreach(file IN LISTS resource_glob_0)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-# Resources:
-set(qmake_immediate_resource_files
- ${resource_glob_0}
-)
-
-qt_internal_add_resource(tst_qcolorspace "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
diff --git a/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc b/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc
new file mode 100644
index 0000000000..b5a73495bf
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc b/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc
new file mode 100644
index 0000000000..b96eb68136
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc b/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc
new file mode 100644
index 0000000000..2187b6786a
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc b/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc
new file mode 100644
index 0000000000..30da950907
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index bc26552311..7505d463ed 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -61,9 +36,18 @@ private slots:
void imageConversion();
void imageConversion64_data();
void imageConversion64();
+ void imageConversion64PM_data();
+ void imageConversion64PM();
void imageConversionOverLargerGamut_data();
void imageConversionOverLargerGamut();
-
+ void imageConversionOverLargerGamut2_data();
+ void imageConversionOverLargerGamut2();
+ void imageConversionOverAnyGamutFP_data();
+ void imageConversionOverAnyGamutFP();
+ void imageConversionOverAnyGamutFP2_data();
+ void imageConversionOverAnyGamutFP2();
+ void imageConversionOverNonThreeComponentMatrix_data();
+ void imageConversionOverNonThreeComponentMatrix();
void loadImage();
void primaries();
@@ -80,6 +64,13 @@ private slots:
void changePrimaries();
void transferFunctionTable();
+
+ void description();
+ void whitePoint_data();
+ void whitePoint();
+ void setWhitePoint();
+ void grayColorSpace();
+ void grayColorSpaceEffectivelySRgb();
};
tst_QColorSpace::tst_QColorSpace()
@@ -197,15 +188,41 @@ void tst_QColorSpace::fromIccProfile_data()
QTest::addColumn<QString>("testProfile");
QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
QTest::addColumn<QColorSpace::TransferFunction>("transferFunction");
+ QTest::addColumn<QColorSpace::TransformModel>("transformModel");
+ QTest::addColumn<QColorSpace::ColorModel>("colorModel");
QTest::addColumn<QString>("description");
QString prefix = QFINDTESTDATA("resources/");
// Read the official sRGB ICCv2 profile:
QTest::newRow("sRGB2014 (ICCv2)") << prefix + "sRGB2014.icc" << QColorSpace::SRgb
- << QColorSpace::TransferFunction::SRgb << QString("sRGB2014");
+ << QColorSpace::TransferFunction::SRgb
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("sRGB2014");
// My monitor's profile:
QTest::newRow("HP ZR30w (ICCv4)") << prefix + "HP_ZR30w.icc" << QColorSpace::NamedColorSpace(0)
- << QColorSpace::TransferFunction::Gamma << QString("HP Z30i");
+ << QColorSpace::TransferFunction::Gamma
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("HP Z30i");
+ // A profile to HD TV
+ QTest::newRow("VideoHD") << prefix + "VideoHD.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Rgb << QString("HDTV (Rec. 709)");
+ // sRGB on PCSLab format
+ QTest::newRow("sRGB ICCv4 Appearance") << prefix + "sRGB_ICC_v4_Appearance.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Rgb << QString("sRGB_ICC_v4_Appearance.icc");
+ // Grayscale profile
+ QTest::newRow("sGrey-v4") << prefix + "sGrey-v4.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::SRgb
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Gray << QString("sGry");
+ // CMYK profile
+ QTest::newRow("CGATS compat") << prefix + "CGATS001Compat-v2-micro.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Cmyk << QString("uCMY");
}
void tst_QColorSpace::fromIccProfile()
@@ -213,10 +230,12 @@ void tst_QColorSpace::fromIccProfile()
QFETCH(QString, testProfile);
QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QFETCH(QColorSpace::TransferFunction, transferFunction);
+ QFETCH(QColorSpace::TransformModel, transformModel);
+ QFETCH(QColorSpace::ColorModel, colorModel);
QFETCH(QString, description);
QFile file(testProfile);
- file.open(QIODevice::ReadOnly);
+ QVERIFY(file.open(QIODevice::ReadOnly));
QByteArray iccProfile = file.readAll();
QColorSpace fileColorSpace = QColorSpace::fromIccProfile(iccProfile);
QVERIFY(fileColorSpace.isValid());
@@ -225,7 +244,14 @@ void tst_QColorSpace::fromIccProfile()
QCOMPARE(fileColorSpace, namedColorSpace);
QCOMPARE(fileColorSpace.transferFunction(), transferFunction);
- QCOMPARE(QColorSpacePrivate::get(fileColorSpace)->description, description);
+ QCOMPARE(fileColorSpace.transformModel(), transformModel);
+ QCOMPARE(fileColorSpace.colorModel(), colorModel);
+ QCOMPARE(fileColorSpace.description(), description);
+
+ QByteArray iccProfile2 = fileColorSpace.iccProfile();
+ QCOMPARE(iccProfile, iccProfile2);
+ QColorSpace fileColorSpace2 = QColorSpace::fromIccProfile(iccProfile2);
+ QCOMPARE(fileColorSpace2, fileColorSpace);
}
void tst_QColorSpace::imageConversion_data()
@@ -236,9 +262,10 @@ void tst_QColorSpace::imageConversion_data()
QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0;
QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb << 2;
- QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0;
QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2;
+ QTest::newRow("Adobe RGB -> Display-P3") << QColorSpace::AdobeRgb << QColorSpace::DisplayP3 << 4;
QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2;
+ QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0;
QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0;
QTest::newRow("sRGB Linear -> sRGB") << QColorSpace::SRgbLinear << QColorSpace::SRgb << 0;
}
@@ -265,9 +292,9 @@ void tst_QColorSpace::imageConversion()
int lastBlue = 0;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qRed(p) >= lastRed);
- QVERIFY(qGreen(p) >= lastGreen);
- QVERIFY(qBlue(p) >= lastBlue);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -280,11 +307,12 @@ void tst_QColorSpace::imageConversion()
QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qAbs(qRed(p) - qGreen(p)) <= tolerance);
- QVERIFY(qAbs(qRed(p) - qBlue(p)) <= tolerance);
- QVERIFY((lastRed - qRed(p)) <= (tolerance / 2));
- QVERIFY((lastGreen - qGreen(p)) <= (tolerance / 2));
- QVERIFY((lastBlue - qBlue(p)) <= (tolerance / 2));
+ QCOMPARE_LE(qAbs(qRed(p) - qBlue(p)), tolerance);
+ QCOMPARE_LE(qAbs(qRed(p) - qGreen(p)), tolerance);
+ QCOMPARE_LE(qAbs(qGreen(p) - qBlue(p)), tolerance);
+ QCOMPARE_LE(lastRed - qRed(p), tolerance / 2);
+ QCOMPARE_LE(lastBlue - qBlue(p), tolerance / 2);
+ QCOMPARE_LE(lastGreen - qGreen(p), tolerance / 2);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -325,9 +353,9 @@ void tst_QColorSpace::imageConversion64()
int lastBlue = 0;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qRed(p) >= lastRed);
- QVERIFY(qGreen(p) >= lastGreen);
- QVERIFY(qBlue(p) >= lastBlue);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -342,13 +370,94 @@ void tst_QColorSpace::imageConversion64()
QRgb p = testImage.pixel(i, 0);
QCOMPARE(qRed(p), qGreen(p));
QCOMPARE(qRed(p), qBlue(p));
- QVERIFY((lastRed - qRed(p)) <= 0);
- QVERIFY((lastGreen - qGreen(p)) <= 0);
- QVERIFY((lastBlue - qBlue(p)) <= 0);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
}
+ QCOMPARE(lastRed, 255);
+ QCOMPARE(lastGreen, 255);
+ QCOMPARE(lastBlue, 255);
+}
+
+void tst_QColorSpace::imageConversion64PM_data()
+{
+ imageConversion64_data();
+}
+
+void tst_QColorSpace::imageConversion64PM()
+{
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
+
+ QImage testImage(256, 16, QImage::Format_RGBA64_Premultiplied);
+
+ for (int j = 0; j < 16; ++j) {
+ int a = j * 15;
+ for (int i = 0; i < 256; ++i) {
+ QRgba64 color = QRgba64::fromRgba(i, i, i, a);
+ testImage.setPixelColor(i, j, QColor::fromRgba64(color));
+ }
+ }
+
+ testImage.setColorSpace(fromColorSpace);
+ QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
+
+ testImage.convertToColorSpace(toColorSpace);
+ QCOMPARE(testImage.colorSpace(), QColorSpace(toColorSpace));
+
+ int lastRed = 0;
+ int lastGreen = 0;
+ int lastBlue = 0;
+ for (int j = 0; j < 16; ++j) {
+ const int expectedAlpha = j * 15;
+ for (int i = 0; i < 256; ++i) {
+ QRgb p = testImage.pixel(i, j);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
+ QCOMPARE(qAlpha(p), expectedAlpha);
+ lastRed = qRed(p);
+ lastGreen = qGreen(p);
+ lastBlue = qBlue(p);
+ }
+ QCOMPARE_LE(lastRed, expectedAlpha);
+ QCOMPARE_LE(lastGreen, expectedAlpha);
+ QCOMPARE_LE(lastBlue, expectedAlpha);
+ lastRed = 0;
+ lastGreen = 0;
+ lastBlue = 0;
+ }
+
+ testImage.convertToColorSpace(fromColorSpace);
+ QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
+ for (int j = 0; j < 16; ++j) {
+ const int expectedAlpha = j * 15;
+ for (int i = 0; i < 256; ++i) {
+ QRgb expected = qPremultiply(qRgba(i, i, i, expectedAlpha));
+ QRgb p = testImage.pixel(i, j);
+ QCOMPARE_LE(qAbs(qRed(p) - qGreen(p)), 1);
+ QCOMPARE_LE(qAbs(qRed(p) - qBlue(p)), 1);
+ QCOMPARE(qAlpha(p), expectedAlpha);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
+ QCOMPARE_LE(qAbs(qRed(p) - qRed(expected)), 1);
+ QCOMPARE_LE(qAbs(qGreen(p) - qGreen(expected)), 1);
+ QCOMPARE_LE(qAbs(qBlue(p) - qBlue(expected)), 1);
+ lastRed = qRed(p);
+ lastGreen = qGreen(p);
+ lastBlue = qBlue(p);
+ }
+ QCOMPARE(lastRed, expectedAlpha);
+ QCOMPARE(lastGreen, expectedAlpha);
+ QCOMPARE(lastBlue, expectedAlpha);
+ lastRed = 0;
+ lastGreen = 0;
+ lastBlue = 0;
+ }
}
void tst_QColorSpace::imageConversionOverLargerGamut_data()
@@ -377,14 +486,14 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
testImage.setColorSpace(csfrom);
for (int y = 0; y < 256; ++y)
for (int x = 0; x < 256; ++x)
- testImage.setPixel(x, y, qRgb(x, y, 0));
+ testImage.setPixel(x, y, qRgb(x, y, qAbs(x - y)));
QImage resultImage = testImage.convertedToColorSpace(csto);
for (int y = 0; y < 256; ++y) {
int lastRed = 0;
for (int x = 0; x < 256; ++x) {
QRgb p = resultImage.pixel(x, y);
- QVERIFY(qRed(p) >= lastRed);
+ QCOMPARE_GE(qRed(p), lastRed);
lastRed = qRed(p);
}
}
@@ -392,7 +501,7 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
int lastGreen = 0;
for (int y = 0; y < 256; ++y) {
QRgb p = resultImage.pixel(x, y);
- QVERIFY(qGreen(p) >= lastGreen);
+ QCOMPARE_GE(qGreen(p), lastGreen);
lastGreen = qGreen(p);
}
}
@@ -406,6 +515,187 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
}
}
+void tst_QColorSpace::imageConversionOverLargerGamut2_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("rgbx16x4") << QImage::Format_RGBX16FPx4;
+ QTest::newRow("rgba16x4") << QImage::Format_RGBA16FPx4;
+ QTest::newRow("rgba16x4PM") << QImage::Format_RGBA16FPx4_Premultiplied;
+ QTest::newRow("rgbx32x4") << QImage::Format_RGBX32FPx4;
+ QTest::newRow("rgba32x4") << QImage::Format_RGBA32FPx4;
+ QTest::newRow("rgba32x4PM") << QImage::Format_RGBA32FPx4_Premultiplied;
+}
+
+void tst_QColorSpace::imageConversionOverLargerGamut2()
+{
+ QFETCH(QImage::Format, format);
+
+ QColorSpace csfrom = QColorSpace::DisplayP3;
+ QColorSpace csto = QColorSpace::SRgb;
+
+ QImage testImage(256, 256, format);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgba(x, y, 16, 255));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto);
+ for (int y = 0; y < 256; ++y) {
+ float lastRed = -256.0f;
+ for (int x = 0; x < 256; ++x) {
+ float pr = resultImage.pixelColor(x, y).redF();
+ QVERIFY(pr >= lastRed);
+ lastRed = pr;
+ }
+ }
+ for (int x = 0; x < 256; ++x) {
+ float lastGreen = -256.0f;
+ for (int y = 0; y < 256; ++y) {
+ float pg = resultImage.pixelColor(x, y).greenF();
+ QVERIFY(pg >= lastGreen);
+ lastGreen = pg;
+ }
+ }
+ // Test colors outside of sRGB are converted to values outside of 0-1 range.
+ QVERIFY(resultImage.pixelColor(255, 0).redF() > 1.0f);
+ QVERIFY(resultImage.pixelColor(255, 0).greenF() < 0.0f);
+ QVERIFY(resultImage.pixelColor(0, 255).redF() < 0.0f);
+ QVERIFY(resultImage.pixelColor(0, 255).greenF() > 1.0f);
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP_data()
+{
+ QTest::addColumn<QColorSpace::NamedColorSpace>("fromColorSpace");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("toColorSpace");
+
+ QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3;
+ QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb;
+ QTest::newRow("sRGB -> ProPhoto RGB") << QColorSpace::SRgb << QColorSpace::ProPhotoRgb;
+ QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb;
+ QTest::newRow("Adobe RGB -> Display-P3") << QColorSpace::AdobeRgb << QColorSpace::DisplayP3;
+ QTest::newRow("Adobe RGB -> ProPhoto RGB") << QColorSpace::AdobeRgb << QColorSpace::ProPhotoRgb;
+ QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb;
+ QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb;
+ QTest::newRow("Display-P3 -> ProPhoto RGB") << QColorSpace::DisplayP3 << QColorSpace::ProPhotoRgb;
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP()
+{
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
+
+ QColorSpace csfrom(fromColorSpace);
+ QColorSpace csto(toColorSpace);
+ csfrom.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ csto.setTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QImage testImage(256, 256, QImage::Format_RGBX32FPx4);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto);
+ resultImage.convertToColorSpace(csfrom);
+
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ QCOMPARE(resultImage.pixel(x, y), testImage.pixel(x, y));
+ }
+ }
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP2_data()
+{
+ imageConversionOverAnyGamutFP_data();
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP2()
+{
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
+
+ // Same as imageConversionOverAnyGamutFP but using format switching transform
+ QColorSpace csfrom(fromColorSpace);
+ QColorSpace csto(toColorSpace);
+ csfrom.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ csto.setTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QImage testImage(256, 256, QImage::Format_RGB32);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto, QImage::Format_RGBX32FPx4);
+ resultImage.convertToColorSpace(csfrom, QImage::Format_RGB32);
+
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ QCOMPARE(resultImage.pixel(x, y), testImage.pixel(x, y));
+ }
+ }
+}
+
+void tst_QColorSpace::imageConversionOverNonThreeComponentMatrix_data()
+{
+ QTest::addColumn<QColorSpace>("fromColorSpace");
+ QTest::addColumn<QColorSpace>("toColorSpace");
+
+ QString prefix = QFINDTESTDATA("resources/");
+ QFile file1(prefix + "VideoHD.icc");
+ QFile file2(prefix + "sRGB_ICC_v4_Appearance.icc");
+ QVERIFY(file1.open(QFile::ReadOnly));
+ QVERIFY(file2.open(QFile::ReadOnly));
+ QByteArray iccProfile1 = file1.readAll();
+ QByteArray iccProfile2 = file2.readAll();
+ QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccProfile1);
+ QColorSpace srgbPcsColorSpace = QColorSpace::fromIccProfile(iccProfile2);
+
+ QTest::newRow("sRGB PCSLab -> sRGB") << srgbPcsColorSpace << QColorSpace(QColorSpace::SRgb);
+ QTest::newRow("sRGB -> sRGB PCSLab") << QColorSpace(QColorSpace::SRgb) << srgbPcsColorSpace;
+ QTest::newRow("HDTV -> sRGB") << hdtvColorSpace << QColorSpace(QColorSpace::SRgb);
+ QTest::newRow("sRGB -> HDTV") << QColorSpace(QColorSpace::SRgb) << hdtvColorSpace;
+ QTest::newRow("sRGB PCSLab -> HDTV") << srgbPcsColorSpace << hdtvColorSpace;
+ QTest::newRow("HDTV -> sRGB PCSLab") << hdtvColorSpace << srgbPcsColorSpace;
+}
+
+void tst_QColorSpace::imageConversionOverNonThreeComponentMatrix()
+{
+ QFETCH(QColorSpace, fromColorSpace);
+ QFETCH(QColorSpace, toColorSpace);
+ QVERIFY(fromColorSpace.isValid());
+ QVERIFY(toColorSpace.isValidTarget());
+
+ QVERIFY(!fromColorSpace.transformationToColorSpace(toColorSpace).isIdentity());
+
+ QImage testImage(256, 256, QImage::Format_RGBX64);
+ testImage.setColorSpace(fromColorSpace);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(toColorSpace);
+ QCOMPARE(resultImage.size(), testImage.size());
+ for (int y = 0; y < 256; ++y) {
+ int lastRed = 0;
+ for (int x = 0; x < 256; ++x) {
+ QRgb p = resultImage.pixel(x, y);
+ QVERIFY(qRed(p) >= lastRed);
+ lastRed = qRed(p);
+ }
+ }
+ for (int x = 0; x < 256; ++x) {
+ int lastGreen = 0;
+ for (int y = 0; y < 256; ++y) {
+ QRgb p = resultImage.pixel(x, y);
+ QVERIFY(qGreen(p) >= lastGreen);
+ lastGreen = qGreen(p);
+ }
+ }
+}
+
void tst_QColorSpace::loadImage()
{
QString prefix = QFINDTESTDATA("resources/");
@@ -447,11 +737,11 @@ void tst_QColorSpace::loadImage()
void tst_QColorSpace::primaries()
{
- QColor black = QColor::fromRgbF(0.0, 0.0, 0.0);
- QColor white = QColor::fromRgbF(1.0, 1.0, 1.0);
- QColor red = QColor::fromRgbF(1.0, 0.0, 0.0);
- QColor green = QColor::fromRgbF(0.0, 1.0, 0.0);
- QColor blue = QColor::fromRgbF(0.0, 0.0, 1.0);
+ QColor black = QColor::fromRgbF(0.0f, 0.0f, 0.0f);
+ QColor white = QColor::fromRgbF(1.0f, 1.0f, 1.0f);
+ QColor red = QColor::fromRgbF(1.0f, 0.0f, 0.0f);
+ QColor green = QColor::fromRgbF(0.0f, 1.0f, 0.0f);
+ QColor blue = QColor::fromRgbF(0.0f, 0.0f, 1.0f);
QColorTransform toAdobeRgb = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(QColorSpace::AdobeRgb);
@@ -583,10 +873,28 @@ void tst_QColorSpace::changePrimaries()
cs.setPrimaries(QColorSpace::Primaries::DciP3D65);
QVERIFY(cs.isValid());
QCOMPARE(cs, QColorSpace(QColorSpace::DisplayP3));
+ QCOMPARE(cs.transformModel(), QColorSpace::TransformModel::ThreeComponentMatrix);
cs.setTransferFunction(QColorSpace::TransferFunction::Linear);
cs.setPrimaries(QPointF(0.3127, 0.3290), QPointF(0.640, 0.330),
QPointF(0.3000, 0.6000), QPointF(0.150, 0.060));
QCOMPARE(cs, QColorSpace(QColorSpace::SRgbLinear));
+
+
+ QFile iccFile(QFINDTESTDATA("resources/") + "VideoHD.icc");
+ QVERIFY(iccFile.open(QFile::ReadOnly));
+ QByteArray iccData = iccFile.readAll();
+ QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccData);
+ QVERIFY(hdtvColorSpace.isValid());
+ QCOMPARE(hdtvColorSpace.transformModel(), QColorSpace::TransformModel::ElementListProcessing);
+ QCOMPARE(hdtvColorSpace.primaries(), QColorSpace::Primaries::Custom);
+ QCOMPARE(hdtvColorSpace.transferFunction(), QColorSpace::TransferFunction::Custom);
+ // Unsets both primaries and transferfunction because they were inseparable in element list processing
+ hdtvColorSpace.setPrimaries(QColorSpace::Primaries::SRgb);
+ QVERIFY(!hdtvColorSpace.isValid());
+ hdtvColorSpace.setTransferFunction(QColorSpace::TransferFunction::SRgb);
+ QVERIFY(hdtvColorSpace.isValid());
+ QCOMPARE(hdtvColorSpace.transformModel(), QColorSpace::TransformModel::ThreeComponentMatrix);
+ QCOMPARE(hdtvColorSpace, QColorSpace(QColorSpace::SRgb));
}
void tst_QColorSpace::transferFunctionTable()
@@ -616,5 +924,111 @@ void tst_QColorSpace::transferFunctionTable()
QCOMPARE(customSRgb, QColorSpace::SRgbLinear);
}
+void tst_QColorSpace::description()
+{
+ QColorSpace srgb(QColorSpace::SRgb);
+ QCOMPARE(srgb.description(), QLatin1String("sRGB"));
+
+ srgb.setTransferFunction(QColorSpace::TransferFunction::ProPhotoRgb);
+ QCOMPARE(srgb.description(), QString()); // No longer sRGB
+ srgb.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ QCOMPARE(srgb.description(), QLatin1String("Linear sRGB")); // Auto-detect
+
+ srgb.setTransferFunction(QColorSpace::TransferFunction::ProPhotoRgb);
+ srgb.setDescription(QStringLiteral("My custom sRGB"));
+ QCOMPARE(srgb.description(), QLatin1String("My custom sRGB"));
+ srgb.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ QCOMPARE(srgb.description(), QLatin1String("My custom sRGB")); // User given name not reset
+ srgb.setDescription(QString());
+ QCOMPARE(srgb.description(), QLatin1String("Linear sRGB")); // Set to empty returns default behavior
+}
+
+void tst_QColorSpace::whitePoint_data()
+{
+ QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
+ QTest::addColumn<QPointF>("whitePoint");
+
+ QTest::newRow("sRGB") << QColorSpace::SRgb << QColorVector::D65Chromaticity();
+ QTest::newRow("Adobe RGB") << QColorSpace::AdobeRgb << QColorVector::D65Chromaticity();
+ QTest::newRow("Display-P3") << QColorSpace::DisplayP3 << QColorVector::D65Chromaticity();
+ QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb << QColorVector::D50Chromaticity();
+}
+
+void tst_QColorSpace::whitePoint()
+{
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
+ QFETCH(QPointF, whitePoint);
+
+ QColorSpace colorSpace(namedColorSpace);
+ QPointF wpt = colorSpace.whitePoint();
+ QCOMPARE_LE(qAbs(wpt.x() - whitePoint.x()), 0.0000001);
+ QCOMPARE_LE(qAbs(wpt.y() - whitePoint.y()), 0.0000001);
+}
+
+void tst_QColorSpace::setWhitePoint()
+{
+ QColorSpace colorSpace(QColorSpace::SRgb);
+ colorSpace.setWhitePoint(QPointF(0.33, 0.33));
+ QCOMPARE_NE(colorSpace, QColorSpace(QColorSpace::SRgb));
+ colorSpace.setWhitePoint(QColorVector::D65Chromaticity());
+ // Check our matrix manipulations returned us to where we came from
+ QCOMPARE(colorSpace, QColorSpace(QColorSpace::SRgb));
+}
+
+void tst_QColorSpace::grayColorSpace()
+{
+ QColorSpace spc;
+ QCOMPARE(spc.colorModel(), QColorSpace::ColorModel::Undefined);
+ QVERIFY(!spc.isValid());
+ spc.setWhitePoint(QColorVector::D65Chromaticity());
+ spc.setTransferFunction(QColorSpace::TransferFunction::SRgb);
+ QVERIFY(spc.isValid());
+ QCOMPARE(spc.colorModel(), QColorSpace::ColorModel::Gray);
+
+ QColorSpace spc2(QColorVector::D65Chromaticity(), QColorSpace::TransferFunction::SRgb);
+ QVERIFY(spc2.isValid());
+ QCOMPARE(spc2.colorModel(), QColorSpace::ColorModel::Gray);
+ QCOMPARE(spc, spc2);
+
+ QImage rgbImage(1, 8, QImage::Format_RGB32);
+ QImage grayImage(1, 255, QImage::Format_Grayscale8);
+ // RGB images can not have gray color space
+ rgbImage.setColorSpace(spc2);
+ grayImage.setColorSpace(spc2);
+ QCOMPARE_NE(rgbImage.colorSpace(), spc2);
+ QCOMPARE(grayImage.colorSpace(), spc2);
+ // But gray images can have RGB color space
+ rgbImage.setColorSpace(QColorSpace::SRgb);
+ grayImage.setColorSpace(QColorSpace::SRgb);
+ QCOMPARE(rgbImage.colorSpace(), QColorSpace(QColorSpace::SRgb));
+ QCOMPARE(grayImage.colorSpace(), QColorSpace(QColorSpace::SRgb));
+
+ // While we can not set a grayscale color space on rgb image, we can convert to one
+ QImage grayImage2 = rgbImage.convertedToColorSpace(spc2);
+ QCOMPARE(grayImage2.colorSpace(), spc2);
+ QCOMPARE(grayImage2.format(), QImage::Format_Grayscale8);
+}
+
+void tst_QColorSpace::grayColorSpaceEffectivelySRgb()
+{
+ // Test grayscale colorspace conversion by making a gray color space that should act like sRGB on gray values.
+ QColorSpace sRgb(QColorSpace::SRgb);
+ QColorSpace sRgbGray(QColorVector::D65Chromaticity(), QColorSpace::TransferFunction::SRgb);
+
+ QImage grayImage1(256, 1, QImage::Format_Grayscale8);
+ QImage grayImage2(256, 1, QImage::Format_Grayscale8);
+ for (int i = 0; i < 256; ++i) {
+ grayImage1.bits()[i] = i;
+ grayImage2.bits()[i] = i;
+ }
+ grayImage1.setColorSpace(sRgb);
+ grayImage2.setColorSpace(sRgbGray);
+
+ QImage rgbImage1 = grayImage1.convertedTo(QImage::Format_RGB32);
+ QImage rgbImage2 = grayImage2.convertedToColorSpace(sRgb, QImage::Format_RGB32);
+
+ QCOMPARE(rgbImage1, rgbImage2);
+}
+
QTEST_MAIN(tst_QColorSpace)
#include "tst_qcolorspace.moc"
diff --git a/tests/auto/gui/painting/qcolortransform/CMakeLists.txt b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
new file mode 100644
index 0000000000..4aa4a8bc4a
--- /dev/null
+++ b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qcolortransform Test:
+#####################################################################
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolortransform LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+qt_internal_add_test(tst_qcolortransform
+ SOURCES
+ tst_qcolortransform.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::GuiPrivate
+)
diff --git a/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
new file mode 100644
index 0000000000..7a976b5f5e
--- /dev/null
+++ b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
@@ -0,0 +1,380 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+
+#include <QTest>
+
+#include <qcolorspace.h>
+#include <qcolortransform.h>
+#include <qrgbafloat.h>
+#include <QtGui/private/qcolortransform_p.h>
+
+class tst_QColorTransform : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QColorTransform();
+
+private slots:
+ void mapRGB32_data();
+ void mapRGB32();
+ void mapRGB64_data();
+ void mapRGB64();
+ void mapRGBAFP16x4_data();
+ void mapRGBAFP16x4();
+ void mapRGBAFP32x4_data();
+ void mapRGBAFP32x4();
+ void mapQColor_data();
+ void mapQColor();
+ void mapRGB32Prepared_data();
+ void mapRGB32Prepared();
+
+ void transformIsIdentity();
+};
+
+tst_QColorTransform::tst_QColorTransform()
+{ }
+
+
+void tst_QColorTransform::mapRGB32_data()
+{
+ QTest::addColumn<QColorTransform>("transform");
+ QTest::addColumn<bool>("sharesRed");
+
+ QColorSpace srgb(QColorSpace::SRgb);
+ QColorSpace srgbLinear(QColorSpace::SRgbLinear);
+ QColorSpace adobeRgb(QColorSpace::AdobeRgb);
+ QColorSpace adobeRgbLinear = adobeRgb.withTransferFunction(QColorSpace::TransferFunction::Linear);
+ QColorSpace dp3(QColorSpace::DisplayP3);
+ QColorSpace dp3Linear = dp3.withTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QTest::newRow("default") << QColorTransform() << true;
+ QTest::newRow("sRGB to Linear sRGB") << srgb.transformationToColorSpace(srgbLinear) << true;
+ QTest::newRow("AdobeRGB to sRGB") << adobeRgb.transformationToColorSpace(srgb) << true;
+ QTest::newRow("Linear AdobeRGB to AdobeRGB") << adobeRgbLinear.transformationToColorSpace(adobeRgb) << true;
+ QTest::newRow("Linear AdobeRGB to Linear sRGB") << adobeRgbLinear.transformationToColorSpace(srgbLinear) << true;
+ QTest::newRow("sRgb to AdobeRGB") << srgb.transformationToColorSpace(adobeRgb) << true;
+ QTest::newRow("DP3 to sRGB") << dp3.transformationToColorSpace(srgb) << false;
+ QTest::newRow("DP3 to Linear DP3") << dp3.transformationToColorSpace(dp3Linear) << false;
+ QTest::newRow("Linear DP3 to Linear sRGB") << dp3Linear.transformationToColorSpace(srgbLinear) << false;
+}
+
+void tst_QColorTransform::mapRGB32()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+ // Do basic sanity tests of conversions between similar sane color spaces
+
+ QRgb testColor = qRgb(32, 64, 128);
+ QRgb result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(128, 64, 32);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) > qGreen(result));
+ QVERIFY(qGreen(result) > qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgba(15, 31, 63, 128);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 128);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(0, 0, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 0);
+ QCOMPARE(qGreen(result), 0);
+ QCOMPARE(qBlue(result), 0);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 255);
+ QCOMPARE(qGreen(result), 255);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qAlpha(result), 255);
+ if (sharesRed)
+ QCOMPARE(qRed(result), 255);
+
+ testColor = qRgb(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+}
+
+void tst_QColorTransform::mapRGB64_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGB64()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgba64 testColor = QRgba64::fromRgba(128, 64, 32, 255);
+ QRgba64 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 0xffff);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgba64::fromRgba64(0, 0, 0, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgba64::fromRgba64(0xffff, 0xffff, 0xffff, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgba64::fromRgba64(0xffff, 0xffff, 0, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result.alpha(), 0xffff);
+ if (sharesRed)
+ QCOMPARE(result.red(), 0xffff);
+
+ testColor = QRgba64::fromRgba64(0, 0xffff, 0xffff, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result.blue(), 0xffff);
+ QCOMPARE(result.alpha(), 0xffff);
+}
+
+void tst_QColorTransform::mapRGBAFP16x4_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGBAFP16x4()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgbaFloat16 testColor = QRgbaFloat16::fromRgba(128, 64, 32, 255);
+ QRgbaFloat16 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgbaFloat16{qfloat16(0.0f), qfloat16(0.0f), qfloat16(0.0f), qfloat16(1.0f)};
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgbaFloat16{qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgbaFloat16{qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
+ result = transform.map(testColor);
+ QCOMPARE(result.alpha(), 1.0f);
+ if (sharesRed)
+ QCOMPARE(result.red(), 1.0f);
+
+ testColor = QRgbaFloat16{qfloat16(0.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
+ result = transform.map(testColor);
+ // QRgbaFloat16 might overflow blue if we convert to a smaller gamut:
+ QCOMPARE(result.blue16(), 65535);
+ QCOMPARE(result.alpha(), 1.0f);
+}
+
+void tst_QColorTransform::mapRGBAFP32x4_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGBAFP32x4()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgbaFloat32 testColor = QRgbaFloat32::fromRgba(128, 64, 32, 255);
+ QRgbaFloat32 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgbaFloat32{0.0f, 0.0f, 0.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.red(), 0.0f);
+ QCOMPARE(result.green(), 0.0f);
+ QCOMPARE(result.blue(), 0.0f);
+ QCOMPARE(result.alpha(), 1.0f);
+
+ testColor = QRgbaFloat32{1.0f, 1.0f, 1.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.red(), 1.0f);
+ QCOMPARE(result.green(), 1.0f);
+ QCOMPARE(result.blue(), 1.0f);
+ QCOMPARE(result.alpha(), 1.0f);
+
+ testColor = QRgbaFloat32{1.0f, 1.0f, 0.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.alpha(), 1.0f);
+ if (sharesRed)
+ QCOMPARE(result.red(), 1.0f);
+
+ testColor = QRgbaFloat32{0.0f, 1.0f, 1.0f, 1.0f};
+ result = transform.map(testColor);
+ // QRgbaFloat16 might overflow blue if we convert to a smaller gamut:
+ QCOMPARE(result.blue16(), 65535);
+ QCOMPARE(result.alpha(), 1.0f);
+}
+
+void tst_QColorTransform::mapQColor_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapQColor()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QColor testColor(32, 64, 128);
+ QColor result = transform.map(testColor);
+ QVERIFY(result.redF() < result.greenF());
+ QVERIFY(result.greenF() < result.blueF());
+ QCOMPARE(result.alphaF(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = Qt::black;
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = Qt::white;
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QColor(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(result.alphaF(), 1);
+ if (sharesRed)
+ QVERIFY(result.redF() >= 1.0f);
+
+ testColor = QColor(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(result.alphaF(), 1.0f);
+ QVERIFY(result.blueF() >= 1.0f);
+}
+
+void tst_QColorTransform::mapRGB32Prepared_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGB32Prepared()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ // The same tests as mapRGB32 but prepared, to use the LUT code-paths
+ if (!transform.isIdentity())
+ QColorTransformPrivate::get(transform)->prepare();
+
+ QRgb testColor = qRgb(32, 64, 128);
+ QRgb result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(128, 64, 32);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) > qGreen(result));
+ QVERIFY(qGreen(result) > qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgba(15, 31, 63, 128);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 128);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(0, 0, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 0);
+ QCOMPARE(qGreen(result), 0);
+ QCOMPARE(qBlue(result), 0);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 255);
+ QCOMPARE(qGreen(result), 255);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qAlpha(result), 255);
+ if (sharesRed)
+ QCOMPARE(qRed(result), 255);
+
+ testColor = qRgb(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+}
+
+void tst_QColorTransform::transformIsIdentity()
+{
+ QColorTransform ct;
+ QVERIFY(ct.isIdentity());
+
+ QColorSpace cs = QColorSpace::SRgb;
+ ct = cs.transformationToColorSpace(QColorSpace::SRgb);
+ QVERIFY(ct.isIdentity());
+
+ ct = cs.transformationToColorSpace(QColorSpace::SRgbLinear);
+ QVERIFY(!ct.isIdentity());
+
+ ct = cs.withTransferFunction(QColorSpace::TransferFunction::Linear).transformationToColorSpace(QColorSpace::SRgbLinear);
+ QVERIFY(ct.isIdentity());
+}
+
+QTEST_MAIN(tst_QColorTransform)
+#include "tst_qcolortransform.moc"
diff --git a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
index 913619461e..b19568592b 100644
--- a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qpagelayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpagelayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpagelayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpagelayout
SOURCES
tst_qpagelayout.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
index 830e0cd16c..4490877e87 100644
--- a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
+++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** 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) 2014 John Layt <jlayt@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/qpagelayout.h>
@@ -37,6 +12,9 @@ private slots:
void invalid();
void basics();
void setGetMargins();
+ void setGetClampedMargins();
+ void setUnits_data();
+ void setUnits();
};
void tst_QPageLayout::invalid()
@@ -113,12 +91,14 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.margins(QPageLayout::Millimeter), QMarginsF(3.53, 3.53, 3.53, 3.53));
QCOMPARE(tenpoint.marginsPoints(), QMargins(10, 10, 10, 10));
QCOMPARE(tenpoint.marginsPixels(72), QMargins(10, 10, 10, 10));
+ QCOMPARE(tenpoint.marginsPixels(600), QMargins(83, 83, 83, 83));
QCOMPARE(tenpoint.minimumMargins(), QMarginsF(0, 0, 0, 0));
QCOMPARE(tenpoint.maximumMargins(), QMarginsF(595, 842, 595, 842));
QCOMPARE(tenpoint.fullRect(), QRectF(0, 0, 595, 842));
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 595, 842));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 4958, 7016));
QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 575, 822));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 202.94, 289.94));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).x(), 3.53);
@@ -131,6 +111,7 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).bottom(), 293.47);
QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 575, 822));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 575, 822));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(83, 83, 4792, 6850));
// Change orientation
tenpoint.setOrientation(QPageLayout::Landscape);
@@ -142,10 +123,12 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 7016, 4958));
QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 822, 575));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 289.94, 202.94));
QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 822, 575));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 822, 575));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(83, 83, 6850, 4792));
// Change mode
QCOMPARE(tenpoint.mode(), QPageLayout::StandardMode);
@@ -159,15 +142,82 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 7016, 4958));
QCOMPARE(tenpoint.paintRect(), QRectF(0, 0, 842, 595));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.paintRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(0, 0, 7016, 4958));
+
+ // A4, 8.4pt margins
+ QPageLayout fraction = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.isValid(), true);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.margins(QPageLayout::Millimeter), QMarginsF(2.96, 2.96, 2.96, 2.96));
+ QCOMPARE(fraction.marginsPoints(), QMarginsF(8, 8, 8, 8));
+ QCOMPARE(fraction.marginsPixels(72), QMargins(8, 8, 8, 8));
+ QCOMPARE(fraction.marginsPixels(600), QMargins(70, 70, 70, 70));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(595, 842, 595, 842));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 4958, 7016));
+ QCOMPARE(fraction.paintRect(), QRectF(8.4, 8.4, 578.2, 825.2));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(2.96, 2.96, 204.08, 291.08));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).x(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).y(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).width(), 204.08);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).height(), 291.08);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).left(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).right(), 207.04);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).top(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).bottom(), 294.04);
+ QCOMPARE(fraction.paintRectPoints(), QRect(8, 8, 579, 826));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(8, 8, 579, 826));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(70, 70, 4818, 6876));
+
+ // Change orientation
+ fraction.setOrientation(QPageLayout::Landscape);
+ QCOMPARE(fraction.orientation(), QPageLayout::Landscape);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 7016, 4958));
+ QCOMPARE(fraction.paintRect(), QRectF(8.4, 8.4, 825.2, 578.2));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(2.96, 2.96, 291.08, 204.08));
+ QCOMPARE(fraction.paintRectPoints(), QRect(8, 8, 826, 579));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(8, 8, 826, 579));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(70, 70, 6876, 4818));
+
+ // Change mode
+ QCOMPARE(fraction.mode(), QPageLayout::StandardMode);
+ fraction.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(fraction.mode(), QPageLayout::FullPageMode);
+ QCOMPARE(fraction.orientation(), QPageLayout::Landscape);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 7016, 4958));
+ QCOMPARE(fraction.paintRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.paintRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(0, 0, 7016, 4958));
}
void tst_QPageLayout::setGetMargins()
{
- // A4, 20pt margins
+ // A4, 10pt margins
QMarginsF margins = QMarginsF(10, 10, 10, 10);
QMarginsF min = QMarginsF(10, 10, 10, 10);
QMarginsF max = QMarginsF(585, 832, 585, 832);
@@ -180,7 +230,7 @@ void tst_QPageLayout::setGetMargins()
QCOMPARE(change.minimumMargins(), min);
QCOMPARE(change.maximumMargins(), max);
- // Set magins within min/max ok
+ // Set margins within min/max ok
margins = QMarginsF(20, 20, 20, 20);
change.setMargins(margins);
QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(7.06, 7.06, 7.06, 7.06));
@@ -240,7 +290,7 @@ void tst_QPageLayout::setGetMargins()
fullPage.setMargins(margins);
QCOMPARE(fullPage.margins(), margins);
- // Set margins all above max is rejected
+ // Set margins all above max is accepted
margins = QMarginsF(1000, 1000, 1000, 1000);
fullPage.setMargins(margins);
QCOMPARE(fullPage.margins(), margins);
@@ -263,6 +313,174 @@ void tst_QPageLayout::setGetMargins()
QCOMPARE(fullPage.maximumMargins(), max);
}
+void tst_QPageLayout::setGetClampedMargins()
+{
+ // A4, 10pt margins
+ QMarginsF margins = QMarginsF(10, 10, 10, 10);
+ QMarginsF min = QMarginsF(10, 10, 10, 10);
+ QMarginsF max = QMarginsF(585, 832, 585, 832);
+ QPageLayout change = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ QCOMPARE(change.isValid(), true);
+
+ // Clamp margins within min/max ok
+ margins = QMarginsF(20, 20, 20, 20);
+ change.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(7.06, 7.06, 7.06, 7.06));
+ QCOMPARE(change.marginsPoints(), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.marginsPixels(72), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.margins(), margins);
+
+ // Clamp margins all below min
+ change.setMargins(QMarginsF(0, 0, 0, 0), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), change.minimumMargins());
+
+ // Clamp margins all above max
+ change.setMargins(QMarginsF(1000, 1000, 1000, 1000), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), change.maximumMargins());
+
+ // Only 1 wrong, clamp still works
+ change.setMargins(QMarginsF(50, 50, 50, 0), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), QMarginsF(50, 50, 50, change.minimumMargins().bottom()));
+
+ // A4, 20pt margins
+ margins = QMarginsF(20, 20, 20, 20);
+ min = QMarginsF(10, 10, 10, 10);
+ max = QMarginsF(585, 832, 585, 832);
+ QPageLayout fullPage = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ fullPage.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(fullPage.isValid(), true);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+
+ // Clamp margins within min/max ok
+ margins = QMarginsF(50, 50, 50, 50);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Clamp margins all below min, no clamping
+ margins = QMarginsF(0, 0, 0, 0);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Clamp margins all above max, no clamping
+ margins = QMarginsF(1000, 1000, 1000, 1000);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Only 1 wrong, no clamping
+ margins = QMarginsF(50, 50, 50, 0);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Set page size, sets min/max, clamps existing margins
+ margins = QMarginsF(20, 500, 20, 500);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+ min = QMarginsF(30, 30, 30, 30);
+ max = QMarginsF(267, 390, 267, 390);
+ fullPage.setPageSize(QPageSize(QPageSize::A6));
+ fullPage.setMinimumMargins(min);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+
+ // Test set* API calls
+ min = QMarginsF(1, 2, 3, 4);
+ max = QMarginsF(595 - min.right(), 842 - min.bottom(), 595 - min.left(), 842 - min.top());
+ change = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ QCOMPARE(change.minimumMargins(), min);
+ QCOMPARE(change.maximumMargins(), max);
+
+ // Test setLeftMargin
+ change.setLeftMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), min.left());
+ change.setLeftMargin(change.fullRectPoints().width(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), max.left());
+ change.setLeftMargin(min.left(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), min.left());
+ change.setLeftMargin(max.left(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), max.left());
+
+ // Test setTopMargin
+ change.setTopMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), min.top());
+ change.setTopMargin(change.fullRectPoints().height(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), max.top());
+ change.setTopMargin(min.top(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), min.top());
+ change.setTopMargin(max.top(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), max.top());
+
+ // Test setRightMargin
+ change.setRightMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), min.right());
+ change.setRightMargin(change.fullRectPoints().width(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), max.right());
+ change.setRightMargin(min.right(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), min.right());
+ change.setRightMargin(max.right(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), max.right());
+
+ // Test setBottomMargin
+ change.setBottomMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), min.bottom());
+ change.setBottomMargin(change.fullRectPoints().height(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), max.bottom());
+ change.setBottomMargin(min.bottom(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), min.bottom());
+ change.setBottomMargin(max.bottom(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), max.bottom());
+}
+
+void tst_QPageLayout::setUnits_data()
+{
+ QTest::addColumn<QPageLayout::Unit>("units");
+ QTest::newRow("Millimeter") << QPageLayout::Millimeter;
+ QTest::newRow("Point") << QPageLayout::Point;
+ QTest::newRow("Inch") << QPageLayout::Inch;
+ QTest::newRow("Pica") << QPageLayout::Pica;
+ QTest::newRow("Didot") << QPageLayout::Didot;
+ QTest::newRow("Cicero") << QPageLayout::Cicero;
+}
+
+void tst_QPageLayout::setUnits()
+{
+ QFETCH(QPageLayout::Unit, units);
+ QPageLayout pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(), units);
+ int maxLeftX100 = qFloor(pageLayout.maximumMargins().left() * 100);
+ QVERIFY(maxLeftX100 > 0);
+ for (int i = 1; i <= maxLeftX100; ++i) {
+ const qreal margin = i / 100.;
+ const QMarginsF unitsMargins = QMarginsF(margin, margin, margin, margin);
+ pageLayout.setMargins(unitsMargins);
+ pageLayout.setUnits(QPageLayout::Point);
+ const QMarginsF pointsMargins = pageLayout.margins();
+ if (units == QPageLayout::Point) {
+ QCOMPARE(pointsMargins, unitsMargins);
+ } else {
+ QCOMPARE_GT(pointsMargins.left(), unitsMargins.left());
+ QCOMPARE_GT(pointsMargins.top(), unitsMargins.top());
+ QCOMPARE_GT(pointsMargins.right(), unitsMargins.right());
+ QCOMPARE_GT(pointsMargins.bottom(), unitsMargins.bottom());
+ }
+ pageLayout.setUnits(units);
+ const QMarginsF convertedUnitsMargins = pageLayout.margins();
+ if (units == QPageLayout::Didot) {
+ // When using Didot units, the small multiplier and ceiling function in conversion
+ // may cause the converted units to not match the original exactly. However, we
+ // can verify that the converted margins are always greater than or equal to the
+ // original.
+ QCOMPARE_GE(convertedUnitsMargins.left(), unitsMargins.left());
+ QCOMPARE_GE(convertedUnitsMargins.top(), unitsMargins.top());
+ QCOMPARE_GE(convertedUnitsMargins.right(), unitsMargins.right());
+ QCOMPARE_GE(convertedUnitsMargins.bottom(), unitsMargins.bottom());
+ } else {
+ QCOMPARE(convertedUnitsMargins, unitsMargins);
+ }
+ }
+}
+
QTEST_APPLESS_MAIN(tst_QPageLayout)
#include "tst_qpagelayout.moc"
diff --git a/tests/auto/gui/painting/qpageranges/CMakeLists.txt b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
index 660d4b4336..99ab477eae 100644
--- a/tests/auto/gui/painting/qpageranges/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qpageranges.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpageranges Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpageranges LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpageranges
SOURCES
tst_qpageranges.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
index 4912aa43c1..d2dbf990e3 100644
--- a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
+++ b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qpageranges.h>
@@ -95,7 +70,7 @@ void tst_QPageRanges::addPage()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (int pageNumber : qAsConst(pageNumbers)) {
+ for (int pageNumber : std::as_const(pageNumbers)) {
if (QByteArrayView(QTest::currentDataTag()) == "invalid")
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addPage: 'pageNumber' must be greater than 0");
result.addPage(pageNumber);
@@ -137,7 +112,7 @@ void tst_QPageRanges::addRange()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (const auto &range : qAsConst(ranges)) {
+ for (const auto &range : std::as_const(ranges)) {
const QByteArrayView testdata(QTest::currentDataTag());
if (testdata.startsWith("invalid"))
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addRange: 'from' and 'to' must be greater than 0");
diff --git a/tests/auto/gui/painting/qpagesize/CMakeLists.txt b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
index fc6fd931c2..b16cd2714a 100644
--- a/tests/auto/gui/painting/qpagesize/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
@@ -1,14 +1,21 @@
-# Generated from qpagesize.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpagesize Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpagesize LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpagesize
SOURCES
tst_qpagesize.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
index 838f7e59cd..de9b799902 100644
--- a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
+++ b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
#include <QtGlobal>
@@ -74,11 +49,13 @@ void tst_QPageSize::basics()
QCOMPARE(a4.size(QPageSize::Pica), QSizeF(49.58, 70.17));
QCOMPARE(a4.sizePoints(), QSize(595, 842));
QCOMPARE(a4.sizePixels(72), QSize(595, 842));
+ QCOMPARE(a4.sizePixels(600), QSize(4958, 7016)); // Rounded down
QCOMPARE(a4.rect(QPageSize::Millimeter), QRectF(0, 0, 210, 297));
QCOMPARE(a4.rect(QPageSize::Inch), QRectF(0, 0, 8.27, 11.69));
QCOMPARE(a4.rect(QPageSize::Pica), QRectF(0, 0, 49.58, 70.17));
QCOMPARE(a4.rectPoints(), QRect(0, 0, 595, 842));
QCOMPARE(a4.rectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(a4.rectPixels(600), QRect(0, 0, 4958, 7016)); // Rounded down
// Simple QPageSize::PaperSizeId later in list
QPageSize folio = QPageSize(QPageSize::Folio);
diff --git a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
index b843135645..4cd0151a01 100644
--- a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qpaintengine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpaintengine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpaintengine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpaintengine
SOURCES
tst_qpaintengine.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
index 4363799702..02441de54c 100644
--- a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
+++ b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
diff --git a/tests/auto/gui/painting/qpainter/BLACKLIST b/tests/auto/gui/painting/qpainter/BLACKLIST
deleted file mode 100644
index b828cbc75e..0000000000
--- a/tests/auto/gui/painting/qpainter/BLACKLIST
+++ /dev/null
@@ -1,3 +0,0 @@
-[textOnTransparentImage]
-# QTBUG-69166
-android
diff --git a/tests/auto/gui/painting/qpainter/CMakeLists.txt b/tests/auto/gui/painting/qpainter/CMakeLists.txt
index bfb992c7b5..261e1eb2cf 100644
--- a/tests/auto/gui/painting/qpainter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainter/CMakeLists.txt
@@ -1,9 +1,16 @@
-# Generated from qpainter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -26,7 +33,7 @@ list(APPEND test_data "task217400.png")
qt_internal_add_test(tst_qpainter
SOURCES
tst_qpainter.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -37,202 +44,7 @@ qt_internal_add_test(tst_qpainter
#####################################################################
qt_internal_extend_target(tst_qpainter CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Widgets
Qt::WidgetsPrivate
)
-
-if(ANDROID AND NOT ANDROID_EMBEDDED)
- # Resources:
- set(testdata_resource_files
- "drawEllipse/10x10SizeAt0x0.png"
- "drawEllipse/10x10SizeAt100x100.png"
- "drawEllipse/10x10SizeAt200x200.png"
- "drawEllipse/13x100SizeAt0x0.png"
- "drawEllipse/13x100SizeAt100x100.png"
- "drawEllipse/13x100SizeAt200x200.png"
- "drawEllipse/200x200SizeAt0x0.png"
- "drawEllipse/200x200SizeAt100x100.png"
- "drawEllipse/200x200SizeAt200x200.png"
- "drawLine_rop_bitmap/dst.xbm"
- "drawLine_rop_bitmap/res/res_AndNotROP.xbm"
- "drawLine_rop_bitmap/res/res_AndROP.xbm"
- "drawLine_rop_bitmap/res/res_ClearROP.xbm"
- "drawLine_rop_bitmap/res/res_CopyROP.xbm"
- "drawLine_rop_bitmap/res/res_NandROP.xbm"
- "drawLine_rop_bitmap/res/res_NopROP.xbm"
- "drawLine_rop_bitmap/res/res_NorROP.xbm"
- "drawLine_rop_bitmap/res/res_NotAndROP.xbm"
- "drawLine_rop_bitmap/res/res_NotCopyROP.xbm"
- "drawLine_rop_bitmap/res/res_NotOrROP.xbm"
- "drawLine_rop_bitmap/res/res_NotROP.xbm"
- "drawLine_rop_bitmap/res/res_NotXorROP.xbm"
- "drawLine_rop_bitmap/res/res_OrNotROP.xbm"
- "drawLine_rop_bitmap/res/res_OrROP.xbm"
- "drawLine_rop_bitmap/res/res_SetROP.xbm"
- "drawLine_rop_bitmap/res/res_XorROP.xbm"
- "drawPixmap_rop/dst1.png"
- "drawPixmap_rop/dst2.png"
- "drawPixmap_rop/dst3.png"
- "drawPixmap_rop/res/res_AndNotROP0.png"
- "drawPixmap_rop/res/res_AndNotROP1.png"
- "drawPixmap_rop/res/res_AndNotROP2.png"
- "drawPixmap_rop/res/res_AndNotROP3.png"
- "drawPixmap_rop/res/res_AndNotROP4.png"
- "drawPixmap_rop/res/res_AndNotROP5.png"
- "drawPixmap_rop/res/res_AndNotROP6.png"
- "drawPixmap_rop/res/res_AndNotROP7.png"
- "drawPixmap_rop/res/res_AndROP0.png"
- "drawPixmap_rop/res/res_AndROP1.png"
- "drawPixmap_rop/res/res_AndROP2.png"
- "drawPixmap_rop/res/res_AndROP3.png"
- "drawPixmap_rop/res/res_AndROP4.png"
- "drawPixmap_rop/res/res_AndROP5.png"
- "drawPixmap_rop/res/res_AndROP6.png"
- "drawPixmap_rop/res/res_AndROP7.png"
- "drawPixmap_rop/res/res_ClearROP0.png"
- "drawPixmap_rop/res/res_ClearROP1.png"
- "drawPixmap_rop/res/res_ClearROP2.png"
- "drawPixmap_rop/res/res_ClearROP3.png"
- "drawPixmap_rop/res/res_ClearROP4.png"
- "drawPixmap_rop/res/res_ClearROP5.png"
- "drawPixmap_rop/res/res_ClearROP6.png"
- "drawPixmap_rop/res/res_ClearROP7.png"
- "drawPixmap_rop/res/res_CopyROP0.png"
- "drawPixmap_rop/res/res_CopyROP1.png"
- "drawPixmap_rop/res/res_CopyROP2.png"
- "drawPixmap_rop/res/res_CopyROP3.png"
- "drawPixmap_rop/res/res_CopyROP4.png"
- "drawPixmap_rop/res/res_CopyROP5.png"
- "drawPixmap_rop/res/res_CopyROP6.png"
- "drawPixmap_rop/res/res_CopyROP7.png"
- "drawPixmap_rop/res/res_NandROP0.png"
- "drawPixmap_rop/res/res_NandROP1.png"
- "drawPixmap_rop/res/res_NandROP2.png"
- "drawPixmap_rop/res/res_NandROP3.png"
- "drawPixmap_rop/res/res_NandROP4.png"
- "drawPixmap_rop/res/res_NandROP5.png"
- "drawPixmap_rop/res/res_NandROP6.png"
- "drawPixmap_rop/res/res_NandROP7.png"
- "drawPixmap_rop/res/res_NopROP0.png"
- "drawPixmap_rop/res/res_NopROP1.png"
- "drawPixmap_rop/res/res_NopROP2.png"
- "drawPixmap_rop/res/res_NopROP3.png"
- "drawPixmap_rop/res/res_NopROP4.png"
- "drawPixmap_rop/res/res_NopROP5.png"
- "drawPixmap_rop/res/res_NopROP6.png"
- "drawPixmap_rop/res/res_NopROP7.png"
- "drawPixmap_rop/res/res_NorROP0.png"
- "drawPixmap_rop/res/res_NorROP1.png"
- "drawPixmap_rop/res/res_NorROP2.png"
- "drawPixmap_rop/res/res_NorROP3.png"
- "drawPixmap_rop/res/res_NorROP4.png"
- "drawPixmap_rop/res/res_NorROP5.png"
- "drawPixmap_rop/res/res_NorROP6.png"
- "drawPixmap_rop/res/res_NorROP7.png"
- "drawPixmap_rop/res/res_NotAndROP0.png"
- "drawPixmap_rop/res/res_NotAndROP1.png"
- "drawPixmap_rop/res/res_NotAndROP2.png"
- "drawPixmap_rop/res/res_NotAndROP3.png"
- "drawPixmap_rop/res/res_NotAndROP4.png"
- "drawPixmap_rop/res/res_NotAndROP5.png"
- "drawPixmap_rop/res/res_NotAndROP6.png"
- "drawPixmap_rop/res/res_NotAndROP7.png"
- "drawPixmap_rop/res/res_NotCopyROP0.png"
- "drawPixmap_rop/res/res_NotCopyROP1.png"
- "drawPixmap_rop/res/res_NotCopyROP2.png"
- "drawPixmap_rop/res/res_NotCopyROP3.png"
- "drawPixmap_rop/res/res_NotCopyROP4.png"
- "drawPixmap_rop/res/res_NotCopyROP5.png"
- "drawPixmap_rop/res/res_NotCopyROP6.png"
- "drawPixmap_rop/res/res_NotCopyROP7.png"
- "drawPixmap_rop/res/res_NotOrROP0.png"
- "drawPixmap_rop/res/res_NotOrROP1.png"
- "drawPixmap_rop/res/res_NotOrROP2.png"
- "drawPixmap_rop/res/res_NotOrROP3.png"
- "drawPixmap_rop/res/res_NotOrROP4.png"
- "drawPixmap_rop/res/res_NotOrROP5.png"
- "drawPixmap_rop/res/res_NotOrROP6.png"
- "drawPixmap_rop/res/res_NotOrROP7.png"
- "drawPixmap_rop/res/res_NotROP0.png"
- "drawPixmap_rop/res/res_NotROP1.png"
- "drawPixmap_rop/res/res_NotROP2.png"
- "drawPixmap_rop/res/res_NotROP3.png"
- "drawPixmap_rop/res/res_NotROP4.png"
- "drawPixmap_rop/res/res_NotROP5.png"
- "drawPixmap_rop/res/res_NotROP6.png"
- "drawPixmap_rop/res/res_NotROP7.png"
- "drawPixmap_rop/res/res_NotXorROP0.png"
- "drawPixmap_rop/res/res_NotXorROP1.png"
- "drawPixmap_rop/res/res_NotXorROP2.png"
- "drawPixmap_rop/res/res_NotXorROP3.png"
- "drawPixmap_rop/res/res_NotXorROP4.png"
- "drawPixmap_rop/res/res_NotXorROP5.png"
- "drawPixmap_rop/res/res_NotXorROP6.png"
- "drawPixmap_rop/res/res_NotXorROP7.png"
- "drawPixmap_rop/res/res_OrNotROP0.png"
- "drawPixmap_rop/res/res_OrNotROP1.png"
- "drawPixmap_rop/res/res_OrNotROP2.png"
- "drawPixmap_rop/res/res_OrNotROP3.png"
- "drawPixmap_rop/res/res_OrNotROP4.png"
- "drawPixmap_rop/res/res_OrNotROP5.png"
- "drawPixmap_rop/res/res_OrNotROP6.png"
- "drawPixmap_rop/res/res_OrNotROP7.png"
- "drawPixmap_rop/res/res_OrROP0.png"
- "drawPixmap_rop/res/res_OrROP1.png"
- "drawPixmap_rop/res/res_OrROP2.png"
- "drawPixmap_rop/res/res_OrROP3.png"
- "drawPixmap_rop/res/res_OrROP4.png"
- "drawPixmap_rop/res/res_OrROP5.png"
- "drawPixmap_rop/res/res_OrROP6.png"
- "drawPixmap_rop/res/res_OrROP7.png"
- "drawPixmap_rop/res/res_SetROP0.png"
- "drawPixmap_rop/res/res_SetROP1.png"
- "drawPixmap_rop/res/res_SetROP2.png"
- "drawPixmap_rop/res/res_SetROP3.png"
- "drawPixmap_rop/res/res_SetROP4.png"
- "drawPixmap_rop/res/res_SetROP5.png"
- "drawPixmap_rop/res/res_SetROP6.png"
- "drawPixmap_rop/res/res_SetROP7.png"
- "drawPixmap_rop/res/res_XorROP0.png"
- "drawPixmap_rop/res/res_XorROP1.png"
- "drawPixmap_rop/res/res_XorROP2.png"
- "drawPixmap_rop/res/res_XorROP3.png"
- "drawPixmap_rop/res/res_XorROP4.png"
- "drawPixmap_rop/res/res_XorROP5.png"
- "drawPixmap_rop/res/res_XorROP6.png"
- "drawPixmap_rop/res/res_XorROP7.png"
- "drawPixmap_rop/src1.xbm"
- "drawPixmap_rop/src2-mask.xbm"
- "drawPixmap_rop/src2.xbm"
- "drawPixmap_rop/src3.xbm"
- "drawPixmap_rop_bitmap/dst.xbm"
- "drawPixmap_rop_bitmap/res/res_AndNotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_AndROP.xbm"
- "drawPixmap_rop_bitmap/res/res_ClearROP.xbm"
- "drawPixmap_rop_bitmap/res/res_CopyROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NandROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NopROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NorROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotAndROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotCopyROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotOrROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotXorROP.xbm"
- "drawPixmap_rop_bitmap/res/res_OrNotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_OrROP.xbm"
- "drawPixmap_rop_bitmap/res/res_SetROP.xbm"
- "drawPixmap_rop_bitmap/res/res_XorROP.xbm"
- "drawPixmap_rop_bitmap/src1-mask.xbm"
- "drawPixmap_rop_bitmap/src1.xbm"
- "drawPixmap_rop_bitmap/src2.xbm"
- "task217400.png"
- )
-
- qt_internal_add_resource(tst_qpainter "testdata"
- PREFIX
- "/"
- FILES
- ${testdata_resource_files}
- )
-endif()
diff --git a/tests/auto/gui/painting/qpainter/testdata.qrc b/tests/auto/gui/painting/qpainter/testdata.qrc
deleted file mode 100644
index a7b8c222e5..0000000000
--- a/tests/auto/gui/painting/qpainter/testdata.qrc
+++ /dev/null
@@ -1,186 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>task217400.png</file>
- <file>drawEllipse/10x10SizeAt0x0.png</file>
- <file>drawEllipse/10x10SizeAt100x100.png</file>
- <file>drawEllipse/10x10SizeAt200x200.png</file>
- <file>drawEllipse/13x100SizeAt0x0.png</file>
- <file>drawEllipse/13x100SizeAt100x100.png</file>
- <file>drawEllipse/13x100SizeAt200x200.png</file>
- <file>drawEllipse/200x200SizeAt0x0.png</file>
- <file>drawEllipse/200x200SizeAt100x100.png</file>
- <file>drawEllipse/200x200SizeAt200x200.png</file>
- <file>drawLine_rop_bitmap/dst.xbm</file>
- <file>drawLine_rop_bitmap/res/res_AndNotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_AndROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_ClearROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_CopyROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NandROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NopROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NorROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotAndROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotCopyROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotOrROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotXorROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_OrNotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_OrROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_SetROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_XorROP.xbm</file>
- <file>drawPixmap_rop/dst1.png</file>
- <file>drawPixmap_rop/dst2.png</file>
- <file>drawPixmap_rop/dst3.png</file>
- <file>drawPixmap_rop/src1.xbm</file>
- <file>drawPixmap_rop/src2-mask.xbm</file>
- <file>drawPixmap_rop/src2.xbm</file>
- <file>drawPixmap_rop/src3.xbm</file>
- <file>drawPixmap_rop/res/res_AndNotROP0.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP1.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP2.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP3.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP4.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP5.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP6.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP7.png</file>
- <file>drawPixmap_rop/res/res_AndROP0.png</file>
- <file>drawPixmap_rop/res/res_AndROP1.png</file>
- <file>drawPixmap_rop/res/res_AndROP2.png</file>
- <file>drawPixmap_rop/res/res_AndROP3.png</file>
- <file>drawPixmap_rop/res/res_AndROP4.png</file>
- <file>drawPixmap_rop/res/res_AndROP5.png</file>
- <file>drawPixmap_rop/res/res_AndROP6.png</file>
- <file>drawPixmap_rop/res/res_AndROP7.png</file>
- <file>drawPixmap_rop/res/res_ClearROP0.png</file>
- <file>drawPixmap_rop/res/res_ClearROP1.png</file>
- <file>drawPixmap_rop/res/res_ClearROP2.png</file>
- <file>drawPixmap_rop/res/res_ClearROP3.png</file>
- <file>drawPixmap_rop/res/res_ClearROP4.png</file>
- <file>drawPixmap_rop/res/res_ClearROP5.png</file>
- <file>drawPixmap_rop/res/res_ClearROP6.png</file>
- <file>drawPixmap_rop/res/res_ClearROP7.png</file>
- <file>drawPixmap_rop/res/res_CopyROP0.png</file>
- <file>drawPixmap_rop/res/res_CopyROP1.png</file>
- <file>drawPixmap_rop/res/res_CopyROP2.png</file>
- <file>drawPixmap_rop/res/res_CopyROP3.png</file>
- <file>drawPixmap_rop/res/res_CopyROP4.png</file>
- <file>drawPixmap_rop/res/res_CopyROP5.png</file>
- <file>drawPixmap_rop/res/res_CopyROP6.png</file>
- <file>drawPixmap_rop/res/res_CopyROP7.png</file>
- <file>drawPixmap_rop/res/res_NandROP0.png</file>
- <file>drawPixmap_rop/res/res_NandROP1.png</file>
- <file>drawPixmap_rop/res/res_NandROP2.png</file>
- <file>drawPixmap_rop/res/res_NandROP3.png</file>
- <file>drawPixmap_rop/res/res_NandROP4.png</file>
- <file>drawPixmap_rop/res/res_NandROP5.png</file>
- <file>drawPixmap_rop/res/res_NandROP6.png</file>
- <file>drawPixmap_rop/res/res_NandROP7.png</file>
- <file>drawPixmap_rop/res/res_NopROP0.png</file>
- <file>drawPixmap_rop/res/res_NopROP1.png</file>
- <file>drawPixmap_rop/res/res_NopROP2.png</file>
- <file>drawPixmap_rop/res/res_NopROP3.png</file>
- <file>drawPixmap_rop/res/res_NopROP4.png</file>
- <file>drawPixmap_rop/res/res_NopROP5.png</file>
- <file>drawPixmap_rop/res/res_NopROP6.png</file>
- <file>drawPixmap_rop/res/res_NopROP7.png</file>
- <file>drawPixmap_rop/res/res_NorROP0.png</file>
- <file>drawPixmap_rop/res/res_NorROP1.png</file>
- <file>drawPixmap_rop/res/res_NorROP2.png</file>
- <file>drawPixmap_rop/res/res_NorROP3.png</file>
- <file>drawPixmap_rop/res/res_NorROP4.png</file>
- <file>drawPixmap_rop/res/res_NorROP5.png</file>
- <file>drawPixmap_rop/res/res_NorROP6.png</file>
- <file>drawPixmap_rop/res/res_NorROP7.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP0.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP1.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP2.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP3.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP4.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP5.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP6.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP7.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP0.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP1.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP2.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP3.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP4.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP5.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP6.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP7.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP0.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP1.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP2.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP3.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP4.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP5.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP6.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP7.png</file>
- <file>drawPixmap_rop/res/res_NotROP0.png</file>
- <file>drawPixmap_rop/res/res_NotROP1.png</file>
- <file>drawPixmap_rop/res/res_NotROP2.png</file>
- <file>drawPixmap_rop/res/res_NotROP3.png</file>
- <file>drawPixmap_rop/res/res_NotROP4.png</file>
- <file>drawPixmap_rop/res/res_NotROP5.png</file>
- <file>drawPixmap_rop/res/res_NotROP6.png</file>
- <file>drawPixmap_rop/res/res_NotROP7.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP0.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP1.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP2.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP3.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP4.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP5.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP6.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP7.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP0.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP1.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP2.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP3.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP4.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP5.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP6.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP7.png</file>
- <file>drawPixmap_rop/res/res_OrROP0.png</file>
- <file>drawPixmap_rop/res/res_OrROP1.png</file>
- <file>drawPixmap_rop/res/res_OrROP2.png</file>
- <file>drawPixmap_rop/res/res_OrROP3.png</file>
- <file>drawPixmap_rop/res/res_OrROP4.png</file>
- <file>drawPixmap_rop/res/res_OrROP5.png</file>
- <file>drawPixmap_rop/res/res_OrROP6.png</file>
- <file>drawPixmap_rop/res/res_OrROP7.png</file>
- <file>drawPixmap_rop/res/res_SetROP0.png</file>
- <file>drawPixmap_rop/res/res_SetROP1.png</file>
- <file>drawPixmap_rop/res/res_SetROP2.png</file>
- <file>drawPixmap_rop/res/res_SetROP3.png</file>
- <file>drawPixmap_rop/res/res_SetROP4.png</file>
- <file>drawPixmap_rop/res/res_SetROP5.png</file>
- <file>drawPixmap_rop/res/res_SetROP6.png</file>
- <file>drawPixmap_rop/res/res_SetROP7.png</file>
- <file>drawPixmap_rop/res/res_XorROP0.png</file>
- <file>drawPixmap_rop/res/res_XorROP1.png</file>
- <file>drawPixmap_rop/res/res_XorROP2.png</file>
- <file>drawPixmap_rop/res/res_XorROP3.png</file>
- <file>drawPixmap_rop/res/res_XorROP4.png</file>
- <file>drawPixmap_rop/res/res_XorROP5.png</file>
- <file>drawPixmap_rop/res/res_XorROP6.png</file>
- <file>drawPixmap_rop/res/res_XorROP7.png</file>
- <file>drawPixmap_rop_bitmap/dst.xbm</file>
- <file>drawPixmap_rop_bitmap/src1-mask.xbm</file>
- <file>drawPixmap_rop_bitmap/src1.xbm</file>
- <file>drawPixmap_rop_bitmap/src2.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_AndNotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_AndROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_ClearROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_CopyROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NandROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NopROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NorROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotAndROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotCopyROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotOrROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotXorROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_OrNotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_OrROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_SetROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_XorROP.xbm</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 30ce4fcfa8..92b28f65bd 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -1,31 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
#include <qpainter.h>
@@ -69,6 +43,9 @@ Q_OBJECT
public:
tst_QPainter();
+ enum ClipType { ClipRect, ClipRectF, ClipRegionSingle, ClipRegionMulti, ClipPathR, ClipPath };
+ Q_ENUM(ClipType);
+
private slots:
void cleanupTestCase();
void getSetCheck();
@@ -84,6 +61,7 @@ private slots:
#endif
void drawPixmapFragments();
void drawPixmapNegativeScale();
+ void drawPixmapRounding();
void drawLine_data();
void drawLine();
@@ -155,6 +133,8 @@ private slots:
void clipBoundingRect();
void transformedClip();
+ void scaledClipConsistency_data();
+ void scaledClipConsistency();
void setOpacity_data();
void setOpacity();
@@ -190,6 +170,7 @@ private slots:
void radialGradientRgb30();
#endif
+ void radialGradient_QTBUG120332_ubsan();
void fpe_pixmapTransform();
void fpe_zeroLengthLines();
void fpe_divByZero();
@@ -300,6 +281,10 @@ private slots:
void fillPolygon();
void drawImageAtPointF();
+ void scaledDashes();
+#if QT_CONFIG(raster_fp)
+ void hdrColors();
+#endif
private:
void fillData();
@@ -599,7 +584,7 @@ QImage tst_QPainter::getResImage( const QString &dir, const QString &addition, c
QImage res;
QString resFilename = dir + QLatin1String("/res_") + addition + QLatin1Char('.') + extension;
if ( !res.load( resFilename ) ) {
- QWARN(QString("Could not load result data %s %1").arg(resFilename).toLatin1());
+ qWarning() << "Could not load result data" << resFilename;
return QImage();
}
return res;
@@ -610,14 +595,14 @@ QBitmap tst_QPainter::getBitmap( const QString &dir, const QString &filename, bo
QBitmap bm;
QString bmFilename = dir + QLatin1Char('/') + filename + QLatin1String(".xbm");
if ( !bm.load( bmFilename ) ) {
- QWARN(QString("Could not load bitmap '%1'").arg(bmFilename).toLatin1());
+ qWarning() << "Could not load bitmap" << bmFilename;
return QBitmap();
}
if ( mask ) {
QBitmap mask;
QString maskFilename = dir + QLatin1Char('/') + filename + QLatin1String("-mask.xbm");
if (!mask.load(maskFilename)) {
- QWARN(QString("Could not load mask '%1'").arg(maskFilename).toLatin1());
+ qWarning() << "Could not load mask" << maskFilename;
return QBitmap();
}
bm.setMask( mask );
@@ -763,6 +748,16 @@ void tst_QPainter::drawPixmapNegativeScale()
QVERIFY(resultImage.pixel(12, 8) == qRgba(0, 0, 0, 255)); // and right strip is now black
}
+void tst_QPainter::drawPixmapRounding()
+{
+ // Just test that we don't assert
+ QBitmap bm(8, 8);
+ QImage out(64, 64, QImage::Format_RGB32);
+ QPainter p(&out);
+ qreal y = 26.499999999999996;
+ p.drawPixmap(QPointF(0, y), bm);
+}
+
void tst_QPainter::drawLine_data()
{
QTest::addColumn<QLine>("line");
@@ -1060,6 +1055,7 @@ void tst_QPainter::fillRect_data()
QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgba64pm") << QImage::Format_RGBA64_Premultiplied;
+ QTest::newRow("rgbaFP16pm") << QImage::Format_RGBA16FPx4_Premultiplied;
}
void tst_QPainter::fillRect()
@@ -1558,6 +1554,8 @@ void tst_QPainter::qimageFormats_data()
QTest::newRow("Qimage::Format_BGR888") << QImage::Format_BGR888;
QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied;
QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30;
+ QTest::newRow("QImage::Format_RGBX16FPx4") << QImage::Format_RGBX16FPx4;
+ QTest::newRow("QImage::Format_RGBA32FPx4_Premultiplied") << QImage::Format_RGBA32FPx4_Premultiplied;
}
/*
@@ -1745,10 +1743,11 @@ void tst_QPainter::setClipRect()
/*
Verify that the clipping works correctly.
- The red outline should be covered by the blue rect on top and left,
- while it should be clipped on the right and bottom and thus the red outline be visible
+ Just like fillRect, cliprect should snap rightwards and downwards in case of .5 coordinates.
+ The red outline should be covered by the blue rect on top,
+ while it should be clipped on the other edges and thus the red outline be visible
- See: QTBUG-83229
+ See: QTBUG-83229, modified by QTBUG-100329
*/
void tst_QPainter::clipRect()
{
@@ -1774,7 +1773,7 @@ void tst_QPainter::clipRect()
p.end();
QCOMPARE(image.pixelColor(clipRect.left() + 1, clipRect.top()), QColor(Qt::blue));
- QCOMPARE(image.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::blue));
+ QCOMPARE(image.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::red));
QCOMPARE(image.pixelColor(clipRect.left() + 1, clipRect.bottom()), QColor(Qt::red));
QCOMPARE(image.pixelColor(clipRect.right(), clipRect.top() + 1), QColor(Qt::red));
}
@@ -2094,21 +2093,22 @@ void tst_QPainter::clippedLines_data()
QPen pen2(QColor(223, 223, 0, 223));
pen2.setWidth(2);
- QList<QLineF> lines;
- lines << QLineF(15, 15, 65, 65)
- << QLineF(14, 14, 66, 66)
- << QLineF(16, 16, 64, 64)
- << QLineF(65, 65, 15, 15)
- << QLineF(66, 66, 14, 14)
- << QLineF(64, 64, 14, 14)
- << QLineF(15, 50, 15, 64)
- << QLineF(15, 50, 15, 65)
- << QLineF(15, 50, 15, 66)
- << QLineF(15, 50, 64, 50)
- << QLineF(15, 50, 65, 50)
- << QLineF(15, 50, 66, 50);
-
- foreach (QLineF line, lines) {
+ const auto lines = {
+ QLineF(15, 15, 65, 65),
+ QLineF(14, 14, 66, 66),
+ QLineF(16, 16, 64, 64),
+ QLineF(65, 65, 15, 15),
+ QLineF(66, 66, 14, 14),
+ QLineF(64, 64, 14, 14),
+ QLineF(15, 50, 15, 64),
+ QLineF(15, 50, 15, 65),
+ QLineF(15, 50, 15, 66),
+ QLineF(15, 50, 64, 50),
+ QLineF(15, 50, 65, 50),
+ QLineF(15, 50, 66, 50),
+ };
+
+ for (QLineF line : lines) {
const QByteArray desc = "line (" + QByteArray::number(line.x1())
+ ", " + QByteArray::number(line.y1()) + ", "
+ QByteArray::number(line.x2()) + ", " + QByteArray::number(line.y2())
@@ -2509,6 +2509,12 @@ void tst_QPainter::drawhelper_blend_untransformed_data()
setOpacity_data();
}
+static const auto &defaultOpacities()
+{
+ static const std::array opacities = {qreal(0.0), 0.1 , 0.01, 0.4, 0.5, 0.6, 0.9, 1.0};
+ return opacities;
+}
+
void tst_QPainter::drawhelper_blend_untransformed()
{
QFETCH(QImage::Format, destFormat);
@@ -2529,9 +2535,7 @@ void tst_QPainter::drawhelper_blend_untransformed()
p.fillRect(paintRect, srcColor);
p.end();
- QList<qreal> opacities = (QList<qreal>() << 0.0 << 0.1 << 0.01 << 0.4
- << 0.5 << 0.6 << 0.9 << 1.0);
- foreach (qreal opacity, opacities) {
+ for (qreal opacity : defaultOpacities()) {
p.begin(&dest);
p.fillRect(paintRect, destColor);
@@ -2586,9 +2590,7 @@ void tst_QPainter::drawhelper_blend_tiled_untransformed()
const QBrush brush(src);
- QList<qreal> opacities = (QList<qreal>() << 0.0 << 0.1 << 0.01 << 0.4
- << 0.5 << 0.6 << 0.9 << 1.0);
- foreach (qreal opacity, opacities) {
+ for (qreal opacity : defaultOpacities()) {
p.begin(&dest);
p.fillRect(paintRect, destColor);
@@ -2782,7 +2784,7 @@ void tst_QPainter::monoImages()
for (int i = 1; i < QImage::NImageFormats; ++i) {
for (int j = 0; j < numColorPairs; ++j) {
const QImage::Format format = QImage::Format(i);
- if (format == QImage::Format_Indexed8)
+ if (format == QImage::Format_Indexed8 || format == QImage::Format_CMYK8888)
continue;
QImage img(2, 2, format);
@@ -2842,7 +2844,14 @@ void tst_QPainter::monoImages()
}
}
-#if !defined(Q_OS_AIX) && !defined(Q_CC_MSVC) && !defined(Q_OS_SOLARIS) && !defined(__UCLIBC__)
+#if defined(Q_OS_DARWIN) || defined(Q_OS_FREEBSD) || defined(Q_OS_ANDROID)
+# define TEST_FPE_EXCEPTIONS
+#elif defined(Q_OS_LINUX) && defined(__GLIBC__)
+# define TEST_FPE_EXCEPTIONS
+#elif defined(Q_OS_WIN) && defined(Q_CC_GNU)
+# define TEST_FPE_EXCEPTIONS
+#endif
+#ifdef TEST_FPE_EXCEPTIONS
#include <fenv.h>
static const QString fpeExceptionString(int exception)
@@ -3545,9 +3554,13 @@ void tst_QPainter::drawImage_data()
for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) {
for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) {
- // Indexed8 can't be painted to, and Alpha8 can't hold a color.
- if (dstFormat == QImage::Format_Indexed8 || dstFormat == QImage::Format_Alpha8)
+ // Indexed8 and CMYK8888 can't be painted to, and Alpha8 can't hold a color.
+ if (dstFormat == QImage::Format_Indexed8 ||
+ dstFormat == QImage::Format_CMYK8888 ||
+ dstFormat == QImage::Format_Alpha8) {
continue;
+ }
+
for (int odd_x = 0; odd_x <= 1; ++odd_x) {
for (int odd_width = 0; odd_width <= 1; ++odd_width) {
QTest::addRow("srcFormat %d, dstFormat %d, odd x: %d, odd width: %d",
@@ -3790,10 +3803,10 @@ static QLinearGradient inverseGradient(QLinearGradient g)
{
QLinearGradient g2 = g;
- QGradientStops stops = g.stops();
+ const QGradientStops stops = g.stops();
QGradientStops inverse;
- foreach (QGradientStop stop, stops)
+ for (const QGradientStop &stop : stops)
inverse << QGradientStop(1 - stop.first, stop.second);
g2.setStops(inverse);
@@ -3899,6 +3912,21 @@ void tst_QPainter::gradientPixelFormat()
QCOMPARE(a, b.convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
+void tst_QPainter::radialGradient_QTBUG120332_ubsan()
+{
+ // Check if Radial Gradient will cause division by zero or not when
+ // the center point coincide with the focal point.
+ QImage image(8, 8, QImage::Format_ARGB32_Premultiplied);
+ QPainter painter(&image);
+
+ QPointF center(0.5, 0.5);
+ QPointF focal(0.5, 0.5);
+ QRadialGradient gradient(center, 0.5, focal, 0.5);
+ gradient.setColorAt(0, Qt::blue);
+ gradient.setColorAt(1, Qt::red);
+ painter.fillRect(image.rect(), QBrush(gradient));
+}
+
void tst_QPainter::gradientInterpolation()
{
QImage image(256, 8, QImage::Format_ARGB32_Premultiplied);
@@ -4576,6 +4604,96 @@ void tst_QPainter::transformedClip()
}
}
+void tst_QPainter::scaledClipConsistency_data()
+{
+ QTest::addColumn<ClipType>("clipType");
+
+ QTest::newRow("clipRect") << ClipRect;
+ QTest::newRow("clipRectF") << ClipRectF;
+ QTest::newRow("clipRegionSingle") << ClipRegionSingle;
+ QTest::newRow("clipRegionMulti") << ClipRegionMulti;
+ QTest::newRow("clipPathR") << ClipPathR;
+ QTest::newRow("clipPath") << ClipPath;
+}
+
+void tst_QPainter::scaledClipConsistency()
+{
+ QFETCH(ClipType, clipType);
+
+ const QList<QRect> clipRects = {
+ // Varying odd and even coordinates and width/height
+ QRect(1, 1, 7, 8),
+ QRect(8, 0, 8, 9),
+ QRect(0, 9, 8, 7),
+ QRect(8, 9, 8, 7),
+ };
+ // Assert that these are edge to edge:
+ QPointF center = QRectF(clipRects[0]).bottomRight();
+ Q_ASSERT(QRectF(clipRects[1]).bottomLeft() == center);
+ Q_ASSERT(QRectF(clipRects[2]).topRight() == center);
+ Q_ASSERT(QRectF(clipRects[3]).topLeft() == center);
+
+ QRegion multiRegion;
+ for (const QRect &clipRect : clipRects)
+ multiRegion += clipRect;
+
+ QColor fillColor(Qt::black);
+ fillColor.setAlphaF(0.5);
+
+ for (int i = 100; i <= 300; i++) {
+ qreal dpr = qreal(i) / 100.0;
+ QImage img(QSize(16, 16) * dpr, QImage::Format_RGB32);
+ img.fill(Qt::white);
+ img.setDevicePixelRatio(dpr);
+
+ for (const QRect &clipRect : clipRects) {
+ QPainter p(&img);
+ switch (clipType) {
+ case ClipRect:
+ p.setClipRect(clipRect);
+ break;
+ case ClipRectF:
+ p.setClipRect(QRectF(clipRect));
+ break;
+ case ClipRegionSingle:
+ p.setClipRegion(QRegion(clipRect));
+ break;
+ case ClipRegionMulti:
+ p.setClipRegion(multiRegion);
+ break;
+ case ClipPath:
+ p.rotate(0.001); // Avoid the path being optimized to a rectf
+ Q_FALLTHROUGH();
+ case ClipPathR: {
+ QPainterPath path;
+ path.addRect(clipRect); // Will be recognized and converted back to a rectf
+ p.setClipPath(path);
+ break;
+ }
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ p.fillRect(p.window(), fillColor);
+ if (clipType == ClipRegionMulti)
+ break; // once is enough, we're not using the clipRect anyway
+ }
+
+ int qtWidth = img.width() / 4;
+ int qtHeight = img.height() / 4;
+ QPoint imgCenter = img.rect().center();
+ const QRgb targetColor = img.pixel(qtWidth, qtHeight);
+
+ // Test that there are no gaps or overlaps where the cliprects meet
+ for (int offset = -2; offset <= 2; offset++) {
+ QCOMPARE(img.pixel(imgCenter.x() + offset, qtHeight), targetColor);
+ QCOMPARE(img.pixel(imgCenter.x() + offset, img.height() - qtHeight), targetColor);
+ QCOMPARE(img.pixel(qtWidth, imgCenter.y() + offset), targetColor);
+ QCOMPARE(img.pixel(img.width() - qtWidth, imgCenter.y() + offset), targetColor);
+ }
+ }
+}
+
#if defined(Q_OS_MAC)
// Only Mac supports sub pixel positions in raster engine currently
void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
@@ -4812,10 +4930,7 @@ void tst_QPainter::QTBUG25153_drawLine()
{
QImage image(2, 2, QImage::Format_RGB32);
- QList<Qt::PenCapStyle> styles;
- styles << Qt::FlatCap << Qt::SquareCap << Qt::RoundCap;
-
- foreach (Qt::PenCapStyle style, styles) {
+ for (Qt::PenCapStyle style : {Qt::FlatCap, Qt::SquareCap, Qt::RoundCap}) {
image.fill(0xffffffff);
QPainter p(&image);
p.setPen(QPen(Qt::black, 0, Qt::SolidLine, style));
@@ -4926,16 +5041,16 @@ void tst_QPainter::blendARGBonRGB_data()
QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85;
#if QT_CONFIG(raster_64bit)
- QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
- << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85;
- QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
- << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85;
+ QTest::newRow("ARGB@85 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85;
+ QTest::newRow("ARGB@120 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85;
#endif
- QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
- << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85;
+ QTest::newRow("ARGB_PM@85 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85;
#if QT_CONFIG(raster_64bit)
- QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
- << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170;
+ QTest::newRow("ARGB_PM@180 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170;
#endif
QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85;
@@ -5096,7 +5211,7 @@ void tst_QPainter::drawPolyline()
p.setPen(pen);
QVERIFY(p.pen().isCosmetic());
if (r) {
- for (int i = 0; i < points.count()-1; i++) {
+ for (int i = 0; i < points.size()-1; i++) {
p.drawLine(points.at(i), points.at(i+1));
}
} else {
@@ -5359,6 +5474,79 @@ void tst_QPainter::drawImageAtPointF()
paint.end();
}
+void tst_QPainter::scaledDashes()
+{
+ // Test that we do not hit the limit-huge-number-of-dashes path
+ QRgb fore = qRgb(0, 0, 0xff);
+ QRgb back = qRgb(0xff, 0xff, 0);
+ QImage image(5, 32, QImage::Format_RGB32);
+ image.fill(back);
+ QPainter p(&image);
+ QPen pen(QColor(fore), 3, Qt::DotLine);
+ p.setPen(pen);
+ p.scale(1, 2);
+ p.drawLine(2, 0, 2, 16);
+ p.end();
+
+ bool foreFound = false;
+ bool backFound = false;
+ int i = 0;
+ while (i < 32 && (!foreFound || !backFound)) {
+ QRgb pix = image.pixel(3, i);
+ if (pix == fore)
+ foreFound = true;
+ else if (pix == back)
+ backFound = true;
+ i++;
+ }
+
+ QVERIFY(foreFound);
+ QVERIFY(backFound);
+}
+
+#if QT_CONFIG(raster_fp)
+void tst_QPainter::hdrColors()
+{
+ QImage img(10, 10, QImage::Format_RGBA32FPx4_Premultiplied);
+ img.fill(Qt::transparent);
+
+ QColor color = QColor::fromRgbF(2.0f, -0.25f, 1.5f);
+ img.setPixelColor(2, 2, color);
+ QCOMPARE(img.pixelColor(2, 2), color);
+
+ {
+ QPainterPath path;
+ path.addEllipse(4, 4, 2, 2);
+ QPainter p(&img);
+ p.fillPath(path, color);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ img.fill(color);
+ QCOMPARE(img.pixelColor(8, 8), color);
+
+ QColor color2 = QColor::fromRgbF(0.0f, 1.25f, 2.5f);
+ {
+ QPainter p(&img);
+ p.fillRect(0, 0, 3, 3, color2);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(1, 1), color2);
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ QImage img2(10, 10, QImage::Format_RGBX32FPx4);
+ img2.fill(Qt::black); // fill to avoid random FP values like Inf which can break SourceOver composition
+ {
+ QPainter p(&img2);
+ p.drawImage(0, 0, img);
+ p.end();
+ }
+ QCOMPARE(img2.pixelColor(2, 2), color2);
+ QCOMPARE(img2.pixelColor(5, 5), color);
+}
+#endif
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
index 53ea3ce9fb..7cb9e74216 100644
--- a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
+++ b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <qapplication.h>
diff --git a/tests/auto/gui/painting/qpainterpath/BLACKLIST b/tests/auto/gui/painting/qpainterpath/BLACKLIST
deleted file mode 100644
index b3e6d3bfe4..0000000000
--- a/tests/auto/gui/painting/qpainterpath/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[contains_QPointF]
-msvc-2019
diff --git a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
index 47450c9146..1da6e25511 100644
--- a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qpainterpath.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainterpath Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainterpath LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpainterpath
SOURCES
tst_qpainterpath.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 12a8fff33b..c00dc3a78a 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
@@ -106,6 +81,8 @@ private slots:
void intersectionEquality();
void intersectionPointOnEdge();
+
+ void boundsAtStartPoint();
};
void tst_QPainterPath::cleanupTestCase()
@@ -173,8 +150,18 @@ void tst_QPainterPath::clear()
p1.setFillRule(Qt::WindingFill);
QVERIFY(p1 != p3);
p1.clear();
- QCOMPARE(p1.fillRule(), Qt::OddEvenFill);
+ QVERIFY(p1 != p3);
+ p1.setFillRule(Qt::OddEvenFill);
QCOMPARE(p1, p2);
+
+ QPainterPath p4;
+ QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
+ p4.setFillRule(Qt::WindingFill);
+ QCOMPARE(p4.fillRule(), Qt::WindingFill);
+ p4.clear();
+ QCOMPARE(p4.fillRule(), Qt::WindingFill);
+ p4 = QPainterPath();
+ QCOMPARE(p4.fillRule(), Qt::OddEvenFill);
}
void tst_QPainterPath::reserveAndCapacity()
@@ -400,11 +387,11 @@ void tst_QPainterPath::contains_QRectF_data()
QTest::newRow("inside 2 rects (winding)") << path << QRectF(51, 51, 48, 48) << true;
path.addEllipse(0, 0, 150, 150);
- QTest::newRow("topRight 2 rects") << path << QRectF(100, 25, 24, 24) << true;
- QTest::newRow("bottomLeft 2 rects") << path << QRectF(25, 100, 24, 24) << true;
+ QTest::newRow("topRight rects+circle") << path << QRectF(100, 25, 24, 24) << true;
+ QTest::newRow("bottomLeft rects+circle") << path << QRectF(25, 100, 24, 24) << true;
path.setFillRule(Qt::OddEvenFill);
- QTest::newRow("inside 2 rects") << path << QRectF(50, 50, 49, 49) << false;
+ QTest::newRow("inside rects+circle") << path << QRectF(50, 50, 49, 49) << false;
}
void tst_QPainterPath::contains_QRectF()
@@ -778,6 +765,21 @@ void tst_QPainterPath::testOperatorDatastream()
}
QCOMPARE(other, path);
+
+ // Check reset & detach
+ QPainterPath p3;
+ p3.lineTo(1, 1);
+ QCOMPARE(p3.elementCount(), 2);
+ QPainterPath p4 = p3;
+ QCOMPARE(p4.elementCount(), 2);
+ {
+ QFile data(tempDir.path() + "/data");
+ QVERIFY(data.open(QFile::ReadOnly));
+ QDataStream stream(&data);
+ stream >> p3;
+ }
+ QCOMPARE(p3.elementCount(), path.elementCount());
+ QCOMPARE(p4.elementCount(), 2);
}
void tst_QPainterPath::closing()
@@ -908,17 +910,17 @@ void tst_QPainterPath::testArcMoveTo_data()
QRectF(100, 100, 100, -100),
QRectF(100, 100, -100, -100),
};
+ constexpr qreal tinyAngle = 1e-10;
- for (uint domain = 0; domain < sizeof rects / sizeof *rects; ++domain) {
- const QByteArray dB = QByteArray::number(domain);
- for (int i=-360; i<=360; ++i) {
- QTest::newRow(("test " + dB + ' ' + QByteArray::number(i)).constData())
- << rects[domain] << (qreal) i;
- }
+ int index = 0;
+ for (const auto &rect : rects) {
+ for (int i = -360; i <= 360; ++i)
+ QTest::addRow("test %d %d", index, i) << rect << qreal(i);
// test low angles
- QTest::newRow("low angles 1") << rects[domain] << (qreal) 1e-10;
- QTest::newRow("low angles 2") << rects[domain] << (qreal)-1e-10;
+ QTest::addRow("low +angle %d", index) << rect << tinyAngle;
+ QTest::addRow("low -angle %d", index) << rect << -tinyAngle;
+ ++index;
}
}
@@ -1235,38 +1237,65 @@ void tst_QPainterPath::testNaNandInfinites()
QPointF p3 = QPointF(qQNaN(), 1);
QPointF pInf = QPointF(qInf(), 1);
- // all these operations with NaN/Inf should be ignored
- // can't test operator>> reliably, as we can't create a path with NaN to << later
+ // All these operations with NaN/Inf should be ignored.
+ // Can't test operator>> reliably, as we can't create a path with NaN to << later.
+#ifdef QT_NO_DEBUG
+# define WARNS(name)
+#else
+# define WARNS(name) \
+ QTest::ignoreMessage(QtWarningMsg, "QPainterPath::" #name ": " \
+ "Adding point with invalid coordinates, ignoring call")
+#endif
+ WARNS(moveTo);
path1.moveTo(p1);
+ WARNS(moveTo);
path1.moveTo(qSNaN(), qQNaN());
+ WARNS(moveTo);
path1.moveTo(pInf);
+ WARNS(lineTo);
path1.lineTo(p1);
+ WARNS(lineTo);
path1.lineTo(qSNaN(), qQNaN());
+ WARNS(lineTo);
path1.lineTo(pInf);
+ WARNS(cubicTo);
path1.cubicTo(p1, p2, p3);
+ WARNS(cubicTo);
path1.cubicTo(p1, QPointF(1, 1), QPointF(2, 2));
+ WARNS(cubicTo);
path1.cubicTo(pInf, QPointF(10, 10), QPointF(5, 1));
+ WARNS(quadTo);
path1.quadTo(p1, p2);
+ WARNS(quadTo);
path1.quadTo(QPointF(1, 1), p3);
+ WARNS(quadTo);
path1.quadTo(QPointF(1, 1), pInf);
+ WARNS(arcTo);
path1.arcTo(QRectF(p1, p2), 5, 5);
+ WARNS(arcTo);
path1.arcTo(QRectF(pInf, QPointF(1, 1)), 5, 5);
+ WARNS(addRect);
path1.addRect(QRectF(p1, p2));
+ WARNS(addRect);
path1.addRect(QRectF(pInf, QPointF(1, 1)));
+ WARNS(addEllipse);
path1.addEllipse(QRectF(p1, p2));
+ WARNS(addEllipse);
path1.addEllipse(QRectF(pInf, QPointF(1, 1)));
+#undef WARNS
+
QCOMPARE(path1, path2);
path1.lineTo(QPointF(1, 1));
- QVERIFY(path1 != path2);
+ QCOMPARE_NE(path1, path2);
}
#endif // signaling_nan
@@ -1430,6 +1459,32 @@ void tst_QPainterPath::intersectionPointOnEdge()
QVERIFY(p.intersects(r));
}
+void tst_QPainterPath::boundsAtStartPoint()
+{
+ const QPointF startPoint(10, 10);
+ const QPainterPath constructedPath(startPoint);
+ {
+ const auto boundingRect = constructedPath.boundingRect();
+ const auto topLeft = boundingRect.topLeft();
+ QCOMPARE(topLeft, startPoint);
+ QCOMPARE(topLeft, constructedPath.elementAt(0));
+ QCOMPARE(boundingRect, constructedPath.controlPointRect());
+ }
+
+ QPainterPath defaultPath;
+ defaultPath.moveTo(startPoint);
+ {
+ const auto boundingRect = defaultPath.boundingRect();
+ const auto topLeft = boundingRect.topLeft();
+ QCOMPARE(topLeft, startPoint);
+ QCOMPARE(topLeft, defaultPath.elementAt(0));
+ QCOMPARE(boundingRect, defaultPath.controlPointRect());
+ }
+
+ QCOMPARE(constructedPath.boundingRect(), defaultPath.boundingRect());
+ QCOMPARE(constructedPath.controlPointRect(), defaultPath.controlPointRect());
+}
+
QTEST_APPLESS_MAIN(tst_QPainterPath)
#include "tst_qpainterpath.moc"
diff --git a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
index f4c301c42e..d30778de3f 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qpainterpathstroker.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainterpathstroker Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainterpathstroker LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpainterpathstroker
SOURCES
tst_qpainterpathstroker.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
index de3f612b10..ce80019273 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
+++ b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
diff --git a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
index 191b1b8a93..2cf25cfdf2 100644
--- a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
@@ -1,4 +1,11 @@
-# Generated from qpathclipper.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpathclipper LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT QT_FEATURE_private_tests)
return()
@@ -14,18 +21,15 @@ qt_internal_add_test(tst_qpathclipper
tst_qpathclipper.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
-#### Keys ignored in scope 1:.:.:qpathclipper.pro:<TRUE>:
-# _REQUIREMENTS = "qtConfig(private_tests)"
-
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qpathclipper CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qpathclipper/pathcompare.h b/tests/auto/gui/painting/qpathclipper/pathcompare.h
index 4f855194a4..593176686e 100644
--- a/tests/auto/gui/painting/qpathclipper/pathcompare.h
+++ b/tests/auto/gui/painting/qpathclipper/pathcompare.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#ifndef PATHCOMPARE_H
#define PATHCOMPARE_H
diff --git a/tests/auto/gui/painting/qpathclipper/paths.cpp b/tests/auto/gui/painting/qpathclipper/paths.cpp
index a814958394..7b1486152b 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.cpp
+++ b/tests/auto/gui/painting/qpathclipper/paths.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include "paths.h"
QPainterPath Paths::rect()
diff --git a/tests/auto/gui/painting/qpathclipper/paths.h b/tests/auto/gui/painting/qpathclipper/paths.h
index 61daa0c3a4..73b41d324a 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.h
+++ b/tests/auto/gui/painting/qpathclipper/paths.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#ifndef PATHS_H
#define PATHS_H
diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
index 83a8d6bd47..c5ef8373fd 100644
--- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
+++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include "private/qpathclipper_p.h"
#include "paths.h"
#include "pathcompare.h"
@@ -495,15 +470,19 @@ void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::O
break;
}
- if (expected != inResult) {
- char str[256];
- const char *opStr =
- op == QPathClipper::BoolAnd ? "and" :
- op == QPathClipper::BoolOr ? "or" : "sub";
- sprintf(str, "Expected: %d, actual: %d, subject: %d, clip: %d, op: %s\n",
- int(expected), int(inResult), subjectIndex, clipIndex, opStr);
- QFAIL(str);
- }
+ auto failLogger = qScopeGuard([&]{
+ qCritical().noquote().nospace()
+ << "\n\tExpected: " << expected
+ << "\n\tActual: " << inResult
+ << "\n\tSubject: " << subjectIndex
+ << "\n\tClip: " << clipIndex
+ << "\n\tOp: " << (op == QPathClipper::BoolAnd
+ ? "and"
+ : op == QPathClipper::BoolOr
+ ? "or" : "sub");
+ });
+ QCOMPARE(inResult, expected);
+ failLogger.dismiss();
}
}
@@ -797,7 +776,7 @@ void tst_QPathClipper::testIntersections7()
void tst_QPathClipper::testIntersections8()
{
QPainterPath path1 = Paths::node() * QTransform().translate(100, 50);
- QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);;
+ QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
@@ -845,7 +824,7 @@ void tst_QPathClipper::testIntersections9()
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
- path1 = QPainterPath();;
+ path1 = QPainterPath();
path2 = QPainterPath();
path1.addRect(QRectF(-1,191, 136, 106));
@@ -853,7 +832,7 @@ void tst_QPathClipper::testIntersections9()
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
- path1 = QPainterPath();;
+ path1 = QPainterPath();
path2 = QPainterPath();
path1.moveTo(-1 , 143);
diff --git a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
index c6eb5b1034..3a42d81600 100644
--- a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
@@ -1,15 +1,22 @@
-# Generated from qpdfwriter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpdfwriter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpdfwriter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpdfwriter
SOURCES
tst_qpdfwriter.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index c74baf0ba4..4d6b1f01b9 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
#include <QtGlobal>
diff --git a/tests/auto/gui/painting/qpen/CMakeLists.txt b/tests/auto/gui/painting/qpen/CMakeLists.txt
index 321c40fa8f..05fbbfb552 100644
--- a/tests/auto/gui/painting/qpen/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpen/CMakeLists.txt
@@ -1,12 +1,19 @@
-# Generated from qpen.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpen Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpen LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpen
SOURCES
tst_qpen.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 64c01a81b5..b3ff1c76f9 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
diff --git a/tests/auto/gui/painting/qpolygon/CMakeLists.txt b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
index a61529d397..42b108efcd 100644
--- a/tests/auto/gui/painting/qpolygon/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qpolygon.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpolygon Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpolygon LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpolygon
SOURCES
tst_qpolygon.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
@@ -15,6 +22,6 @@ qt_internal_add_test(tst_qpolygon
#####################################################################
qt_internal_extend_target(tst_qpolygon CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
index 4cde0aa549..cd24135ac6 100644
--- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
@@ -41,6 +16,7 @@ class tst_QPolygon : public QObject
private slots:
void constructors();
+ void toPolygonF();
void boundingRect_data();
void boundingRect();
void boundingRectF_data();
@@ -80,6 +56,17 @@ void tst_QPolygon::constructors()
constructors_helperF(QRectF(1, 2, 3, 4));
}
+void tst_QPolygon::toPolygonF()
+{
+ const QPolygon p = {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}};
+ auto pf = p.toPolygonF();
+ static_assert(std::is_same_v<decltype(pf), QPolygonF>);
+ QCOMPARE(pf.size(), p.size());
+ auto p2 = pf.toPolygon();
+ static_assert(std::is_same_v<decltype(p2), QPolygon>);
+ QCOMPARE(p, p2);
+}
+
void tst_QPolygon::boundingRect_data()
{
QTest::addColumn<QPolygon>("poly");
@@ -181,8 +168,8 @@ void tst_QPolygon::swap()
QPolygon p2(QList<QPoint>() << QPoint(0, 0) << QPoint(0, 10) << QPoint(10, 10)
<< QPoint(10, 0));
p1.swap(p2);
- QCOMPARE(p1.count(),4);
- QCOMPARE(p2.count(),3);
+ QCOMPARE(p1.size(),4);
+ QCOMPARE(p2.size(),3);
}
void tst_QPolygon::intersections_data()
diff --git a/tests/auto/gui/painting/qregion/CMakeLists.txt b/tests/auto/gui/painting/qregion/CMakeLists.txt
index 9564e0719e..ba580438cd 100644
--- a/tests/auto/gui/painting/qregion/CMakeLists.txt
+++ b/tests/auto/gui/painting/qregion/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qregion.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qregion Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qregion LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qregion
SOURCES
tst_qregion.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 29179c44a0..3d60e62fc1 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>
diff --git a/tests/auto/gui/painting/qtransform/CMakeLists.txt b/tests/auto/gui/painting/qtransform/CMakeLists.txt
index 4d50e2cf33..557e5fa742 100644
--- a/tests/auto/gui/painting/qtransform/CMakeLists.txt
+++ b/tests/auto/gui/painting/qtransform/CMakeLists.txt
@@ -1,13 +1,20 @@
-# Generated from qtransform.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtransform Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtransform LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtransform
SOURCES
tst_qtransform.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
@@ -15,6 +22,6 @@ qt_internal_add_test(tst_qtransform
#####################################################################
qt_internal_extend_target(tst_qtransform CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
index 1bab7200f0..428174bfc6 100644
--- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
+++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** 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
#include <QTest>