summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-04-18 17:58:42 +0200
committerArtem Dyomin <artem.dyomin@qt.io>2023-04-19 09:31:48 +0000
commit587fb48167cf57d1612338ac0e91ae8136cd76aa (patch)
tree1e6e8a861b3dbd2b0a9b1abcc247d5daea7c68e7
parent819141db2067afd8b3fe2d287b6df966b083d352 (diff)
downloadqtmultimedia-587fb48167cf57d1612338ac0e91ae8136cd76aa.tar.gz
Fix qmediaplayer tests flakyness with QSignalSpy
QSignalSpy is not safe if signals are emitted from another thread, on windows the collision of removing QSignalSpy and receiving a new frame occurredpretty often (around 20% of running attempts). Catching the signal in the main thread fixes the problem. Pick-to: 6.5 Change-Id: Id9630a5ee32e261b308ea61dc0a61b424f5239c0 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index a3e005929..953a43fc8 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -113,11 +113,12 @@ public:
: m_storeFrames(storeFrames)
{
connect(this, &QVideoSink::videoFrameChanged, this, &TestVideoSink::addVideoFrame);
+ connect(this, &QVideoSink::videoFrameChanged, this, &TestVideoSink::videoFrameChangedSync);
}
QVideoFrame waitForFrame()
{
- QSignalSpy spy(this, &TestVideoSink::videoFrameChanged);
+ QSignalSpy spy(this, &TestVideoSink::videoFrameChangedSync);
return spy.wait() ? spy.at(0).at(0).value<QVideoFrame>() : QVideoFrame{};
}
@@ -136,6 +137,9 @@ public Q_SLOTS:
++m_totalFrames;
}
+signals:
+ void videoFrameChangedSync(const QVideoFrame &frame);
+
public:
QList<QVideoFrame> m_frameList;
int m_totalFrames = 0; // used instead of the list when frames are not stored