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

List:       kde-devel
Subject:    Re: unit testing a freeze
From:       Frank Reininghaus <frank78ac () googlemail ! com>
Date:       2012-03-22 6:00:42
Message-ID: CAFoZWWh+NwxLJBegQW7k5BVR7ceTq1qSAGX5fh-bq=mFMq4MOA () mail ! gmail ! com
[Download RAW message or body]

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)

Best regards,
Frank

>> 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