summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index f1e04511cd..ac8aae8d3a 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -102,6 +102,7 @@ private slots:
#ifndef QT_NO_PROCESS
void recursiveSignalEmission();
#endif
+ void signalBlocking();
void blockingQueuedConnection();
void childEvents();
void installEventFilter();
@@ -454,7 +455,7 @@ void tst_QObject::connectSlotsByName()
sender.setObjectName("Sender");
QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: No matching signal for on_child_signal()");
- QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: Connecting slot on_Sender_signalManyParams() with the first of the following compatible signals: (\"signalManyParams(int,int,int,QString,bool)\", \"signalManyParams(int,int,int,QString,bool,bool)\") ");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::connectSlotsByName: Connecting slot on_Sender_signalManyParams() with the first of the following compatible signals: (\"signalManyParams(int,int,int,QString,bool)\", \"signalManyParams(int,int,int,QString,bool,bool)\")");
QMetaObject::connectSlotsByName(&receiver);
receiver.called_slots.clear();
@@ -2949,6 +2950,9 @@ void tst_QObject::dynamicProperties()
QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
QCOMPARE(obj.changedDynamicProperties.count(), 1);
QCOMPARE(obj.changedDynamicProperties.first(), QByteArray("myuserproperty"));
+ //check if there is no redundant DynamicPropertyChange events
+ QVERIFY(!obj.setProperty("myuserproperty", "Hello"));
+ QCOMPARE(obj.changedDynamicProperties.count(), 1);
obj.changedDynamicProperties.clear();
QCOMPARE(obj.property("myuserproperty").toString(), QString("Hello"));
@@ -2981,6 +2985,30 @@ void tst_QObject::recursiveSignalEmission()
}
#endif
+void tst_QObject::signalBlocking()
+{
+ SenderObject sender;
+ ReceiverObject receiver;
+
+ receiver.connect(&sender, SIGNAL(signal1()), SLOT(slot1()));
+
+ sender.emitSignal1();
+ QVERIFY(receiver.called(1));
+ receiver.reset();
+
+ sender.blockSignals(true);
+
+ sender.emitSignal1();
+ QVERIFY(!receiver.called(1));
+ receiver.reset();
+
+ sender.blockSignals(false);
+
+ sender.emitSignal1();
+ QVERIFY(receiver.called(1));
+ receiver.reset();
+}
+
void tst_QObject::blockingQueuedConnection()
{
{
@@ -4731,6 +4759,9 @@ class LotsOfSignalsAndSlots: public QObject
#endif*/
static void static_slot_vPFvvE(fptr) {}
+ void slot_vcRQObject(const QObject &) {}
+ void slot_vRQObject(QObject &) {}
+
signals:
void signal_v();
void signal_vi(int);
@@ -4748,6 +4779,9 @@ class LotsOfSignalsAndSlots: public QObject
void const_signal_v() const;
void const_signal_vi(int) const;
+ void signal_vcRQObject(const QObject &);
+ void signal_vRQObject(QObject &);
+
void signal(short&, short, long long, short);
void otherSignal(const char *);
};
@@ -4865,6 +4899,14 @@ void tst_QObject::connectCxx0xTypeMatching()
QVERIFY(QObject::connect(&obj, &Foo::const_signal_vi, &obj, &Foo::slot_vi));
QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_vi));
QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_v));
+
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vcRQObject, &obj, &Foo::slot_vcRQObject));
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vRQObject, &obj, &Foo::slot_vRQObject));
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vRQObject, &obj, &Foo::slot_vcRQObject));
+ // QVERIFY(QObject::connect(&obj, &Foo::signal_vcRQObject, &obj, &Foo::slot_vRQObject)); // Should be an error (const& -> &)
+
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vRi, &obj, &Foo::slot_vs));
+
}
class StringVariant : public QObject
@@ -5522,8 +5564,8 @@ public:
};
class ConnectToPrivateSlotPrivate : public QObjectPrivate {
-public:
Q_DECLARE_PUBLIC(ConnectToPrivateSlot)
+public:
int receivedCount;
QVariant receivedValue;