summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-07-18 22:27:17 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-07-26 14:33:21 -0700
commit51905f8e7638e997653c3fc10b97a66fe305edf9 (patch)
tree5bf06964c5458358f655b2cedf4355ed9f102736 /tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
parentaae882b02f346740f5a6b6d8b4d2bcf7f90bdc09 (diff)
tst_QMetaType: suppress most warnings
It's not warning-free, but it's much better. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323c9ed12dd23 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 67d92d15fa..facd9992b9 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -564,6 +564,17 @@ namespace enumerations {
enum Test { a = 0 };
}
+static void ignoreInvalidMetaTypeWarning(int typeId)
+{
+ if (typeId < 0 || typeId > QMetaType::User + 500 ||
+ (typeId > QMetaType::LastCoreType && typeId < QMetaType::FirstGuiType) ||
+ (typeId > QMetaType::LastGuiType && typeId < QMetaType::FirstWidgetsType) ||
+ (typeId > QMetaType::LastWidgetsType && typeId < QMetaType::User)) {
+ QTest::ignoreMessage(QtWarningMsg, "Trying to construct an instance of an invalid type, type id: "
+ + QByteArray::number(typeId));
+ }
+}
+
void tst_QMetaType::typeName_data()
{
QTest::addColumn<int>("aType");
@@ -612,6 +623,7 @@ void tst_QMetaType::typeName()
if (aType >= QMetaType::FirstWidgetsType)
QSKIP("The test doesn't link against QtWidgets.");
+ ignoreInvalidMetaTypeWarning(aType);
const char *rawname = QMetaType::typeName(aType);
QString name = QString::fromLatin1(rawname);
@@ -619,6 +631,7 @@ void tst_QMetaType::typeName()
QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData()));
QCOMPARE(rawname == nullptr, aTypeName.isNull());
+ ignoreInvalidMetaTypeWarning(aType);
QMetaType mt(aType);
if (mt.isValid()) { // Gui type are not valid
QCOMPARE(QString::fromLatin1(QMetaType(aType).name()), aTypeName);
@@ -1018,6 +1031,7 @@ void tst_QMetaType::flags()
QFETCH(bool, isEnum);
QFETCH(bool, isQmlList);
+ ignoreInvalidMetaTypeWarning(type);
QMetaType meta(type);
QCOMPARE(bool(meta.flags() & QMetaType::NeedsConstruction), isComplex);
@@ -1463,7 +1477,7 @@ void tst_QMetaType::isRegistered_data()
// unknown types
QTest::newRow("-1") << -1 << false;
QTest::newRow("-42") << -42 << false;
- QTest::newRow("IsRegisteredDummyType + 1") << (dummyTypeId + 1) << false;
+ QTest::newRow("IsRegisteredDummyType + 1000") << (dummyTypeId + 1000) << false;
QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << false;
}
@@ -1516,6 +1530,7 @@ void tst_QMetaType::isRegisteredStaticLess()
{
QFETCH(int, typeId);
QFETCH(bool, registered);
+ ignoreInvalidMetaTypeWarning(typeId);
QCOMPARE(QMetaType(typeId).isRegistered(), registered);
}