summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-18 13:05:22 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-22 09:27:27 +0100
commit5681ae74e35b861b03a51cc5f9dbcbadef45b24c (patch)
tree8139bd82cf026afe6cd8a6600eff5387d2298d1c /tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
parent0dd7bd0c7ab8383c5aa739e69a3e2bb317c4b19f (diff)
Android: Fix QFileInfo tests
Since there's no way to deploy files directly to the file file system on Android, we put them in a qrc file and extract them on startup. Change-Id: I6a42aa5e0372bfd9fb2f7ccfea964c9c3c2e45d8 Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp')
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 22d5da8e68..d187133674 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -272,9 +272,32 @@ private:
void tst_QFileInfo::initTestCase()
{
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ QString dataPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ QString resourceSourcePath = QStringLiteral(":/android_testdata");
+ QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ it.next();
+
+ QFileInfo fileInfo = it.fileInfo();
+ if (!fileInfo.isDir()) {
+ QString destination = dataPath + 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()));
+ }
+ }
+ }
+ m_sourceFile = dataPath + QStringLiteral("/tst_qfileinfo.cpp");
+ m_resourcesDir = dataPath + QStringLiteral("/resources");
+#else
m_sourceFile = QFINDTESTDATA("tst_qfileinfo.cpp");
- QVERIFY(!m_sourceFile.isEmpty());
m_resourcesDir = QFINDTESTDATA("resources");
+#endif
+
+ QVERIFY(!m_sourceFile.isEmpty());
QVERIFY(!m_resourcesDir.isEmpty());
QVERIFY(m_dir.isValid());
QVERIFY(QDir::setCurrent(m_dir.path()));