[Qt] Make QWebHistory unit tests more robust
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 16:34:05 +0000 (16:34 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 16:34:05 +0000 (16:34 +0000)
commit144a8459061c0eda945138d41503bf94f5f76789
treecb0ea10705d418355923b2ccabe27b8c76fa167f
parent1438a09d518983ec798d8821943d5d3b7f5ab236
[Qt] Make QWebHistory unit tests more robust

Reviewed by Jocelyn Turcotten.

The tests were using a QEventLoop::exec() call to verify the emission
of the loadFinished() signal after calling for example back() or forward().
However sometimes the call to back() may emit the signal immediately and
sometimes async, causing instabilities in test runs. The call to exec()
also means that if there was a bug then the rest would hang forever because
exec() has no timeout.

This patch introduces a simple SignalBarrier class that solves both issues:

(1) ensureSignalEmitted() supports the immediate signal emission case as well
as the async one.

(2) Through the use of QSignalSpy's wait() there's an actual timeout.

* tests/qwebhistory/tst_qwebhistory.cpp:
(tst_QWebHistory::init):
(tst_QWebHistory::cleanup):
(tst_QWebHistory::back):
(tst_QWebHistory::forward):
(tst_QWebHistory::goToItem):
(tst_QWebHistory::serialize_2):
* tests/util.h:
(waitForSignal):
(SignalBarrier):
(SignalBarrier::SignalBarrier):
(SignalBarrier::ensureSignalEmitted):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141598 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
Source/WebKit/qt/tests/util.h