From 036aa822455b4d831076a1ba364fa1ef304dee84 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 29 May 2018 13:55:38 +0200 Subject: Show error message when type qmlRegisterType and friends fail When a type is registered through qmlRegisterType or similar functions, no error was shown. Task-number: QTBUG-68323 Change-Id: Iff44bf8744c67dba2fdd12c43aaee44a8e15364a Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 1d0d353668..e83dac48fb 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -227,17 +227,13 @@ void tst_qqmlmetatype::qmlType() void tst_qqmlmetatype::invalidQmlTypeName() { - QStringList currFailures = QQmlMetaType::typeRegistrationFailures(); + QTest::ignoreMessage(QtWarningMsg, "Invalid QML element name \"testtype\"; type names must begin with an uppercase letter"); + QTest::ignoreMessage(QtWarningMsg, "Invalid QML element name \"Test$Type\""); + QTest::ignoreMessage(QtWarningMsg, "Invalid QML element name \"EndingInSlash/\""); + QCOMPARE(qmlRegisterType("TestNamespace", 1, 0, "Test$Type"), -1); // should fail due to invalid QML type name. QCOMPARE(qmlRegisterType("Test", 1, 0, "EndingInSlash/"), -1); - QStringList nowFailures = QQmlMetaType::typeRegistrationFailures(); - - foreach (const QString &f, currFailures) - nowFailures.removeOne(f); - - QCOMPARE(nowFailures.size(), 2); - QCOMPARE(nowFailures.at(0), QStringLiteral("Invalid QML element name \"Test$Type\"")); - QCOMPARE(nowFailures.at(1), QStringLiteral("Invalid QML element name \"EndingInSlash/\"")); + QCOMPARE(qmlRegisterType("Test", 1, 0, "testtype"), -1); } void tst_qqmlmetatype::prettyTypeName() -- cgit v1.2.3