[Interest] QTest + QSignalSpy doesn't seem to work with deferred signals
Bob Hood
bhood2 at comcast.net
Wed Jan 18 19:09:21 CET 2017
On 1/18/2017 10:28 AM, Konrad Rosenbaum wrote:
> 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...
Ah, I see. The qWait() approach has probably been folded into QSignalSpy.
That makes sense.
Thanks, Konrad.
More information about the Interest
mailing list