summaryrefslogtreecommitdiffstats
path: root/tests/auto/qobject
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-23 13:16:52 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-23 13:36:16 (GMT)
commitb17b2443bf8bd1880af593f379c93081ac6d7a80 (patch)
tree2c4a41b6d76194d00fb12ea1a8ff086e61f2755f /tests/auto/qobject
parent5d27c5485023998c3771bded0b86f1ae836a44af (diff)
downloadQt-b17b2443bf8bd1880af593f379c93081ac6d7a80.zip
Qt-b17b2443bf8bd1880af593f379c93081ac6d7a80.tar.gz
Qt-b17b2443bf8bd1880af593f379c93081ac6d7a80.tar.bz2
tst_QObject: test signals and slots with the same name
Diffstat (limited to 'tests/auto/qobject')
-rw-r--r--tests/auto/qobject/tst_qobject.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 7b35ef5..8da3484 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -128,6 +128,7 @@ private slots:
void isSignalConnected();
void qMetaObjectConnect();
void qMetaObjectDisconnectOne();
+ void sameName();
protected:
};
@@ -162,7 +163,7 @@ class SenderObject : public QObject
Q_OBJECT
public:
- SenderObject() : recursionCount(0) {}
+ SenderObject() : aPublicSlotCalled(0), recursionCount(0) {}
void emitSignal1AfterRecursion()
{
@@ -185,11 +186,12 @@ signals:
QT_MOC_COMPAT void signal5();
public slots:
- void aPublicSlot(){}
+ void aPublicSlot() { aPublicSlotCalled++; }
public:
Q_INVOKABLE void invoke1(){}
Q_SCRIPTABLE void sinvoke1(){}
+ int aPublicSlotCalled;
protected:
Q_INVOKABLE QT_MOC_COMPAT void invoke2(){}
Q_INVOKABLE QT_MOC_COMPAT void invoke2(int){}
@@ -3552,5 +3554,41 @@ void tst_QObject::qMetaObjectDisconnectOne()
delete r1;
}
+class ConfusingObject : public SenderObject
+{ Q_OBJECT
+public slots:
+ void signal1() { s++; }
+signals:
+ void aPublicSlot();
+public:
+ int s;
+ ConfusingObject() : s(0) {}
+ friend class tst_QObject;
+};
+
+void tst_QObject::sameName()
+{
+ ConfusingObject c1, c2;
+ QVERIFY(connect(&c1, SIGNAL(signal1()), &c1, SLOT(signal1())));
+ c1.emitSignal1();
+ QCOMPARE(c1.s, 1);
+
+ QVERIFY(connect(&c2, SIGNAL(signal1()), &c1, SIGNAL(signal1())));
+ c2.emitSignal1();
+ QCOMPARE(c1.s, 2);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(signal1())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 0);
+ QCOMPARE(c1.s, 3);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(aPublicSlot())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 1);
+ QCOMPARE(c1.s, 4);
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"