summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-18 12:32:13 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-22 09:26:57 +0100
commit0dd7bd0c7ab8383c5aa739e69a3e2bb317c4b19f (patch)
treedb9e2de7fd16ec62a7eb1eaedbe253920cc1c07a /tests/auto/corelib
parent0b16f425652c0e804ddac9cbca2d0063cfdad55e (diff)
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 <bogdan@kde.org>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp26
1 files changed, 26 insertions, 0 deletions
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");