summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qresourceengine
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-19 10:36:46 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-19 16:00:41 +0100
commit0fb839ac62fe9feb8700783270d03f1e9ccb3914 (patch)
tree8abfbd0261335341437a1d08cadca18fd2782921 /tests/auto/corelib/io/qresourceengine
parenta07120d496c43d45792dc5ca92d93eea37f32cec (diff)
Android: Fix QResourceEngine tests
The test expects all the files to reside in the file system, both for loading the runtime resources and for comparisons. Since we can't deploy directly to the file system on Android, we go via qrc and extract the files on startup instead. Change-Id: I17ff8985cb17dbfc45f0fb692ca46558bb5c5cdc Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'tests/auto/corelib/io/qresourceengine')
-rw-r--r--tests/auto/corelib/io/qresourceengine/android_testdata.qrc21
-rw-r--r--tests/auto/corelib/io/qresourceengine/qresourceengine.pro4
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp54
3 files changed, 71 insertions, 8 deletions
diff --git a/tests/auto/corelib/io/qresourceengine/android_testdata.qrc b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc
new file mode 100644
index 0000000000..ad3389ac20
--- /dev/null
+++ b/tests/auto/corelib/io/qresourceengine/android_testdata.qrc
@@ -0,0 +1,21 @@
+<RCC>
+ <qresource prefix="/android_testdata">
+ <file>runtime_resource.rcc</file>
+ <file>parentdir.txt</file>
+ <file>testqrc/blahblah.txt</file>
+ <file>testqrc/currentdir.txt</file>
+ <file>testqrc/currentdir2.txt</file>
+ <file>testqrc/search_file.txt</file>
+ <file>testqrc/aliasdir/aliasdir.txt</file>
+ <file>testqrc/aliasdir/compressme.txt</file>
+ <file>testqrc/otherdir/otherdir.txt</file>
+ <file>testqrc/searchpath1/search_file.txt</file>
+ <file>testqrc/searchpath2/search_file.txt</file>
+ <file>testqrc/subdir/subdir.txt</file>
+ <file>testqrc/test/test/test2.txt</file>
+ <file>testqrc/test/test/test1.txt</file>
+ <file>testqrc/test/german.txt</file>
+ <file>testqrc/test/testdir.txt</file>
+ <file>testqrc/test/testdir2.txt</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
index b7606eb3fc..92d0952b89 100644
--- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
+++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
@@ -16,3 +16,7 @@ TESTDATA += \
testqrc/*
GENERATED_TESTDATA = $${runtime_resource.target}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+android:!android-no-sdk {
+ RESOURCES += android_testdata.qrc
+}
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index 20a5fa2786..5f8b79d2fc 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -40,7 +40,13 @@ class tst_QResourceEngine: public QObject
Q_OBJECT
public:
- tst_QResourceEngine() : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) {}
+ tst_QResourceEngine()
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ : m_runtimeResourceRcc(QFileInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/runtime_resource.rcc")).absoluteFilePath())
+#else
+ : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc"))
+#endif
+ {}
private slots:
void initTestCase();
@@ -62,6 +68,29 @@ private:
void tst_QResourceEngine::initTestCase()
{
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ QString sourcePath(QStringLiteral(":/android_testdata/"));
+ QString dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
+
+ QDirIterator it(sourcePath, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ it.next();
+
+ QFileInfo fileInfo = it.fileInfo();
+ if (!fileInfo.isDir()) {
+ QString destination(dataPath + QLatin1Char('/') + fileInfo.filePath().mid(sourcePath.length()));
+ QFileInfo destinationFileInfo(destination);
+ if (!destinationFileInfo.exists()) {
+ QVERIFY(QDir().mkpath(destinationFileInfo.path()));
+ QVERIFY(QFile::copy(fileInfo.filePath(), destination));
+ QVERIFY(QFileInfo(destination).exists());
+ }
+ }
+ }
+
+ QVERIFY(QDir::setCurrent(dataPath));
+#endif
+
QVERIFY(!m_runtimeResourceRcc.isEmpty());
QVERIFY(QResource::registerResource(m_runtimeResourceRcc));
QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/"));
@@ -85,16 +114,25 @@ void tst_QResourceEngine::checkStructure_data()
QFileInfo info;
+ QStringList rootContents;
+ rootContents << QLatin1String("aliasdir")
+ << QLatin1String("otherdir")
+ << QLatin1String("qt-project.org")
+ << QLatin1String("runtime_resource")
+ << QLatin1String("searchpath1")
+ << QLatin1String("searchpath2")
+ << QLatin1String("secondary_root")
+ << QLatin1String("test")
+ << QLatin1String("withoutslashes");
+
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+ rootContents.insert(1, QLatin1String("android_testdata"));
+#endif
+
QTest::newRow("root dir") << QString(":/")
<< QString()
<< (QStringList() << "search_file.txt")
- << (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir")
- << QLatin1String("qt-project.org")
- << QLatin1String("runtime_resource")
- << QLatin1String("searchpath1") << QLatin1String("searchpath2")
- << QLatin1String("secondary_root")
- << QLatin1String("test")
- << QLatin1String("withoutslashes"))
+ << rootContents
<< QLocale::c()
<< qlonglong(0);