summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-18 12:53:47 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-21 10:41:14 +0000
commite3fdc140113dba6f94376f4a27a0d31f2363721f (patch)
treecf96dd39530c280d75a67e10aab0914ced52a690
parent39b3ff04e6c6d01c4f294a870caaf19ced3216b2 (diff)
Fix tst_sensorgestures_gestures to pass on Android
The problem was that the testcase did not find the testdata files on Android. On closer inspection it turns out that TESTDATA token in qt_internal_add_test treats ANDROID/IOS and rest of the platforms differently in terms of how test resources are handled. This commit stores testdata unconditionally as qrc resources. Task-number: QTBUG-92513 Task-number: QTBUG-73618 Change-Id: I0cfe878661dd2c55fa63abc1f95534a8041aa34d Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 07155b638ec9e6383e05f054c71da24a199bf11e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/qsensorgestures_gestures/CMakeLists.txt15
-rw-r--r--tests/auto/qsensorgestures_gestures/mockcommon.cpp15
2 files changed, 13 insertions, 17 deletions
diff --git a/tests/auto/qsensorgestures_gestures/CMakeLists.txt b/tests/auto/qsensorgestures_gestures/CMakeLists.txt
index cebdf1a1..7707f9d5 100644
--- a/tests/auto/qsensorgestures_gestures/CMakeLists.txt
+++ b/tests/auto/qsensorgestures_gestures/CMakeLists.txt
@@ -3,17 +3,22 @@
#####################################################################
# Collect test data
-list(APPEND test_data "mock_data")
-list(APPEND test_data "dataset2_mock_data")
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ mock_data/*
+ dataset2_mock_data/*)
+list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_sensorgestures_gestures
SOURCES
mockbackends.h
mockcommon.cpp mockcommon.h
tst_sensorgestures_gestures.cpp
- DEFINES
- SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\"
PUBLIC_LIBRARIES
Qt::SensorsPrivate
- TESTDATA ${test_data}
)
+
+qt_internal_add_resource(tst_sensorgestures_gestures
+ "tst_sensorgestures_gestures_testdata"
+ PREFIX "/"
+ FILES ${test_data})
diff --git a/tests/auto/qsensorgestures_gestures/mockcommon.cpp b/tests/auto/qsensorgestures_gestures/mockcommon.cpp
index e068a460..b11e4f67 100644
--- a/tests/auto/qsensorgestures_gestures/mockcommon.cpp
+++ b/tests/auto/qsensorgestures_gestures/mockcommon.cpp
@@ -61,21 +61,12 @@ void mockcommonPrivate::timerout()
bool mockcommonPrivate::setFile(const QString &filename)
{
- if (filename.isEmpty())
- return false;
-
- if (pFile.isOpen()) {
+ if (pFile.isOpen())
pFile.close();
- }
oldAccelTs = 0;
firstRun = true;
- pFile.setFileName(QCoreApplication::instance()->applicationDirPath() + "/" + filename);
- bool ok = pFile.open(QIODevice::ReadOnly);
- if (!ok) {
- pFile.setFileName(SRCDIR "/" + filename);
- ok = pFile.open(QIODevice::ReadOnly);
- }
- return ok;
+ pFile.setFileName(":/" + filename);
+ return pFile.open(QIODevice::ReadOnly);
}
bool mockcommonPrivate::parseData(const QString &line)