diff options
Diffstat (limited to 'tests/auto/corelib')
24 files changed, 323 insertions, 47 deletions
diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a966f557f5..1b7f28bbfa 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -39,8 +39,12 @@ #include <private/qabstractanimation_p.h> -#ifdef Q_OS_WIN -static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution"; +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) +# define BAD_TIMER_RESOLUTION +#endif + +#ifdef BAD_TIMER_RESOLUTION +static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; #endif class TestablePauseAnimation : public QPauseAnimation @@ -140,17 +144,17 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != expectedLoopCount) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount); } @@ -169,41 +173,41 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation2.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Running); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, 2); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QTest::qWait(550); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 3); } @@ -232,9 +236,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); QVERIFY(pause.state() == QAbstractAnimation::Stopped); @@ -253,9 +257,9 @@ void tst_QPauseAnimation::pauseResume() animation.start(); QTRY_COMPARE(animation.state(), QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount < 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY2(animation.m_updateCurrentTimeCount >= 3, qPrintable( QString::fromLatin1("animation.m_updateCurrentTimeCount = %1").arg(animation.m_updateCurrentTimeCount))); @@ -408,39 +412,39 @@ void tst_QPauseAnimation::multipleSequentialGroups() // measure... QTest::qWait(group.totalDuration() + 500); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(group.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup3.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup4.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (pause5.m_updateCurrentTimeCount != 4) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(pause5.m_updateCurrentTimeCount, 4); } diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 749c7da789..140b349c64 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -40,6 +40,9 @@ class tst_qmessagehandler : public QObject { Q_OBJECT +public: + tst_qmessagehandler(); + public slots: void initTestCase(); @@ -92,6 +95,12 @@ void customMsgHandler(QtMsgType type, const char *msg) s_message = QString::fromLocal8Bit(msg); } +tst_qmessagehandler::tst_qmessagehandler() +{ + // ensure it's unset, otherwise we'll have trouble + qputenv("QT_MESSAGE_PATTERN", ""); +} + void tst_qmessagehandler::initTestCase() { m_appDir = QFINDTESTDATA("app"); @@ -756,6 +765,12 @@ void tst_qmessagehandler::qMessagePattern_data() << "A DEBUG qDebug " << "A qWarning "); + QTest::newRow("pid") << "%{pid}: %{message}" + << true << QList<QByteArray>(); // can't match anything, just test validity + QTest::newRow("threadid") << "ThreadId:%{threadid}: %{message}" + << true << (QList<QByteArray>() + << "ThreadId:0x"); + // This test won't work when midnight is too close... wait a bit while (QTime::currentTime() > QTime(23, 59, 30)) QTest::qWait(10000); @@ -811,6 +826,7 @@ void tst_qmessagehandler::qMessagePattern() process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( QString::fromLatin1("Could not start %1: %2").arg(appExe, process.errorString()))); + QByteArray pid = QByteArray::number(process.processId()); process.waitForFinished(); QByteArray output = process.readAllStandardError(); @@ -825,6 +841,8 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(output.contains(e)); } } + if (pattern.startsWith("%{pid}")) + QVERIFY2(output.startsWith('"' + pid), "PID: " + pid + "\noutput:\n" + output); #endif } 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"); diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro index 25d740f5b9..237e20685a 100644 --- a/tests/auto/corelib/json/json.pro +++ b/tests/auto/corelib/json/json.pro @@ -1,10 +1,11 @@ -TARGET = tst_qtjson +TARGET = tst_json QT = core testlib CONFIG -= app_bundle CONFIG += testcase CONFIG += parallel_test -TESTDATA += test.json test.bjson test3.json test2.json +!android:TESTDATA += test.json test.bjson test3.json test2.json + else:RESOURCES += json.qrc SOURCES += tst_qtjson.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/json/json.qrc b/tests/auto/corelib/json/json.qrc new file mode 100644 index 0000000000..eb122a1779 --- /dev/null +++ b/tests/auto/corelib/json/json.qrc @@ -0,0 +1,9 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>bom.json</file> + <file>test2.json</file> + <file>test3.json</file> + <file>test.json</file> + <file>test.bjson</file> +</qresource> +</RCC> |