summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qtestsupport_widgets.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-01-25 13:35:28 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-01-25 18:37:47 +0100
commit3f2a9523a442e44ef52ebca30da9b5d3188df6bc (patch)
treec50a8569109465f0bf2d48afa23d3fb57bb6d80b /src/widgets/kernel/qtestsupport_widgets.cpp
parent9932f2dd479baefb915ad841c95855d61b764ab6 (diff)
qWaitForWindowFocused: Pass timeout as QDeadlineTimer
We should avoid int-based timeouts nowadays, and prefer std::chrono, or for timeouts where Forever is a valid state, QDeadlineTimer. Discovered during API header review. Pick-to: 6.7 Change-Id: Ia56a67084c7a2f989951755fed5ffc161ed8f79e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/widgets/kernel/qtestsupport_widgets.cpp')
-rw-r--r--src/widgets/kernel/qtestsupport_widgets.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp
index 226c56140d..f7b25b6643 100644
--- a/src/widgets/kernel/qtestsupport_widgets.cpp
+++ b/src/widgets/kernel/qtestsupport_widgets.cpp
@@ -16,8 +16,8 @@
QT_BEGIN_NAMESPACE
-template <typename FunctorWindowGetter, typename FunctorPredicate>
-static bool qWaitForWidgetWindow(FunctorWindowGetter windowGetter, FunctorPredicate predicate, int timeout)
+template <typename FunctorWindowGetter, typename FunctorPredicate, typename Timeout>
+static bool qWaitForWidgetWindow(FunctorWindowGetter windowGetter, FunctorPredicate predicate, Timeout timeout)
{
if (!windowGetter())
return false;
@@ -64,7 +64,7 @@ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
/*!
\since 6.7
- Returns \c true, if \a widget is the focus window within \a timeout milliseconds. Otherwise returns \c false.
+ Returns \c true, if \a widget is the focus window within \a timeout. Otherwise returns \c false.
The method is useful in tests that call QWidget::show() and rely on the widget
having focus (for receiving keyboard events e.g.) before proceeding.
@@ -77,7 +77,7 @@ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
\sa qWaitForWindowExposed(), qWaitForWindowActive(), QGuiApplication::focusWindow()
*/
-Q_WIDGETS_EXPORT bool QTest::qWaitForWindowFocused(QWidget *widget, int timeout)
+Q_WIDGETS_EXPORT bool QTest::qWaitForWindowFocused(QWidget *widget, QDeadlineTimer timeout)
{
return qWaitForWidgetWindow([&]() {
return widget->window()->windowHandle();