From 0dd7bd0c7ab8383c5aa739e69a3e2bb317c4b19f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 12:32:13 +0100 Subject: Android: Fix QDirIterator tests This test requires that the resources are also available in the file system. Since it's not possible to deploy directly to the file system using Android, we extract the files on startup instead. Change-Id: I1d1fe7d62c4c618a89713e3a7d1903e42bfb10b8 Reviewed-by: BogDan Vatra --- .../corelib/io/qdiriterator/tst_qdiriterator.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index fa6a1978ca..cdece2f8c7 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -119,8 +119,34 @@ private slots: void tst_QDirIterator::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString testdata_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + QString resourceSourcePath = QStringLiteral(":/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = testdata_dir + QLatin1Char('/') + fileInfo.filePath().mid(resourceSourcePath.length()); + QFileInfo destinationFileInfo(destination); + if (!destinationFileInfo.exists()) { + QDir().mkpath(destinationFileInfo.path()); + if (!QFile::copy(fileInfo.filePath(), destination)) + qWarning("Failed to copy %s", qPrintable(fileInfo.filePath())); + } + } + + } + + testdata_dir += QStringLiteral("/entrylist"); +#else + // chdir into testdata directory, then find testdata by relative paths. QString testdata_dir = QFileInfo(QFINDTESTDATA("entrylist")).absolutePath(); +#endif + QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); QFile::remove("entrylist/entrylist1.lnk"); -- cgit v1.2.3