Il 22 marzo 2012 07:00, Frank Reininghaus <frank7...@googlemail.com> ha scritto: > Hi, > > Am 22. März 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 unsubscribe << >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<