summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/util.h')
-rw-r--r--tests/auto/widgets/util.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index e5e991f89..a9a3d487c 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -93,24 +93,32 @@ public:
// Tells tr1::ref the result of void operator()(const T &result) when decltype isn't available.
typedef void result_type;
- CallbackSpy() {
+ CallbackSpy() : called(false) {
timeoutTimer.setSingleShot(true);
QObject::connect(&timeoutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
}
T waitForResult() {
- timeoutTimer.start(10000);
- eventLoop.exec();
+ if (!called) {
+ timeoutTimer.start(10000);
+ eventLoop.exec();
+ }
return result;
}
+ bool wasCalled() const {
+ return called;
+ }
+
void operator()(const T &result) {
this->result = result;
+ called = true;
eventLoop.quit();
}
private:
Q_DISABLE_COPY(CallbackSpy)
+ bool called;
QTimer timeoutTimer;
QEventLoop eventLoop;
T result;