summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-09-24 10:25:49 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 18:45:20 (GMT)
commitb66b145633e19a7f70aade0943e0c8efb5169a59 (patch)
tree7effd30faa99b445d33dd625da8677ef89da391a /tests/auto
parentdff8dd6c31e81269b99004d9fb4127cd50a86fe4 (diff)
downloadQt-b66b145633e19a7f70aade0943e0c8efb5169a59.zip
Qt-b66b145633e19a7f70aade0943e0c8efb5169a59.tar.gz
Qt-b66b145633e19a7f70aade0943e0c8efb5169a59.tar.bz2
Include the signal code in the argument of (dis)connectNotify().
As it turns out, the convention of (dis)connectNotify() is to include the signal prefix, i.e. '2'. Therefore add this prefix also when calling these functions from QML. Also add a unit test confirming that the C++ and QML cases are now handled the same way. This patch is not needed in Qt5, as connectNotify() and disconnectNotify() take a QMetaMethod as a parameter, not a const char*. Change-Id: I3add0fc13c60a479949cf3d31218af5fd3f546a2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativenotifier/tst_qdeclarativenotifier.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/tests/auto/declarative/qdeclarativenotifier/tst_qdeclarativenotifier.cpp b/tests/auto/declarative/qdeclarativenotifier/tst_qdeclarativenotifier.cpp
index 9fb028b..2cdd67f 100644
--- a/tests/auto/declarative/qdeclarativenotifier/tst_qdeclarativenotifier.cpp
+++ b/tests/auto/declarative/qdeclarativenotifier/tst_qdeclarativenotifier.cpp
@@ -105,30 +105,30 @@ protected:
void connectNotify(const char *signal)
{
const QString signalName(signal);
- if (signalName == "selfPropChanged()") selfPropConnections++;
- if (signalName == "qmlObjectPropChanged()") qmlObjectPropConnections++;
- if (signalName == "cppObjectPropChanged()") cppObjectPropConnections++;
- if (signalName == "unboundPropChanged()") unboundPropConnections++;
- if (signalName == "normalBindingPropChanged()") normalBindingPropConnections++;
- if (signalName == "compiledBindingPropChanged()") compiledBindingPropConnections++;
- if (signalName == "compiledBindingPropSharedChanged()") compiledBindingPropSharedConnections++;
- if (signalName == "boundSignal()") boundSignalConnections++;
- if (signalName == "unusedSignal()") unusedSignalConnections++;
+ if (signalName == SIGNAL(selfPropChanged())) selfPropConnections++;
+ if (signalName == SIGNAL(qmlObjectPropChanged())) qmlObjectPropConnections++;
+ if (signalName == SIGNAL(cppObjectPropChanged())) cppObjectPropConnections++;
+ if (signalName == SIGNAL(unboundPropChanged())) unboundPropConnections++;
+ if (signalName == SIGNAL(normalBindingPropChanged())) normalBindingPropConnections++;
+ if (signalName == SIGNAL(compiledBindingPropChanged())) compiledBindingPropConnections++;
+ if (signalName == SIGNAL(compiledBindingPropSharedChanged())) compiledBindingPropSharedConnections++;
+ if (signalName == SIGNAL(boundSignal())) boundSignalConnections++;
+ if (signalName == SIGNAL(unusedSignal())) unusedSignalConnections++;
//qDebug() << Q_FUNC_INFO << this << signalName;
}
void disconnectNotify(const char *signal)
{
const QString signalName(signal);
- if (signalName == "selfPropChanged()") selfPropConnections--;
- if (signalName == "qmlObjectPropChanged()") qmlObjectPropConnections--;
- if (signalName == "cppObjectPropChanged()") cppObjectPropConnections--;
- if (signalName == "unboundPropChanged()") unboundPropConnections--;
- if (signalName == "normalBindingPropChanged()") normalBindingPropConnections--;
- if (signalName == "compiledBindingPropChanged()") compiledBindingPropConnections--;
- if (signalName == "compiledBindingPropSharedChanged()") compiledBindingPropSharedConnections--;
- if (signalName == "boundSignal()") boundSignalConnections--;
- if (signalName == "unusedSignal()") unusedSignalConnections--;
+ if (signalName == SIGNAL(selfPropChanged())) selfPropConnections--;
+ if (signalName == SIGNAL(qmlObjectPropChanged())) qmlObjectPropConnections--;
+ if (signalName == SIGNAL(cppObjectPropChanged())) cppObjectPropConnections--;
+ if (signalName == SIGNAL(unboundPropChanged())) unboundPropConnections--;
+ if (signalName == SIGNAL(normalBindingPropChanged())) normalBindingPropConnections--;
+ if (signalName == SIGNAL(compiledBindingPropChanged())) compiledBindingPropConnections--;
+ if (signalName == SIGNAL(compiledBindingPropSharedChanged())) compiledBindingPropSharedConnections--;
+ if (signalName == SIGNAL(boundSignal())) boundSignalConnections--;
+ if (signalName == SIGNAL(unusedSignal())) unusedSignalConnections--;
//qDebug() << Q_FUNC_INFO << this << signalName;
}
@@ -167,6 +167,8 @@ private slots:
void propertyChange();
void disconnectOnDestroy();
+ void nonQmlConnect();
+
private:
void createObjects();
@@ -296,6 +298,15 @@ void tst_qdeclarativenotifier::disconnectOnDestroy()
QCOMPARE(exportedObject->cppObjectPropConnections, 0);
}
+void tst_qdeclarativenotifier::nonQmlConnect()
+{
+ ExportedClass a;
+ connect(&a, SIGNAL(boundSignal()), &a, SIGNAL(compiledBindingPropChanged()));
+ QCOMPARE(a.boundSignalConnections, 1);
+ disconnect(&a, SIGNAL(boundSignal()), &a, SIGNAL(compiledBindingPropChanged()));
+ QCOMPARE(a.boundSignalConnections, 0);
+}
+
QTEST_MAIN(tst_qdeclarativenotifier)
#include "tst_qdeclarativenotifier.moc"