[Interest] QTest + QSignalSpy doesn't seem to work with deferred signals
Konrad Rosenbaum
konrad at silmor.de
Wed Jan 18 18:28:13 CET 2017
Hi,
On Wednesday, January 18, 2017 10:16:30 Bob Hood wrote:
> I'm trying to develop a unit test for an deferred signal; i.e. one that
> won't be emitted until the event loop has been allowed to run. The case
> looks like:
>
> void MyTest::user_info_deferred()
> {
> QVERIFY(qnam_class_ptr != nullptr);
>
> QSignalSpy spy(qnam_class_ptr, &QNAMClass::signal_userInfoReceived);
>
> // Retrieve account user information (deferred)
> QCOMPARE(qname_class_ptr->userInfo(), true);
I think you need to insert a spy.wait(...) here. Give the event loop a chance
to run...
> QCOMPARE(spy.count(), 1); // make sure the signal was emitted
> exactly one time
> QNAMClassUser info = qvariant_cast<QNAMClassUser>(spy.at(0).at(0));
> }
[cut]
Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170118/b206b10b/attachment.sig>
More information about the Interest
mailing list