diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-21 18:38:53 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-21 18:38:53 (GMT) |
commit | 8e65adce9ced8f3b1d42b938e4d65e1af4768c33 (patch) | |
tree | 042094137a842b98a41474ce99192b67a822820c /tests/auto/qobject | |
parent | 613be7cd75663ab8227de80d75d8f01e92c5c7d2 (diff) | |
parent | 2ae6b44e4242c60bd882661e104bb53fa6670556 (diff) | |
download | Qt-8e65adce9ced8f3b1d42b938e4d65e1af4768c33.zip Qt-8e65adce9ced8f3b1d42b938e4d65e1af4768c33.tar.gz Qt-8e65adce9ced8f3b1d42b938e4d65e1af4768c33.tar.bz2 |
Merge branch '4.6'
Conflicts:
tools/assistant/lib/qhelpsearchquerywidget.cpp
Diffstat (limited to 'tests/auto/qobject')
-rw-r--r-- | tests/auto/qobject/tst_qobject.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 7c172ef..3896d70 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -127,6 +127,7 @@ private slots: void overloads(); void isSignalConnected(); void qMetaObjectConnect(); + void qMetaObjectDisconnectOne(); protected: }; @@ -3441,5 +3442,77 @@ void tst_QObject::qMetaObjectConnect() } +void tst_QObject::qMetaObjectDisconnectOne() +{ + SenderObject *s = new SenderObject; + ReceiverObject *r1 = new ReceiverObject; + + int signal1Index = s->metaObject()->indexOfSignal("signal1()"); + int signal3Index = s->metaObject()->indexOfSignal("signal3()"); + int slot1Index = r1->metaObject()->indexOfSlot("slot1()"); + int slot2Index = r1->metaObject()->indexOfSlot("slot2()"); + + QVERIFY(signal1Index > 0); + QVERIFY(signal3Index > 0); + QVERIFY(slot1Index > 0); + QVERIFY(slot2Index > 0); + + QVERIFY( QMetaObject::connect(s, signal1Index, r1, slot1Index) ); + QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); + QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); + QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); + + r1->reset(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 0 ); + + s->emitSignal1(); + QCOMPARE( r1->count_slot1, 1 ); + QCOMPARE( r1->count_slot2, 0 ); + + s->emitSignal3(); + QCOMPARE( r1->count_slot1, 1 ); + QCOMPARE( r1->count_slot2, 3 ); + + r1->reset(); + QVERIFY( QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); + QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + + s->emitSignal1(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 0 ); + + s->emitSignal3(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 2 ); + + r1->reset(); + QVERIFY( false == QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); + QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + + s->emitSignal1(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 0 ); + + s->emitSignal3(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 1 ); + + r1->reset(); + QVERIFY( false == QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); + QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + + s->emitSignal1(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 0 ); + + s->emitSignal3(); + QCOMPARE( r1->count_slot1, 0 ); + QCOMPARE( r1->count_slot2, 0 ); + + delete s; + delete r1; +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" |