From cd7d2dc5481f7954da7ebec27b86adda2602c5b7 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 29 Sep 2017 15:55:03 +0200 Subject: Fix test checking QVector not being registered In qtbase 2b1ab81edaf19042d11b4ac1836f527c8590ee45 the basic types registered by DBus got extended to QVector, in addition to QList. This broke the assumption in the QObject test that QVector wasn't registered yet. Use a custom type for this check instead. Task-number: QTBUG-63432 Change-Id: Ib6a405a6bcb2ee2c294b3260b89c567712c49a63 Reviewed-by: Richard Moe Gustavsen --- tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 6aef3b4..edc6ad1 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -269,9 +269,9 @@ public: { m_qtFunctionInvoked = 37; return BazPolicy; } Q_INVOKABLE MyQObject::Strategy myInvokableReturningQualifiedEnum() { m_qtFunctionInvoked = 38; return BazStrategy; } - Q_INVOKABLE QVector myInvokableReturningVectorOfInt() - { m_qtFunctionInvoked = 11; return QVector(); } - Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector &) + Q_INVOKABLE QVector myInvokableReturningVectorOfCustomType() + { m_qtFunctionInvoked = 11; return QVector(); } + Q_INVOKABLE void myInvokableWithVectorOfCustomTypeArg(const QVector &) { m_qtFunctionInvoked = 12; } Q_INVOKABLE QObject *myInvokableReturningQObjectStar() { m_qtFunctionInvoked = 13; return this; } @@ -1359,16 +1359,17 @@ void tst_QScriptExtQObject::callQtInvokable2() // first time we expect failure because the metatype is not registered m_myObject->resetQtFunctionInvoked(); - QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()").isError(), true); + QCOMPARE(QMetaType::type("QVector"), QMetaType::UnknownType); // this type should not be registered yet + QCOMPARE(m_engine->evaluate("myObject.myInvokableReturningVectorOfCustomType()").isError(), true); QCOMPARE(m_myObject->qtFunctionInvoked(), -1); - QCOMPARE(m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(0)").isError(), true); + QCOMPARE(m_engine->evaluate("myObject.myInvokableWithVectorOfCustomTypeArg(CustomType())").isError(), true); QCOMPARE(m_myObject->qtFunctionInvoked(), -1); // now we register it, and it should work - qScriptRegisterSequenceMetaType >(m_engine); + qScriptRegisterSequenceMetaType >(m_engine); { - QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningVectorOfInt()"); + QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningVectorOfCustomType()"); QCOMPARE(ret.isArray(), true); QCOMPARE(m_myObject->qtFunctionInvoked(), 11); } @@ -1377,7 +1378,8 @@ void tst_QScriptExtQObject::callQtInvokable2() void tst_QScriptExtQObject::callQtInvokable3() { { - QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVectorOfIntArg(myObject.myInvokableReturningVectorOfInt())"); + qScriptRegisterSequenceMetaType >(m_engine); + QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVectorOfCustomTypeArg(myObject.myInvokableReturningVectorOfCustomType())"); QCOMPARE(ret.isUndefined(), true); QCOMPARE(m_myObject->qtFunctionInvoked(), 12); } -- cgit v1.2.1