diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/util.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/util.h b/tests/util.h index 51aac3f8..34cd0d6e 100644 --- a/tests/util.h +++ b/tests/util.h @@ -94,6 +94,18 @@ T expectFutureVariant(const QFuture<Input> &future) return expectVariant<T>(future.result()); } +template<typename T> +T wait(const QFuture<T> &future) +{ + auto watcher = std::make_unique<QFutureWatcher<T>>(); + QSignalSpy spy(watcher.get(), &QFutureWatcherBase::finished); + watcher->setFuture(future); + spy.wait(); + if constexpr (!std::is_same_v<T, void>) { + return future.result(); + } +} + class TestPasswordChecker : public QXmppPasswordChecker { public: |
