[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: unit testing a freeze
From:       Dario Freddi <drf54321 () gmail ! com>
Date:       2012-03-22 7:34:22
Message-ID: CAFFVnfNG1xVmWLZRdWw1CL5CM3zYqNucmKzJBCHTwi7=Buj_SQ () mail ! gmail ! com
[Download RAW message or body]

Il 22 marzo 2012 07:00, Frank Reininghaus <frank78ac@googlemail.com> ha scr=
itto:
> Hi,
>
> Am 22. M=E4rz 2012 01:11 schrieb Dario Freddi:
>> Il 21 marzo 2012 22:29, Dominik Haumann ha scritto:
>>> Moin,
>>>
>>> is there a simple way to unit test a freeze?
>>> Like if the test needs more than 5 seconds, fail?
>>
>> There's no straightforward way to check afaik and I don't really like
>> the thread approach. What are you trying to verify? If the context is
>> the one of a synchronous operation, I am afraid this might be very
>> tricky, since there is no easy way you can interrupt a synchronous
>> call identifying its context. Supposing your routine is asynchronous,
>>
>> QTimer timer;
>> QEventLoop e;
>> connect(&timer, SIGNAL(timeout()), &e, SLOT(quit()));
>> connect(myObject, SIGNAL(finished()), &e, SLOT(quit()));
>> myObject->problematicAsyncCall();
>> timer.setSingleShot(true);
>> timer.start(5000);
>> e.exec();
>>
>> QVERIFY(timer.isActive());
>
> I think the same could be achieved like this:
>
> myObject->problematicAsyncCall();
> QTest::kWaitForSignal(myObject, SIGNAL(finished()), 5000)

Correct - I forgot we were using KDE's infrastructure and not pure Qt

>
> Best regards,
> Frank
>
>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscri=
be <<

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic