summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-26 12:14:02 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-05-28 23:33:37 +0000
commitcb34e4361dcf7effb3b8e917df7e68b7fdd255b7 (patch)
tree62c2d6b6e6d8ac7a48b53ee68a930877223ce9d6 /tests
parent6e695c0fb6b1f4cd28ef7bea615a8621fd76a168 (diff)
Fix ExtendedRgb and Rgb encoding comparisons
ExtendedRgb should be treated as Rgb as it can be an automatic upgrade. Change-Id: I2942a1067ed5cacb2f60f303f467887cb44c36dd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit d80a98d52548b1081ba3f980252fe9aee89bc1f8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 07c820dc86..31221bc8fd 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -106,6 +106,8 @@ private slots:
void achromaticHslHue();
+ void equality();
+
void premultiply();
void unpremultiply_sse4();
void qrgba64();
@@ -1645,6 +1647,24 @@ void tst_QColor::achromaticHslHue()
QCOMPARE(hsl.hslHue(), -1);
}
+void tst_QColor::equality()
+{
+ QColor red = Qt::red;
+ QColor black = Qt::black;
+
+ QCOMPARE(red, red);
+ QCOMPARE(black, black);
+ QVERIFY(red != black);
+
+ // Encodings must match
+ QVERIFY(red != red.toHsv());
+ QVERIFY(black.toHsl() != black);
+
+ // Except for ExtendedRgb and Rgb, as it can be an automatic upgrade.
+ QCOMPARE(red, red.toExtendedRgb());
+ QCOMPARE(black.toExtendedRgb(), black);
+}
+
void tst_QColor::premultiply()
{
// Tests that qPremultiply(qUnpremultiply(x)) returns x.