summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2017-09-29 15:55:03 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2017-10-04 11:35:02 +0000
commitcd7d2dc5481f7954da7ebec27b86adda2602c5b7 (patch)
treee9c860665c85f2730bc0cda2285231325464f549
parent1e2914d4537eb5acaede9b81d6edac12e99e4b1f (diff)
downloadqtscript-cd7d2dc5481f7954da7ebec27b86adda2602c5b7.tar.gz
Fix test checking QVector<int> 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<int> wasn't registered yet. Use a custom type for this check instead. Task-number: QTBUG-63432 Change-Id: Ib6a405a6bcb2ee2c294b3260b89c567712c49a63 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp18
1 files 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<int> myInvokableReturningVectorOfInt()
- { m_qtFunctionInvoked = 11; return QVector<int>(); }
- Q_INVOKABLE void myInvokableWithVectorOfIntArg(const QVector<int> &)
+ Q_INVOKABLE QVector<CustomType> myInvokableReturningVectorOfCustomType()
+ { m_qtFunctionInvoked = 11; return QVector<CustomType>(); }
+ Q_INVOKABLE void myInvokableWithVectorOfCustomTypeArg(const QVector<CustomType> &)
{ 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<CustomType>"), 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<QVector<int> >(m_engine);
+ qScriptRegisterSequenceMetaType<QVector<CustomType> >(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<QVector<CustomType> >(m_engine);
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithVectorOfCustomTypeArg(myObject.myInvokableReturningVectorOfCustomType())");
QCOMPARE(ret.isUndefined(), true);
QCOMPARE(m_myObject->qtFunctionInvoked(), 12);
}