DBus tests: port away from deprecated APIs

Replacing QVariant::Type with QMetaType::Type

Task-number: QTBUG-104858
Change-Id: If03e2ad72b46c33f68f4382c7ed5c5801d2e70b2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ivan Solovev 2022-08-17 15:52:22 +02:00
parent e5c184ecd1
commit 373c7fe17e
5 changed files with 38 additions and 38 deletions

View File

@ -868,7 +868,7 @@ void tst_QDBusAbstractAdaptor::readProperties()
properties.call(QDBus::BlockWithGui, "Get", "local." + name, propname);
QVariant value = reply;
QCOMPARE(value.userType(), int(QVariant::String));
QCOMPARE(value.userType(), int(QMetaType::QString));
QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
}
}
@ -957,7 +957,7 @@ void tst_QDBusAbstractAdaptor::readAllProperties()
qPrintable(propname + " on " + name));
QVariant value = reply.value().value(propname);
QCOMPARE(value.userType(), int(QVariant::String));
QCOMPARE(value.userType(), int(QMetaType::QString));
QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
}
}
@ -1405,7 +1405,7 @@ void tst_QDBusAbstractAdaptor::readPropertiesPeer()
properties.call(QDBus::BlockWithGui, "Get", "local." + name, propname);
QVariant value = reply;
QCOMPARE(value.userType(), int(QVariant::String));
QCOMPARE(value.userType(), int(QMetaType::QString));
QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
}
}
@ -1484,7 +1484,7 @@ void tst_QDBusAbstractAdaptor::readAllPropertiesPeer()
qPrintable(propname + " on " + name));
QVariant value = reply.value().value(propname);
QCOMPARE(value.userType(), int(QVariant::String));
QCOMPARE(value.userType(), int(QMetaType::QString));
QCOMPARE(value.toString(), QString("QString %1::%2() const").arg(name, propname));
}
}
@ -1864,7 +1864,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValue()
QVERIFY(intreply.isValid());
QCOMPARE(intreply.value(), 42);
QCOMPARE(reply.arguments().at(1).userType(), int(QVariant::String));
QCOMPARE(reply.arguments().at(1).userType(), int(QMetaType::QString));
QCOMPARE(qdbus_cast<QString>(reply.arguments().at(1)), testString);
}
@ -1887,7 +1887,7 @@ void tst_QDBusAbstractAdaptor::methodWithMoreThanOneReturnValuePeer()
QVERIFY(intreply.isValid());
QCOMPARE(intreply.value(), 42);
QCOMPARE(reply.arguments().at(1).userType(), int(QVariant::String));
QCOMPARE(reply.arguments().at(1).userType(), int(QMetaType::QString));
QCOMPARE(qdbus_cast<QString>(reply.arguments().at(1)), testString);
}

View File

@ -864,7 +864,7 @@ void tst_QDBusAbstractInterface::getStringSignal()
QCOMPARE(s.size(), 1);
QCOMPARE(s[0].size(), 1);
QCOMPARE(s[0][0].userType(), int(QVariant::String));
QCOMPARE(s[0][0].userType(), int(QMetaType::QString));
QCOMPARE(s[0][0].toString(), expectedValue);
}
@ -946,7 +946,7 @@ void tst_QDBusAbstractInterface::getStringSignalPeer()
QCOMPARE(s.size(), 1);
QCOMPARE(s[0].size(), 1);
QCOMPARE(s[0][0].userType(), int(QVariant::String));
QCOMPARE(s[0][0].userType(), int(QMetaType::QString));
QCOMPARE(s[0][0].toString(), expectedValue);
}

View File

@ -1009,7 +1009,7 @@ void tst_QDBusInterface::propertyRead()
QVariant v = iface.property("prop1");
QVERIFY(v.isValid());
QCOMPARE(v.userType(), int(QVariant::Int));
QCOMPARE(v.userType(), int(QMetaType::Int));
QCOMPARE(v.toInt(), arg);
QCOMPARE(MyObject::callCount, 1);
}
@ -1072,7 +1072,7 @@ void tst_QDBusInterface::propertyReadPeer()
QVariant v = iface.property("prop1");
QVERIFY(v.isValid());
QCOMPARE(v.userType(), int(QVariant::Int));
QCOMPARE(v.userType(), int(QMetaType::Int));
QCOMPARE(v.toInt(), arg);
QCOMPARE(callCountPeer(), 1);
}

View File

@ -377,7 +377,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
// try to demarshall the arg according to v2
switch (v2.userType())
{
case QVariant::Bool:
case QMetaType::Bool:
return compare<bool>(arg, v2);
case QMetaType::UChar:
return compare<uchar>(arg, v2);
@ -385,45 +385,45 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2)
return compare<short>(arg, v2);
case QMetaType::UShort:
return compare<ushort>(arg, v2);
case QVariant::Int:
case QMetaType::Int:
return compare<int>(arg, v2);
case QVariant::UInt:
case QMetaType::UInt:
return compare<uint>(arg, v2);
case QVariant::LongLong:
case QMetaType::LongLong:
return compare<qlonglong>(arg, v2);
case QVariant::ULongLong:
case QMetaType::ULongLong:
return compare<qulonglong>(arg, v2);
case QVariant::Double:
case QMetaType::Double:
return compare<double>(arg, v2);
case QVariant::String:
case QMetaType::QString:
return compare<QString>(arg, v2);
case QVariant::ByteArray:
case QMetaType::QByteArray:
return compare<QByteArray>(arg, v2);
case QVariant::List:
case QMetaType::QVariantList:
return compare<QVariantList>(arg, v2);
case QVariant::Map:
case QMetaType::QVariantMap:
return compare<QVariantMap>(arg, v2);
case QVariant::Point:
case QMetaType::QPoint:
return compare<QPoint>(arg, v2);
case QVariant::PointF:
case QMetaType::QPointF:
return compare<QPointF>(arg, v2);
case QVariant::Size:
case QMetaType::QSize:
return compare<QSize>(arg, v2);
case QVariant::SizeF:
case QMetaType::QSizeF:
return compare<QSizeF>(arg, v2);
case QVariant::Line:
case QMetaType::QLine:
return compare<QLine>(arg, v2);
case QVariant::LineF:
case QMetaType::QLineF:
return compare<QLineF>(arg, v2);
case QVariant::Rect:
case QMetaType::QRect:
return compare<QRect>(arg, v2);
case QVariant::RectF:
case QMetaType::QRectF:
return compare<QRectF>(arg, v2);
case QVariant::Date:
case QMetaType::QDate:
return compare<QDate>(arg, v2);
case QVariant::Time:
case QMetaType::QTime:
return compare<QTime>(arg, v2);
case QVariant::DateTime:
case QMetaType::QDateTime:
return compare<QDateTime>(arg, v2);
default:
int id = v2.userType();
@ -524,16 +524,16 @@ template<> bool compare(const QVariant &v1, const QVariant &v2)
return false;
int id = v1.userType();
if (id == QVariant::List)
if (id == QMetaType::QVariantList)
return compare(v1.toList(), v2.toList());
else if (id == QVariant::Map)
else if (id == QMetaType::QVariantMap)
return compare(v1.toMap(), v2.toMap());
else if (id == QVariant::String)
else if (id == QMetaType::QString)
return compare(v1.toString(), v2.toString());
else if (id == QVariant::ByteArray)
else if (id == QMetaType::QByteArray)
return compare(v1.toByteArray(), v2.toByteArray());
else if (id == QMetaType::UChar)
@ -638,7 +638,7 @@ template<> bool compare(const QVariant &v1, const QVariant &v2)
else if (id == qMetaTypeId<MyStruct>()) // (is)
return qvariant_cast<MyStruct>(v1) == qvariant_cast<MyStruct>(v2);
else if (id < int(QVariant::UserType)) // yes, v1.type()
else if (id < int(QMetaType::User)) // yes, v1.type()
// QVariant can compare
return v1 == v2;

View File

@ -713,14 +713,14 @@ void tst_QDBusMarshall::sendArgument_data()
<< QVariant::fromValue(QVariant::fromValue(QDBusVariant(1)));
arg = QDBusArgument();
arg.beginArray(QVariant::Int);
arg.beginArray(QMetaType::Int);
arg << 1 << 2 << 3 << -4;
arg.endArray();
QTest::newRow("array-of-int") << QVariant::fromValue(arg) << "ai" << int(QDBusArgument::ArrayType)
<< QVariant::fromValue(arg);
arg = QDBusArgument();
arg.beginMap(QVariant::Int, QVariant::UInt);
arg.beginMap(QMetaType::Int, QMetaType::UInt);
arg.beginMapEntry();
arg << 1 << 2U;
arg.endMapEntry();