diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-05 15:38:39 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-05 15:38:39 (GMT) |
commit | 508c9cd681244a5ad566c12733aa70f5bd522b57 (patch) | |
tree | 67a7b8fe7a530fa42f61f55aa7f2401caff64e72 /tests | |
parent | 9691523b796c6acc6a837a5f5a34fef16aa74c48 (diff) | |
download | Qt-508c9cd681244a5ad566c12733aa70f5bd522b57.zip Qt-508c9cd681244a5ad566c12733aa70f5bd522b57.tar.gz Qt-508c9cd681244a5ad566c12733aa70f5bd522b57.tar.bz2 |
make signal handlers understand QVariant again
Also, issue a warning if a type is not known to the meta-type system.
Task-number: 248129
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptqobject/tst_qscriptqobject.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp index 1025d2a..2c47c49 100644 --- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp +++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp @@ -333,6 +333,10 @@ public: { emit mySignalWithDefaultArg(arg); } void emitMySignalWithDefaultArg() { emit mySignalWithDefaultArg(); } + void emitMySignalWithVariantArg(const QVariant &arg) + { emit mySignalWithVariantArg(arg); } + void emitMySignalWithScriptEngineArg(QScriptEngine *arg) + { emit mySignalWithScriptEngineArg(arg); } public Q_SLOTS: void mySlot() @@ -395,6 +399,8 @@ Q_SIGNALS: void myOtherOverloadedSignal(const QString &arg); void myOtherOverloadedSignal(int arg); void mySignalWithDefaultArg(int arg = 123); + void mySignalWithVariantArg(const QVariant &arg); + void mySignalWithScriptEngineArg(QScriptEngine *arg); protected: void connectNotify(const char *signal) { @@ -1553,6 +1559,29 @@ void tst_QScriptExtQObject::connectAndDisconnect() m_myObject->emitMyOtherOverloadedSignal(123); QVERIFY(!m_engine->evaluate("gotSignal").toBoolean()); + // signal with QVariant arg: argument conversion should work + m_myObject->clearConnectedSignal(); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.connect(myHandler)").isUndefined()); + QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithVariantArg(QVariant))); + m_engine->evaluate("gotSignal = false"); + m_myObject->emitMySignalWithVariantArg(123); + QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); + QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); + + // signal with argument type that's unknown to the meta-type system + m_myObject->clearConnectedSignal(); + QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.connect(myHandler)").isUndefined()); + QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithScriptEngineArg(QScriptEngine*))); + m_engine->evaluate("gotSignal = false"); + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine: Unable to handle unregistered datatype 'QScriptEngine*' when invoking handler of signal MyQObject::mySignalWithScriptEngineArg(QScriptEngine*)"); + m_myObject->emitMySignalWithScriptEngineArg(m_engine); + QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); + QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isUndefined()); + QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.disconnect(myHandler)").isUndefined()); + // connect(object, function) m_engine->evaluate("otherObject = { name:'foo' }"); QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined()); |