From 538f1b7dd65b1aa6133e1adb8b6d893ab366173e Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 21 Aug 2020 09:22:49 +0200 Subject: tst_qqmlenginedebugservice: Adapt to QVariant comparison change QVariant::operator== won't do the needed conversions anymore, so we have to apply them manually. In contrast to operator==, convert is not const, so we have to apply it to a copy of the variant. Change-Id: Ic55c2791038dbc9e45dcdcb163828cb7ca93a29e Reviewed-by: Fawzi Mohamed Reviewed-by: Ulf Hermann --- .../tst_qqmlenginedebugservice.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 3ae40bf687..9bef2185de 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -282,7 +282,11 @@ void tst_QQmlEngineDebugService::recursiveObjectTest( } } else if (pmeta.userType() < QMetaType::User && pmeta.userType() != QMetaType::QVariant) { const QVariant expected = pmeta.read(o); - QVERIFY2(p.value == expected, QString::fromLatin1("%1 != %2. Details: %3/%4/%5/%6") + QVariant value = p.value; + auto expectedType = expected.metaType().id(); + if (value != expected && p.value.canConvert(expectedType)) + value.convert(expectedType); + QVERIFY2(value == expected, QString::fromLatin1("%1 != %2. Details: %3/%4/%5/%6") .arg(QTest::toString(p.value)).arg(QTest::toString(expected)).arg(p.name) .arg(p.valueTypeName).arg(pmeta.userType()).arg(pmeta.userType()).toUtf8()); } @@ -774,9 +778,9 @@ void tst_QQmlEngineDebugService::queryObject() // test specific property values QCOMPARE(findProperty(rect.properties, "width").value, QVariant::fromValue(500)); QCOMPARE(findProperty(rect.properties, "height").value, QVariant::fromValue(600)); - QCOMPARE(findProperty(rect.properties, "color").value, QVariant::fromValue(QColor("blue"))); - - QCOMPARE(findProperty(text.properties, "color").value, QVariant::fromValue(QColor("blue"))); + auto expected = findProperty(rect.properties, "color").value; + expected.convert(QMetaType::fromType().id()); + QCOMPARE(expected , QVariant::fromValue(QColor("blue"))); } else { foreach (const QQmlEngineDebugObjectReference &child, obj.children) { QVERIFY(!child.className.isEmpty()); @@ -853,9 +857,11 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation() // test specific property values QCOMPARE(findProperty(rect.properties, "width").value, QVariant::fromValue(500)); QCOMPARE(findProperty(rect.properties, "height").value, QVariant::fromValue(600)); - QCOMPARE(findProperty(rect.properties, "color").value, QVariant::fromValue(QColor("blue"))); - - QCOMPARE(findProperty(text.properties, "color").value, QVariant::fromValue(QColor("blue"))); + auto expected = findProperty(rect.properties, "color").value; + auto colorMetatype = QMetaType::fromType().id(); + QVERIFY(expected.canConvert(colorMetatype)); + expected.convert(colorMetatype); + QCOMPARE(expected , QVariant::fromValue(QColor("blue"))); } else { foreach (const QQmlEngineDebugObjectReference &child, obj.children) { QVERIFY(!child.className.isEmpty()); -- cgit v1.2.3