summaryrefslogtreecommitdiffstats
path: root/tests/auto/qobject
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-12-02 19:27:48 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-12-02 19:27:48 (GMT)
commit204fc5ed9642a3754dfefe7d4b1a5374615726a4 (patch)
tree65465f39338fb4d00c1c86be65edc372ab990795 /tests/auto/qobject
parent2eb96bf5b68cbdcc1ebd2616b0b9e5f0f77eb257 (diff)
parentf29f1bb287c6b39bd1270802d1579f1c1d53f905 (diff)
downloadQt-204fc5ed9642a3754dfefe7d4b1a5374615726a4.zip
Qt-204fc5ed9642a3754dfefe7d4b1a5374615726a4.tar.gz
Qt-204fc5ed9642a3754dfefe7d4b1a5374615726a4.tar.bz2
Merge branch '4.6'
Conflicts: src/corelib/global/qglobal.h src/gui/dialogs/qfiledialog_win.cpp src/plugins/qpluginbase.pri src/qbase.pri tests/auto/selftests/expected_cmptest.txt tests/auto/selftests/expected_crashes_3.txt tests/auto/selftests/expected_longstring.txt tests/auto/selftests/expected_maxwarnings.txt tests/auto/selftests/expected_skip.txt tools/assistant/tools/assistant/doc/assistant.qdocconf tools/qdoc3/test/assistant.qdocconf tools/qdoc3/test/designer.qdocconf tools/qdoc3/test/linguist.qdocconf tools/qdoc3/test/qmake.qdocconf tools/qdoc3/test/qt-build-docs.qdocconf tools/qdoc3/test/qt.qdocconf
Diffstat (limited to 'tests/auto/qobject')
-rw-r--r--tests/auto/qobject/tst_qobject.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index b296e1b..d2073d2 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -60,6 +60,10 @@
#include <QProcess>
#include "qobject.h"
+#ifdef QT_BUILD_INTERNAL
+#include <private/qobject_p.h>
+#endif
+
#include <math.h>
@@ -121,6 +125,7 @@ private slots:
void interfaceIid();
void deleteQObjectWhenDeletingEvent();
void overloads();
+ void isSignalConnected();
protected:
};
@@ -3188,5 +3193,109 @@ void tst_QObject::overloads()
QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot
}
+class ManySignals : public QObject
+{ Q_OBJECT
+ friend class tst_QObject;
+signals:
+ void sig00(); void sig01(); void sig02(); void sig03(); void sig04();
+ void sig05(); void sig06(); void sig07(); void sig08(); void sig09();
+ void sig10(); void sig11(); void sig12(); void sig13(); void sig14();
+ void sig15(); void sig16(); void sig17(); void sig18(); void sig19();
+ void sig20(); void sig21(); void sig22(); void sig23(); void sig24();
+ void sig25(); void sig26(); void sig27(); void sig28(); void sig29();
+ void sig30(); void sig31(); void sig32(); void sig33(); void sig34();
+ void sig35(); void sig36(); void sig37(); void sig38(); void sig39();
+ void sig40(); void sig41(); void sig42(); void sig43(); void sig44();
+ void sig45(); void sig46(); void sig47(); void sig48(); void sig49();
+ void sig50(); void sig51(); void sig52(); void sig53(); void sig54();
+ void sig55(); void sig56(); void sig57(); void sig58(); void sig59();
+ void sig60(); void sig61(); void sig62(); void sig63(); void sig64();
+ void sig65(); void sig66(); void sig67(); void sig68(); void sig69();
+
+public slots:
+ void received() { rec++; }
+public:
+ int rec;
+};
+
+
+void tst_QObject::isSignalConnected()
+{
+ ManySignals o;
+ o.rec = 0;
+#ifdef QT_BUILD_INTERNAL
+ QObjectPrivate *priv = QObjectPrivate::get(&o);
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
+ if (sizeof(void *) >= 8) { //on 32bit isSignalConnected only works with the first 32 signals
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()")));
+ }
+#endif
+
+ QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69()));
+ QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03()));
+ QObject::connect(&o, SIGNAL(sig69()), &o, SIGNAL(sig34()));
+ QObject::connect(&o, SIGNAL(sig03()), &o, SIGNAL(sig18()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
+
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()")));
+#endif
+
+ QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29()));
+ QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62()));
+ QObject::connect(&o, SIGNAL(sig62()), &o, SIGNAL(sig28()));
+ QObject::connect(&o, SIGNAL(sig28()), &o, SIGNAL(sig27()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()")));
+#endif
+
+ QCOMPARE(o.rec, 0);
+ emit o.sig01();
+ emit o.sig34();
+ QCOMPARE(o.rec, 0);
+
+ QObject::connect(&o, SIGNAL(sig27()), &o, SLOT(received()));
+
+#ifdef QT_BUILD_INTERNAL
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
+ QVERIFY(priv->isSignalConnected(priv->signalIndex("sig27()")));
+
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig04()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()")));
+ QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()")));
+#endif
+
+ emit o.sig00();
+ QCOMPARE(o.rec, 1);
+ emit o.sig69();
+ QCOMPARE(o.rec, 2);
+ emit o.sig36();
+ QCOMPARE(o.rec, 2);
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"