aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-08-14 11:44:49 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-28 04:32:48 +0200
commit70a2c0491d66aa05f9e9e67f8a845f4df84da857 (patch)
tree08d7828cfb6950926e1176ee420d5e15dedd9817 /tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
parent3912bbaceab166eb116447311eb16453e4f26edf (diff)
Refactor singleton type registration code
Previously each singleton type was registered as an implicit separate import. This commit changes the code so that these types are treated just like any other type in the registration sense. It also ensures that singleton types are instantiated per-engine. Change-Id: I5c81c4ca5bf65210f7125d74a62a282a21838068 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp')
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index 520697909a..3df18fc77f 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -59,6 +59,7 @@ private slots:
void qmlPropertyValueSourceCast();
void qmlPropertyValueInterceptorCast();
void qmlType();
+ void invalidQmlTypeName();
void isList();
@@ -188,6 +189,19 @@ void tst_qqmlmetatype::qmlType()
QCOMPARE(type->qmlTypeName(), QLatin1String("Test/ParserStatusTestType"));
}
+void tst_qqmlmetatype::invalidQmlTypeName()
+{
+ QStringList currFailures = QQmlMetaType::typeRegistrationFailures();
+ QCOMPARE(qmlRegisterType<TestType>("TestNamespace", 1, 0, "Test$Type"), -1); // should fail due to invalid QML type name.
+ QStringList nowFailures = QQmlMetaType::typeRegistrationFailures();
+
+ foreach (const QString &f, currFailures)
+ nowFailures.removeOne(f);
+
+ QCOMPARE(nowFailures.size(), 1);
+ QCOMPARE(nowFailures.at(0), QStringLiteral("Invalid QML element name \"Test$Type\""));
+}
+
void tst_qqmlmetatype::isList()
{
QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false);