summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2020-04-09 15:23:04 +0200
committerBernd Weimer <bernd.weimer@pelagicore.com>2020-04-15 17:33:19 +0200
commitda49b8bb9363216192e8acdde2f5941bb7f29cd7 (patch)
tree94ec40052bb2a9954cd1a7b49443004b96230c57
parent84f83d69323271c0677abd983c64507e96181002 (diff)
Flush Wayland messages in test case
A SignalSpy in QML tests frequently calls processEvents(), which unfortunately doesn't lead to a flush of the Wayland message queue. A workaround is implemented that forces flushing by manually emitting the aboutToBlock signal. Task-number: AUTOSUITE-709 Change-Id: I1480d756d9eb00d16181c9c747a3f27bce88891d Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--src/tools/testrunner/testrunner.cpp6
-rw-r--r--src/tools/testrunner/testrunner_p.h1
-rw-r--r--tests/qml/configs/tst_configs.qml17
3 files changed, 19 insertions, 5 deletions
diff --git a/src/tools/testrunner/testrunner.cpp b/src/tools/testrunner/testrunner.cpp
index 7402adad..d8837b01 100644
--- a/src/tools/testrunner/testrunner.cpp
+++ b/src/tools/testrunner/testrunner.cpp
@@ -43,6 +43,7 @@
#include "testrunner.h"
#include <QCoreApplication>
+#include <QAbstractEventDispatcher>
#include <QEventLoop>
#include <QQmlEngine>
#include <QRegExp>
@@ -130,6 +131,11 @@ int AmTest::observeObjectDestroyed(QObject *obj)
return index;
}
+void AmTest::aboutToBlock()
+{
+ emit QAbstractEventDispatcher::instance()->aboutToBlock();
+}
+
QTestRootObject::QTestRootObject(QObject *parent)
: QObject(parent)
diff --git a/src/tools/testrunner/testrunner_p.h b/src/tools/testrunner/testrunner_p.h
index cf00f516..3c4cbde0 100644
--- a/src/tools/testrunner/testrunner_p.h
+++ b/src/tools/testrunner/testrunner_p.h
@@ -100,6 +100,7 @@ public:
Q_INVOKABLE void ignoreMessage(MsgType type, const char* msg);
Q_INVOKABLE void ignoreMessage(MsgType type, const QRegExp &expression);
Q_INVOKABLE int observeObjectDestroyed(QObject *obj);
+ Q_INVOKABLE void aboutToBlock();
Q_SIGNALS:
void objectDestroyed(int index);
diff --git a/tests/qml/configs/tst_configs.qml b/tests/qml/configs/tst_configs.qml
index 7e92e89f..6acbb67c 100644
--- a/tests/qml/configs/tst_configs.qml
+++ b/tests/qml/configs/tst_configs.qml
@@ -42,6 +42,7 @@
import QtQuick 2.4
import QtTest 1.0
+import QtApplicationManager 2.0
import QtApplicationManager.SystemUI 2.0
@@ -68,6 +69,13 @@ TestCase {
SignalSpy {
id: windowPropertyChangedSpy
+ // Workaround to flush Wayland messages, see https://bugreports.qt.io/browse/AUTOSUITE-709
+ // A proper solution in QtWayland is sought here: https://bugreports.qt.io/browse/QTBUG-83422
+ function aboutToBlockWait(timeout)
+ {
+ AmTest.aboutToBlock();
+ wait(timeout);
+ }
target: WindowManager
signalName: "windowPropertyChanged"
}
@@ -109,13 +117,12 @@ TestCase {
}
window.setWindowProperty("trigger", "now");
- windowPropertyChangedSpy.wait();
+ windowPropertyChangedSpy.aboutToBlockWait();
compare(windowPropertyChangedSpy.signalArguments[0][0], window);
compare(window.windowProperty("trigger"), "now");
- // The following would only work in single-process mode (see https://bugreports.qt.io/browse/AUTOSUITE-709)
- // windowPropertyChangedSpy.wait();
- // compare(windowPropertyChangedSpy.signalArguments[1][0], window);
- // compare(window.windowProperty("ack"), "done");
+ windowPropertyChangedSpy.wait();
+ compare(windowPropertyChangedSpy.signalArguments[1][0], window);
+ compare(window.windowProperty("ack"), "done");
}
}