aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-04-24 12:46:59 +0200
committerMitch Curtis <mitch.curtis@qt.io>2019-04-24 12:23:50 +0000
commit5ca18a3f21083151b771f0efa2a2605f183c8166 (patch)
tree9ba2ed6889d1d117fbb33cea09db151d00bbb29b /tests/auto
parentb587e4186497b1f65c5499b2b22c37babb305a09 (diff)
Use resource path for test data on Android and iOS
qtbase/mkspecs/features/testcase.prf already generates a .qrc file containing the files in TESTDATA, so instead of trying to copy QML files to the device, we can just use the existing resources. This fixes the following failure, which affects all tests using util.pri: FAIL! : tst_cursor::initTestCase() 'QDir::setCurrent(m_directory)' returned FALSE. (Could not chdir to :/) Change-Id: I1fd7449437be045a7230a7679e24252cdf9c0ccc Fixes: QTBUG-73604 Fixes: QTBUG-73606 Fixes: QTBUG-73607 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/shared/util.cpp7
-rw-r--r--tests/auto/shared/util.pri6
2 files changed, 10 insertions, 3 deletions
diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp
index e9e58993..2f6b7f54 100644
--- a/tests/auto/shared/util.cpp
+++ b/tests/auto/shared/util.cpp
@@ -53,7 +53,9 @@ QQmlDataTest::QQmlDataTest() :
m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)),
#endif
- m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
+ m_dataDirectoryUrl(m_dataDirectory.startsWith(QLatin1Char(':'))
+ ? QUrl(QLatin1String("qrc") + m_dataDirectory)
+ : QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
{
m_instance = this;
}
@@ -67,7 +69,8 @@ void QQmlDataTest::initTestCase()
{
QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found");
m_directory = QFileInfo(m_dataDirectory).absolutePath();
- QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
+ if (m_dataDirectoryUrl.scheme() != QLatin1String("qrc"))
+ QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
}
QString QQmlDataTest::testFile(const QString &fileName) const
diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri
index 16f37f8a..99607a66 100644
--- a/tests/auto/shared/util.pri
+++ b/tests/auto/shared/util.pri
@@ -6,5 +6,9 @@ HEADERS += $$PWD/visualtestutil.h \
SOURCES += $$PWD/visualtestutil.cpp \
$$PWD/util.cpp
-DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
+android|ios {
+ DEFINES += QT_QMLTEST_DATADIR=\\\":/data\\\"
+} else {
+ DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
+}
DEFINES += QQC2_IMPORT_PATH=\\\"$$QQC2_SOURCE_TREE/src/imports\\\"