diff options
Diffstat (limited to 'tests/auto/corelib/io')
20 files changed, 255 insertions, 11 deletions
diff --git a/tests/auto/corelib/io/qdir/android_testdata.qrc b/tests/auto/corelib/io/qdir/android_testdata.qrc new file mode 100644 index 0000000000..52cf4da330 --- /dev/null +++ b/tests/auto/corelib/io/qdir/android_testdata.qrc @@ -0,0 +1,44 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>tst_qdir.cpp</file> + <file>entrylist/file</file> + <file>entrylist/directory/dummy</file> + <file>searchdir/subdir1/picker.png</file> + <file>searchdir/subdir2/picker.png</file> + <file>testData/empty</file> + <file>testdir/dir/tmp/empty</file> + <file>testdir/dir/qdir.pro</file> + <file>testdir/dir/qrc_qdir.cpp</file> + <file>testdir/dir/tst_qdir.cpp</file> + <file>testdir/spaces/foo. bar</file> + <file>testdir/spaces/foo.bar</file> + <file>types/a</file> + <file>types/a.a</file> + <file>types/a.b</file> + <file>types/a.c</file> + <file>types/b</file> + <file>types/b.a</file> + <file>types/b.b</file> + <file>types/b.c</file> + <file>types/c</file> + <file>types/c.a</file> + <file>types/c.b</file> + <file>types/c.c</file> + <file>types/d/dummy</file> + <file>types/d.a/dummy</file> + <file>types/d.c/dummy</file> + <file>types/d.b/dummy</file> + <file>types/e/dummy</file> + <file>types/e.a/dummy</file> + <file>types/e.c/dummy</file> + <file>types/f/dummy</file> + <file>types/f.a/dummy</file> + <file>types/f.b/dummy</file> + <file>types/f.c/dummy</file> + <file>types/e.b/dummy</file> + <file>resources/entryList/file1.data</file> + <file>resources/entryList/file2.data</file> + <file>resources/entryList/file3.data</file> + <file>resources/entryList/file4.nothing</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index e2b25866df..d3e954bd32 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -6,3 +6,7 @@ RESOURCES += qdir.qrc TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 49e3264617..484130f163 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -214,8 +214,35 @@ private: Q_DECLARE_METATYPE(tst_QDir::UncHandling) tst_QDir::tst_QDir() +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + : m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) +#else : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) +#endif { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString resourceSourcePath = QStringLiteral(":/android_testdata/"); + QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); + while (it.hasNext()) { + it.next(); + + QFileInfo fileInfo = it.fileInfo(); + + if (!fileInfo.isDir()) { + QString destination = m_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())); + } + } + + } + + if (!QDir::setCurrent(m_dataPath)) + qWarning("Couldn't set current path to %s", qPrintable(m_dataPath)); +#endif } void tst_QDir::init() @@ -2028,6 +2055,8 @@ void tst_QDir::equalityOperator_data() //need a path in the root directory that is unlikely to be a symbolic link. #if defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QString pathinroot("/system/.."); #else QString pathinroot("/usr/.."); #endif 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"); diff --git a/tests/auto/corelib/io/qfileinfo/android_testdata.qrc b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc new file mode 100644 index 0000000000..ce545cc21c --- /dev/null +++ b/tests/auto/corelib/io/qfileinfo/android_testdata.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>resources/file1</file> + <file>resources/file1.ext1</file> + <file>resources/file1.ext1.ext2</file> + <file>tst_qfileinfo.cpp</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index 64d289bc3c..3fd58b4958 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -8,3 +8,7 @@ TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resour win32*:!wince*:!winrt:LIBS += -ladvapi32 -lnetapi32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 22d5da8e68..5b67fd2af5 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())); @@ -1137,7 +1160,11 @@ void tst_QFileInfo::fileTimes() QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); #elif defined(Q_OS_QNX) QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue); +#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + if (fileInfo.lastRead() <= beforeRead) + QEXPECT_FAIL("", "Android may use relatime or noatime on mounts", Continue); #endif + QVERIFY(fileInfo.lastRead() > beforeRead); QVERIFY(fileInfo.lastModified() > beforeWrite); QVERIFY(fileInfo.lastModified() < beforeRead); diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 4f648a62d6..0a952e9452 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -87,6 +87,10 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() m_tempDirPattern += QLatin1Char('/'); m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX"); #endif // QT_NO_FILESYSTEMWATCHER + +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); +#endif } #ifndef QT_NO_FILESYSTEMWATCHER diff --git a/tests/auto/corelib/io/qiodevice/android_testdata.qrc b/tests/auto/corelib/io/qiodevice/android_testdata.qrc new file mode 100644 index 0000000000..fa4b3d11da --- /dev/null +++ b/tests/auto/corelib/io/qiodevice/android_testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>tst_qiodevice.cpp</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qiodevice/qiodevice.pro b/tests/auto/corelib/io/qiodevice/qiodevice.pro index 9103ff2152..9fd70fb177 100644 --- a/tests/auto/corelib/io/qiodevice/qiodevice.pro +++ b/tests/auto/corelib/io/qiodevice/qiodevice.pro @@ -6,3 +6,8 @@ SOURCES = tst_qiodevice.cpp TESTDATA += tst_qiodevice.cpp MOC_DIR=tmp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index dec440a6d5..d94893c767 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -62,6 +62,10 @@ private slots: void tst_QIODevice::initTestCase() { +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() + || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); +#endif } // Testing get/set functions diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 1790676028..77bef94550 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -66,7 +66,9 @@ public: void tst_QLockFile::initTestCase() { -#ifdef QT_NO_PROCESS +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QSKIP("This test requires deploying and running external console applications"); +#elif defined(QT_NO_PROCESS) QSKIP("This test requires QProcess support"); #else // chdir to our testdata path and execute helper apps relative to that. diff --git a/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc new file mode 100644 index 0000000000..7563fb9630 --- /dev/null +++ b/tests/auto/corelib/io/qloggingregistry/android_testdata.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qtlogging.ini</file> + </qresource> +</RCC> diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index c6c4caace3..6be5fb1067 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -6,3 +6,8 @@ QT = core core-private testlib SOURCES += tst_qloggingregistry.cpp OTHER_FILES += qtlogging.ini + +android:!android-no-sdk: { + RESOURCES += \ + android_testdata.qrc +} 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); diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a1732a0a79..21e020404b 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -472,7 +472,7 @@ void tst_qstandardpaths::testAllWritableLocations() QString loc = QStandardPaths::writableLocation(location); if (loc.size() > 1) // workaround for unlikely case of locations that return '/' QCOMPARE(loc.endsWith(QLatin1Char('/')), false); - QVERIFY(loc.contains(QLatin1Char('/'))); + QVERIFY(loc.isEmpty() || loc.contains(QLatin1Char('/'))); QVERIFY(!loc.contains(QLatin1Char('\\'))); } diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 3e11ba0717..a68a1185b8 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -237,7 +237,11 @@ void tst_QTemporaryDir::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif // QTemporaryDir("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryDir dir("tempXXXXXX"); diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index b3fa47e586..a08a0ae777 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -269,7 +269,12 @@ void tst_QTemporaryFile::nonWritableCurrentDir() }; ChdirOnReturn cor(QDir::currentPath()); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) + QDir::setCurrent("/data"); +#else QDir::setCurrent("/home"); +#endif + // QTemporaryFile("tempXXXXXX") is probably a bad idea in any app // where the current dir could anything... QTemporaryFile file("tempXXXXXX"); |