Remove Q_ASSERT's from QObject autotest.
authorJason McDonald <jason.mcdonald@nokia.com>
Tue, 3 May 2011 01:59:05 +0000 (11:59 +1000)
committerRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 18 May 2011 00:46:42 +0000 (10:46 +1000)
The Receiver class has two slots that aren't meant to get called during
the test (they're there to catch broken parsing of slot names).  Rather
than asserting when one of them gets called, which does nothing in a
release mode build, this commit makes the slots record the number of
times they were called (as for the other slots in the test) and fails
the test gracefully if either of those slots was called.

Change-Id: Ia0393026cb96ffdc6190b5e7bd951f75d231b11e
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
(cherry picked from commit 7bd6ca895e5fa4de197d9d7bf2e7b578c01c3c2a)

tests/auto/qobject/tst_qobject.cpp

index 4b926e4..b083561 100644 (file)
@@ -403,6 +403,8 @@ public:
     }
 
     void reset() {
+        called_slot10 = 0;
+        called_slot9 = 0;
         called_slot8 = 0;
         called_slot7 = 0;
         called_slot6 = 0;
@@ -421,6 +423,8 @@ public:
     int called_slot6;
     int called_slot7;
     int called_slot8;
+    int called_slot9;
+    int called_slot10;
 
     bool called(int slot) {
         switch (slot) {
@@ -432,6 +436,8 @@ public:
         case 6: return called_slot6;
         case 7: return called_slot7;
         case 8: return called_slot8;
+        case 9: return called_slot9;
+        case 10: return called_slot10;
         default: return false;
         }
     }
@@ -449,8 +455,8 @@ public slots:
     void slotLoopBack() { ++called_slot8; }
 
 protected slots:
-    void o() { Q_ASSERT(0); }
-    void on() { Q_ASSERT(0); }
+    void o() { ++called_slot9; }
+    void on() { ++called_slot10; }
 
 signals:
     void on_Sender_signalLoopBack();
@@ -473,6 +479,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), false);
     QCOMPARE(receiver.called(8), false);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 
     sender.emitSignalWithParams(0);
@@ -484,6 +492,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), false);
     QCOMPARE(receiver.called(8), false);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 
     sender.emitSignalWithParams(0, "string");
@@ -495,6 +505,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), false);
     QCOMPARE(receiver.called(8), false);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 
     sender.emitSignalManyParams(1, 2, 3, "string", true);
@@ -506,6 +518,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), false);
     QCOMPARE(receiver.called(8), false);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 
     sender.emitSignalManyParams2(1, 2, 3, "string", true);
@@ -517,6 +531,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), true);
     QCOMPARE(receiver.called(8), false);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 
     sender.emitSignalLoopBack();
@@ -528,6 +544,8 @@ void tst_QObject::connectByName()
     QCOMPARE(receiver.called(6), false);
     QCOMPARE(receiver.called(7), false);
     QCOMPARE(receiver.called(8), true);
+    QCOMPARE(receiver.called(9), false);
+    QCOMPARE(receiver.called(10), false);
     receiver.reset();
 }