summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-04-24 11:29:18 +0200
committerMitch Curtis <mitch.curtis@qt.io>2019-04-24 12:07:27 +0000
commit0e039c17ccb97071fd4210ac958a5e9b999c44f9 (patch)
tree703bc0a497fa28ccbf9f4e585eebe3b3b1dff422 /tests
parent2cd99e2b69779c12309dd454584aa9546029323e (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: I/QTestLib( 7143): FAIL! : tst_qquickapplication::initTestCase() 'QDir::setCurrent(m_directory)' returned FALSE. (Could not chdir to :/) Change-Id: Iddfd227c402dbe80aeaa9742a52690d3d8049e46 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-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 189398f0c2..96876428f6 100644
--- a/tests/auto/shared/util.cpp
+++ b/tests/auto/shared/util.cpp
@@ -40,7 +40,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;
}
@@ -54,7 +56,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 a05af4773d..b54897ac2c 100644
--- a/tests/auto/shared/util.pri
+++ b/tests/auto/shared/util.pri
@@ -3,4 +3,8 @@ INCLUDEPATH += $$PWD
HEADERS += $$PWD/util.h
SOURCES += $$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\\\"
+}