summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-02-15 11:58:08 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-15 10:36:09 +0000
commitce83a03cfda1b1d98234e8d82f8c41eda285384e (patch)
tree89b1eb2f55cac8248a3e7f05b32fe3c186e6f653 /tests/auto/gui
parentee0908228f0e06f426c3c95d4e7fb733d9433705 (diff)
QColor: deprecate isValidColor, setNamedColor, string-ish ctors
[ChangeLog][QtGui][QColor] The constructors from string-ish type, as well as the setNamedColor() and isValidColor() functions, have been deprecated effective Qt 6.6 in favor of fromString() and isValidColorName(), resp. Fixes: QTBUG-101389 Change-Id: I002646bd48c1e4340dc6842fd136fc9f35bb9b61 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 47e684b55c..bf375e267d 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -38,6 +38,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
@@ -335,7 +341,9 @@ void tst_QColor::namehex()
{
QFETCH(QString, hexcolor);
QFETCH(QColor, color);
+ DEPRECATED_IN_6_6(
QCOMPARE(QColor(hexcolor), color);
+ )
QCOMPARE(QColor::fromString(hexcolor), color);
}
@@ -724,8 +732,10 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
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");
@@ -735,13 +745,20 @@ void tst_QColor::fromString_data()
#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);
@@ -771,21 +788,27 @@ void tst_QColor::fromString_data()
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);
}