aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-11 15:21:41 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-12 11:38:18 +0000
commitf783ab6049774888308e24bf6e4218a7035a4d12 (patch)
tree70328085ea8995193ae7cc15a52e29624e82bf78 /tests/auto
parentce452b70e158461b021aa47faf5cce87964b6cf7 (diff)
Fix warnings about lossy double/float conversion in tests
QColor operates on floats, not qreal or double, so explicitly use float literals in test code. Change-Id: I6f0cb56e861b4812fc79ce67ade9abe3ee9dfddc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io> (cherry picked from commit 8bb955e22f027fc3fd9402383445685cb4185744) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp8
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp38
-rw-r--r--tests/auto/qml/qqmlvaluetypeproviders/testtypes.h8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.h8
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp36
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp4
6 files changed, 51 insertions, 51 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 41fb80d8ed..f058b97605 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -905,7 +905,7 @@ void tst_qqmllanguage::assignLiteralToVar()
QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
QCOMPARE(object->property("test10"), QVariant(bool(true)));
QCOMPARE(object->property("test11"), QVariant(bool(false)));
- QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
+ QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2f, 0.3f, 0.4f, 0.5f)));
QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
@@ -1060,7 +1060,7 @@ void tst_qqmllanguage::bindJSValueToVar()
QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
QCOMPARE(object->property("test10"), QVariant(bool(true)));
QCOMPARE(object->property("test11"), QVariant(bool(false)));
- QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
+ QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2f, 0.3f, 0.4f, 0.5f)));
QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
@@ -1109,7 +1109,7 @@ void tst_qqmllanguage::bindJSValueToVariant()
QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
QCOMPARE(object->property("test10"), QVariant(bool(true)));
QCOMPARE(object->property("test11"), QVariant(bool(false)));
- QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
+ QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2f, 0.3f, 0.4f, 0.5f)));
QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
@@ -1133,7 +1133,7 @@ void tst_qqmllanguage::bindJSValueToType()
QCOMPARE(object->doubleProperty(), double(1.7));
QCOMPARE(object->stringProperty(), QString(QLatin1String("Hello world!")));
QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->colorProperty(), QColor::fromRgbF(0.2, 0.3, 0.4, 0.5));
+ QCOMPARE(object->colorProperty(), QColor::fromRgbF(0.2f, 0.3f, 0.4f, 0.5f));
QCOMPARE(object->rectFProperty(), QRectF(10, 10, 10, 10));
QCOMPARE(object->pointFProperty(), QPointF(10, 10));
QCOMPARE(object->sizeFProperty(), QSizeF(10, 10));
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 9406ba5d6a..e4f28c29fb 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -189,8 +189,8 @@ void tst_qqmlqt::rgba()
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
@@ -209,8 +209,8 @@ void tst_qqmlqt::hsla()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
@@ -229,8 +229,8 @@ void tst_qqmlqt::hsva()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHsvF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHsvF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHsvF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHsvF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHsvF(1, 1, 1, 1));
@@ -503,13 +503,13 @@ void tst_qqmlqt::lighter()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8f, 0.3f).lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QColor::fromRgbF(1, 0.8f, 0.3f).lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8f, 0.3f).lighter(180));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QColor::fromRgbF(1, 0.8f, 0.3f).lighter(180));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), QColor("red").lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
@@ -528,13 +528,13 @@ void tst_qqmlqt::darker()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8f, 0.3f).darker());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QColor::fromRgbF(1, 0.8f, 0.3f).darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8f, 0.3f).darker(280));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QColor::fromRgbF(1, 0.8f, 0.3f).darker(280));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), QColor("red").darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
@@ -554,17 +554,17 @@ void tst_qqmlqt::alpha()
QVERIFY(object != nullptr);
QCOMPARE(qvariant_cast<QColor>(object->property("test1")),
- QColor::fromRgbF(1.0, 0.8, 0.3, 0.5));
+ QColor::fromRgbF(1.0f, 0.8f, 0.3f, 0.5f));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3, 0.5));
+ QColor::fromRgbF(1, 0.8f, 0.3f, 0.5));
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test3")),
- QColor::fromRgbF(1.0, 0.8, 0.3, 0.7));
+ QColor::fromRgbF(1.0f, 0.8f, 0.3f, 0.7f));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3, 0.7));
+ QColor::fromRgbF(1, 0.8f, 0.3f, 0.7f));
QColor alphaRed = QColor("red");
- alphaRed.setAlphaF(0.5);
+ alphaRed.setAlphaF(0.5f);
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), alphaRed);
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), alphaRed);
diff --git a/tests/auto/qml/qqmlvaluetypeproviders/testtypes.h b/tests/auto/qml/qqmlvaluetypeproviders/testtypes.h
index 5241381336..8a1e3615da 100644
--- a/tests/auto/qml/qqmlvaluetypeproviders/testtypes.h
+++ b/tests/auto/qml/qqmlvaluetypeproviders/testtypes.h
@@ -95,10 +95,10 @@ public:
m_font.setCapitalization(QFont::AllLowercase);
m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
m_font.setWordSpacing(19.7);
- m_color.setRedF(0.2);
- m_color.setGreenF(0.88);
- m_color.setBlueF(0.6);
- m_color.setAlphaF(0.34);
+ m_color.setRedF(0.2f);
+ m_color.setGreenF(0.88f);
+ m_color.setBlueF(0.6f);
+ m_color.setAlphaF(0.34f);
}
QPoint m_point;
diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h
index 5b1b3ce7fd..8ea2e68260 100644
--- a/tests/auto/qml/qqmlvaluetypes/testtypes.h
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h
@@ -103,10 +103,10 @@ public:
m_font.setCapitalization(QFont::AllLowercase);
m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
m_font.setWordSpacing(19.7);
- m_color.setRedF(0.2);
- m_color.setGreenF(0.88);
- m_color.setBlueF(0.6);
- m_color.setAlphaF(0.34);
+ m_color.setRedF(0.2f);
+ m_color.setGreenF(0.88f);
+ m_color.setBlueF(0.6f);
+ m_color.setAlphaF(0.34f);
}
QPoint m_point;
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index f615060ce3..5d24e162ae 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -905,10 +905,10 @@ void tst_qqmlvaluetypes::color()
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != nullptr);
- QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
- QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
- QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
- QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
+ QCOMPARE(float(object->property("v_r").toDouble()), 0.2f);
+ QCOMPARE(float(object->property("v_g").toDouble()), 0.88f);
+ QCOMPARE(float(object->property("v_b").toDouble()), 0.6f);
+ QCOMPARE(float(object->property("v_a").toDouble()), 0.34f);
QCOMPARE(qRound(object->property("hsv_h").toDouble() * 100), 43);
QCOMPARE(qRound(object->property("hsv_s").toDouble() * 100), 77);
@@ -924,10 +924,10 @@ void tst_qqmlvaluetypes::color()
QVERIFY(!object->property("invalid").toBool());
QColor comparison;
- comparison.setRedF(0.2);
- comparison.setGreenF(0.88);
- comparison.setBlueF(0.6);
- comparison.setAlphaF(0.34);
+ comparison.setRedF(0.2f);
+ comparison.setGreenF(0.88f);
+ comparison.setBlueF(0.6f);
+ comparison.setAlphaF(0.34f);
QCOMPARE(object->property("copy"), QVariant(comparison));
delete object;
@@ -939,10 +939,10 @@ void tst_qqmlvaluetypes::color()
QVERIFY(object != nullptr);
QColor newColor;
- newColor.setRedF(0.5);
- newColor.setGreenF(0.38);
- newColor.setBlueF(0.3);
- newColor.setAlphaF(0.7);
+ newColor.setRedF(0.5f);
+ newColor.setGreenF(0.38f);
+ newColor.setBlueF(0.3f);
+ newColor.setAlphaF(0.7f);
QCOMPARE(object->color(), newColor);
delete object;
@@ -954,7 +954,7 @@ void tst_qqmlvaluetypes::color()
QVERIFY(object != nullptr);
QColor newColor;
- newColor.setHsvF(0.43, 0.77, 0.88, 0.7);
+ newColor.setHsvF(0.43f, 0.77f, 0.88f, 0.7f);
QCOMPARE(object->color(), newColor);
delete object;
@@ -966,7 +966,7 @@ void tst_qqmlvaluetypes::color()
QVERIFY(object != nullptr);
QColor newColor;
- newColor.setHslF(0.43, 0.74, 0.54, 0.7);
+ newColor.setHslF(0.43f, 0.74f, 0.54f, 0.7f);
QCOMPARE(object->color(), newColor);
delete object;
@@ -977,10 +977,10 @@ void tst_qqmlvaluetypes::color()
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != nullptr);
QColor comparison;
- comparison.setRedF(0.2);
- comparison.setGreenF(0.88);
- comparison.setBlueF(0.6);
- comparison.setAlphaF(0.34);
+ comparison.setRedF(0.2f);
+ comparison.setGreenF(0.88f);
+ comparison.setBlueF(0.6f);
+ comparison.setAlphaF(0.34f);
QString colorString = comparison.name(QColor::HexArgb);
QCOMPARE(object->property("colorToString").toString(), colorString);
QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index fe366d0f34..072fe38f80 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -217,7 +217,7 @@ void tst_qquickanimations::simpleColor()
QVERIFY(animation.isPaused());
animation.setCurrentTime(125);
QCOMPARE(animation.currentTime(), 125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039f, 0, 0.498039f, 1));
rect.setColor(QColor("green"));
animation.setFrom(QColor("blue"));
@@ -228,7 +228,7 @@ void tst_qquickanimations::simpleColor()
QCOMPARE(rect.color(), QColor("blue"));
QVERIFY(animation.isRunning());
animation.setCurrentTime(125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039f, 0, 0.498039f, 1));
}
void tst_qquickanimations::simpleRotation()