7#include <QtCore/qbytearray.h>
8#include <QtCore/qlist.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qmetaobject.h>
11#include <QtTest/qtesteventloop.h>
12#include <QtCore/qvariant.h>
25 if (!isObjectValid(
obj))
29 qWarning(
"QSignalSpy: Null signal name is not valid");
34 qWarning(
"QSignalSpy: Not a valid signal, use the SIGNAL macro");
46 if (!connectToSignal(
obj, sigIndex))
50 initArgs(
mo->method(sigIndex),
obj);
54 template <
typename Po
interToMemberFunction>
57 template <
typename Func>
61 if (!isObjectValid(
obj))
65 qWarning(
"QSignalSpy: Null signal name is not valid");
71 const int sigIndex = signalMetaMethod.
methodIndex();
73 if (!isSignalMetaMethodValid(signalMetaMethod))
76 if (!connectToSignal(
obj, sigIndex))
80 initArgs(
mo->method(sigIndex),
obj);
87 if (isObjectValid(
obj) && isSignalMetaMethodValid(
signal) &&
88 connectToSignal(
obj,
signal.methodIndex())) {
89 sig =
signal.methodSignature();
98 {
return wait(std::chrono::milliseconds{
timeout}); }
100 bool wait(std::chrono::milliseconds
timeout = std::chrono::seconds{5})
107 return size() > origCount;
112 methodId = QObject::qt_metacall(call, methodId,
a);
128 static const int memberOffset = QObject::staticMetaObject.methodCount();
133 qWarning(
"QSignalSpy: QMetaObject::connect returned false. Unable to connect.");
148 static bool isObjectValid(
const QObject *
object)
150 const bool valid = !!
object;
153 qWarning(
"QSignalSpy: Cannot spy on a null object");
164 void *argv[] = { &tp, &
i };
170 qWarning(
"QSignalSpy: Unable to handle parameter '%s' of type '%s' of method '%s',"
171 " use qRegisterMetaType to register it.",
180 void appendArgs(
void **
a)
184 for (
int i = 0;
i < args.
size(); ++
i) {
187 list << *reinterpret_cast<QVariant *>(
a[
i + 1]);
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
qsizetype size() const noexcept
const_pointer constData() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
QSignalSpy(const typename QtPrivate::FunctionPointer< Func >::Object *obj, Func signal0)
QSignalSpy(const QObject *obj, const QMetaMethod &signal)
QSignalSpy(const QObject *obj, const char *aSignal)
bool wait(std::chrono::milliseconds timeout=std::chrono::seconds{5})
QByteArray signal() const
int qt_metacall(QMetaObject::Call call, int methodId, void **a) override
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean GLboolean a
[7]
GLbitfield GLuint64 timeout
[4]