diff options
author | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2019-08-12 14:36:06 +0200 |
---|---|---|
committer | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2019-08-13 17:26:18 +0200 |
commit | e8c7124768b0e3e556a8ae53629478284bbdca8e (patch) | |
tree | a29ebb5ada09c6a91651c455970fb6b858232d57 /src/testlib/qsignalspy.h | |
parent | c29a136804f5952c0b4c15920f3ab4032c21573c (diff) |
Introduce QSignalSpy constructor allows to spy on a meta method
This functionality is especially convenient if meta-object system is
heavily used in a test. For example, if you need to test a bunch of
signals based on their names and/or argument types.
Change-Id: I09a4ecbbd3d0859b5fd466d9dde7679804eb7614
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/testlib/qsignalspy.h')
-rw-r--r-- | src/testlib/qsignalspy.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index 91c2d139a8..dc0c58044f 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -118,6 +118,16 @@ public: } #endif // Q_CLANG_QDOC + QSignalSpy(const QObject *obj, const QMetaMethod &signal) + : m_waiting(false) + { + if (isObjectValid(obj) && isSignalMetaMethodValid(signal) && + connectToSignal(obj, signal.methodIndex())) { + sig = signal.methodSignature(); + initArgs(signal, obj); + } + } + inline bool isValid() const { return !sig.isEmpty(); } inline QByteArray signal() const { return sig; } |