summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-11 15:19:45 +0200
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-14 20:02:10 +0200
commit51f092905a2cb38feb5fef759b5ac8b417df0996 (patch)
tree3660c03297b1b55335803f288ab3bd06e7ab7fea
parent332c255c696bb15db7a0510dab2a6ac214ecdb19 (diff)
QTest: fall back to qWaitForWindowExposed in qWaitForWindowActivated
...if window activation isn't supported. Task-number: QTBUG-62188 Change-Id: Ia83de59d9a755d95b7150eb5261bc43dd7b60588 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/gui/kernel/qtestsupport_gui.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp
index 7aad4d8c7d..79da26f2ca 100644
--- a/src/gui/kernel/qtestsupport_gui.cpp
+++ b/src/gui/kernel/qtestsupport_gui.cpp
@@ -37,10 +37,15 @@
**
****************************************************************************/
+#include <private/qguiapplication_p.h>
+
+#include <qpa/qplatformintegration.h>
+
#include "qtestsupport_gui.h"
#include "qwindow.h"
#include <QtCore/qtestsupport_core.h>
+#include <QtCore/QDebug>
QT_BEGIN_NAMESPACE
@@ -55,6 +60,14 @@ QT_BEGIN_NAMESPACE
*/
Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
{
+ if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))) {
+ qWarning() << "qWaitForWindowActive was called on a platform that doesn't support window"
+ << "activation. This means there is an error in the test and it should either"
+ << "check for the WindowActivation platform capability before calling"
+ << "qWaitForWindowActivate, use qWaitForWindowExposed instead, or skip the test."
+ << "Falling back to qWaitForWindowExposed.";
+ return qWaitForWindowExposed(window, timeout);
+ }
return QTest::qWaitFor([&]() { return window->isActive(); }, timeout);
}