diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-08-28 13:12:32 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-28 15:59:00 +0200 |
commit | a6277bb84d208279abb600f9eae801b3aacecc4c (patch) | |
tree | 86889fa33e8fb234be8eb7194d321706b627cf24 /tests | |
parent | cc878137fcf984eb1d6ecec74d4b807e49874d8b (diff) |
Test metatype registration errors with non-metatypes.
QList<QPoint> is to become automatically registered
with https://codereview.qt-project.org/#change,32897
and https://codereview.qt-project.org/#change,33031
Change-Id: I455028e226c15e922162bae21db7e5e9de07063b
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.h | 14 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 10 |
3 files changed, 22 insertions, 12 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml index 12a76d7e7d..dd110d20ee 100644 --- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml @@ -10,12 +10,12 @@ Item { objectName: "msco" } - property int pointListLength: 0 - property variant pointList + property int typeListLength: 0 + property variant typeList function performTest() { - // we have NOT registered QList<QPoint> as a type - pointListLength = msco.pointListProperty.length; - pointList = msco.pointListProperty; + // we have NOT registered QList<NonRegisteredType> as a type + typeListLength = msco.typeListProperty.length; + typeList = msco.typeListProperty; } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index a4983f13db..a4615c5f52 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -707,6 +707,11 @@ public: Q_INVOKABLE inline void method_overload(); }; +struct NonRegisteredType +{ + +}; + class MyInvokableObject : public MyInvokableBaseObject { Q_OBJECT @@ -759,7 +764,7 @@ public: Q_INVOKABLE void method_overload(const QJsonArray &a) { invoke(26); m_actuals << QVariant::fromValue(a); } Q_INVOKABLE void method_overload(const QJsonValue &a) { invoke(27); m_actuals << QVariant::fromValue(a); } - Q_INVOKABLE void method_unknown(MyInvokableObject *) { invoke(28); } + Q_INVOKABLE void method_unknown(NonRegisteredType) { invoke(28); } private: friend class MyInvokableBaseObject; @@ -1352,6 +1357,7 @@ class MySequenceConversionObject : public QObject Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged) Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged) + Q_PROPERTY (QList<NonRegisteredType> typeListProperty READ typeListProperty WRITE setTypeListProperty NOTIFY typeListPropertyChanged) Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged) Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT) @@ -1406,6 +1412,8 @@ public: void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); } QList<QPoint> pointListProperty() const { return m_pointList; } void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); } + QList<NonRegisteredType> typeListProperty() const { return m_typeList; } + void setTypeListProperty(const QList<NonRegisteredType> &list) { m_typeList = list; emit typeListPropertyChanged(); } QList<QVariant> variantListProperty() const { return m_variantList; } void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); } @@ -1431,6 +1439,7 @@ signals: void urlListPropertyChanged(); void qstringListPropertyChanged(); void pointListPropertyChanged(); + void typeListPropertyChanged(); void variantListPropertyChanged(); private: @@ -1442,7 +1451,8 @@ private: QList<QUrl> m_urlList; QStringList m_qstringList; - QList<QPoint> m_pointList; // not a supported sequence type + QList<QPoint> m_pointList; + QList<NonRegisteredType> m_typeList; // not a supported sequence type QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded. }; diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 4c5fb6f123..96c0ec1080 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -5382,19 +5382,19 @@ void tst_qqmlecmascript::sequenceConversionRead() MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco"); QVERIFY(seq != 0); - // we haven't registered QList<QPoint> as a sequence type. - QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'"); + // we haven't registered QList<NonRegisteredType> as a sequence type. + QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'"); QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined"); QTest::ignoreMessage(QtWarningMsg, warningOne.toLatin1().constData()); QTest::ignoreMessage(QtWarningMsg, warningTwo.toLatin1().constData()); QMetaObject::invokeMethod(object, "performTest"); - // QList<QPoint> has not been registered as a sequence type. + // QList<NonRegisteredType> has not been registered as a sequence type. QCOMPARE(object->property("pointListLength").toInt(), 0); QVERIFY(!object->property("pointList").isValid()); - QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'"); - QQmlProperty seqProp(seq, "pointListProperty", &engine); + QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'"); + QQmlProperty seqProp(seq, "typeListProperty", &engine); QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type delete object; |