aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimatedsprite
diff options
context:
space:
mode:
authorAndreas Buhr <andreas@andreasbuhr.de>2022-04-19 18:29:50 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-07 13:03:43 +0000
commit033e972e0eb58a347f7902a4ab86d19c0600e975 (patch)
treeb8d5904f0713894c38b6b93b58bbf21c097f8698 /tests/auto/quick/qquickanimatedsprite
parent9cb98734b416c937f1e18ac43db6a76b598eafb0 (diff)
Fix tst_qquickanimatedsprite on Android
tst_qquickanimatedsprite:: test_changeSourceToSmallerImgKeepingBigFrameSize() starts an extra thread which is supposed to kill the test application in case the main loop enters some infinite loop. In case of success (no infinite loop), that extra thread should be terminated. On Android, thread termination is not available. This patch introduces code so that the thread can end itself. Task-number: QTBUG-101865 Change-Id: I80e80d3c650fa738f6d078e25e54fb2a198a64e5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit ac3583c015881c432256e6decffd2360e4a689cf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/quick/qquickanimatedsprite')
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index a7c08b714a..99ed8aec95 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -329,9 +329,26 @@ class KillerThread : public QThread
Q_OBJECT
protected:
void run() override {
- sleep(3);
- qFatal("Either the GUI or the render thread is stuck in an infinite loop.");
+ QMutexLocker lock(&abortMutex);
+ if (!aborted)
+ abortWaitCondition.wait(&abortMutex, 3000);
+
+ if (!aborted)
+ qFatal("Either the GUI or the render thread is stuck in an infinite loop.");
+ }
+
+public:
+ void abort()
+ {
+ QMutexLocker lock(&abortMutex);
+ aborted = true;
+ abortWaitCondition.wakeAll();
}
+
+private:
+ QMutex abortMutex;
+ QWaitCondition abortWaitCondition;
+ bool aborted = false;
};
// Regression test for QTBUG-53937
@@ -356,7 +373,7 @@ void tst_qquickanimatedsprite::test_changeSourceToSmallerImgKeepingBigFrameSize(
// If we reach this point it's because we didn't hit QTBUG-53937
- killer->terminate();
+ killer->abort();
killer->wait();
}