From d80a98d52548b1081ba3f980252fe9aee89bc1f8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 26 May 2020 12:14:02 +0200 Subject: Fix ExtendedRgb and Rgb encoding comparisons ExtendedRgb should be treated as Rgb as it can be an automatic upgrade. Pick-to: 5.15 Change-Id: I2942a1067ed5cacb2f60f303f467887cb44c36dd Reviewed-by: Eirik Aavitsland --- tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index f8502c1e2f..5bbf60ea79 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(); @@ -1682,6 +1684,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. -- cgit v1.2.3