diff options
Diffstat (limited to 'tests')
24 files changed, 180 insertions, 48 deletions
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 24592238bd..29717b3a1c 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -63,4 +63,5 @@ winrt: SUBDIRS -= \ qprocess \ qprocess-noapplication \ qprocessenvironment \ + qstorageinfo \ qwinoverlappedionotifier diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 52f6e13376..e448093062 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -65,7 +65,7 @@ public: , fd_(-1) , stream_(0) { - #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) + #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) && !defined(Q_OS_WINRT) maxSizeBits = 36; // 64 GiB #elif defined(Q_OS_MAC) // HFS+ does not support sparse files, so we limit file size for the test @@ -130,6 +130,9 @@ private: int fd_; FILE *stream_; + + QSharedPointer<QTemporaryDir> m_tempDir; + QString m_previousCurrent; }; /* @@ -224,6 +227,11 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) void tst_LargeFile::initTestCase() { + m_previousCurrent = QDir::currentPath(); + m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir); + QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory.")); + QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory")); + QFile file("qt_largefile.tmp"); QVERIFY( !file.exists() || file.remove() ); } @@ -235,6 +243,8 @@ void tst_LargeFile::cleanupTestCase() QFile file("qt_largefile.tmp"); QVERIFY( !file.exists() || file.remove() ); + + QDir::setCurrent(m_previousCurrent); } void tst_LargeFile::init() diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index 80b6304049..dba920d1f7 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -47,6 +47,7 @@ class tst_QAbstractFileEngine { Q_OBJECT public slots: + void initTestCase(); void cleanupTestCase(); private slots: @@ -59,6 +60,8 @@ private slots: void mounting(); private: QStringList filesForRemoval; + QSharedPointer<QTemporaryDir> m_currentDir; + QString m_previousCurrent; }; class ReferenceFileEngine @@ -558,6 +561,14 @@ class FileEngineHandler } }; +void tst_QAbstractFileEngine::initTestCase() +{ + m_previousCurrent = QDir::currentPath(); + m_currentDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir()); + QVERIFY2(!m_currentDir.isNull(), qPrintable("Could not create current directory.")); + QDir::setCurrent(m_currentDir->path()); +} + void tst_QAbstractFileEngine::cleanupTestCase() { bool failed = false; @@ -571,6 +582,8 @@ void tst_QAbstractFileEngine::cleanupTestCase() } QVERIFY(!failed); + + QDir::setCurrent(m_previousCurrent); } void tst_QAbstractFileEngine::customHandler() diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index ad463488ed..f5a546ebf1 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -45,6 +45,7 @@ public: void stream_data(int noOfElements); public slots: + void initTestCase(); void cleanupTestCase(); private slots: @@ -243,6 +244,10 @@ private: void readqint64(QDataStream *s); void readQIcon(QDataStream *s); void readQEasingCurve(QDataStream *s); + +private: + QSharedPointer<QTemporaryDir> m_tempDir; + QString m_previousCurrent; }; static int NColorRoles[] = { @@ -293,10 +298,20 @@ void tst_QDataStream::getSetCheck() QCOMPARE(QDataStream::ReadCorruptData, obj1.status()); } +void tst_QDataStream::initTestCase() +{ + m_previousCurrent = QDir::currentPath(); + m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir); + QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory.")); + QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory")); +} + void tst_QDataStream::cleanupTestCase() { QFile::remove(QLatin1String("qdatastream.out")); QFile::remove(QLatin1String("datastream.tmp")); + + QDir::setCurrent(m_previousCurrent); } static int dataIndex(const QString &tag) diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index 26bc60a731..e8f5d1079a 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -6,6 +6,8 @@ RESOURCES += qdir.qrc TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp +contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA + 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 7903176781..5046f5abf4 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -51,7 +51,7 @@ # include <sys/stat.h> #endif -#if defined(Q_OS_VXWORKS) +#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT) #define Q_NO_SYMLINKS #endif @@ -211,7 +211,12 @@ private slots: void cdBelowRoot(); private: +#ifdef BUILTIN_TESTDATA + QString m_dataPath; + QSharedPointer<QTemporaryDir> m_dataDir; +#else const QString m_dataPath; +#endif }; Q_DECLARE_METATYPE(tst_QDir::UncHandling) @@ -219,7 +224,7 @@ 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 +#elif !defined(BUILTIN_TESTDATA) : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) #endif { @@ -256,12 +261,23 @@ void tst_QDir::init() void tst_QDir::initTestCase() { +#ifdef BUILTIN_TESTDATA + m_dataDir = QEXTRACTTESTDATA("/"); + QVERIFY2(!m_dataDir.isNull(), qPrintable("Did not find testdata. Is this builtin?")); + m_dataPath = m_dataDir->path(); +#endif + QVERIFY2(!m_dataPath.isEmpty(), "test data not found"); } void tst_QDir::cleanupTestCase() { +#ifdef BUILTIN_TESTDATA + // We need to reset the current directory outside of QTemporaryDir for successful deletion + QDir::setCurrent(QCoreApplication::applicationDirPath()); +#else QDir(QDir::currentPath() + "/tmpdir").removeRecursively(); +#endif } // Testing get/set functions @@ -527,7 +543,7 @@ void tst_QDir::exists_data() QTest::newRow("simple dir") << (m_dataPath + "/resources") << true; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true; -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) && !defined(Q_OS_WINRT) const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; @@ -539,7 +555,7 @@ void tst_QDir::exists_data() QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false; QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false; #endif -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)) QTest::newRow("This drive should exist") << "C:/" << true; // find a non-existing drive and check if it does not exist #ifdef QT_BUILD_INTERNAL @@ -892,7 +908,7 @@ void tst_QDir::entryListSimple_data() QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2; #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); QTest::newRow("unc 1") << uncRoot << 2; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2; @@ -975,7 +991,6 @@ void tst_QDir::canonicalPath_data() QTest::newRow("relative") << "." << m_dataPath; QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData"; - #ifndef Q_OS_WIN QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData"; #else @@ -1174,7 +1189,7 @@ tst_QDir::cleanPath_data() QTest::newRow("data10") << "/:/" << "/:"; #endif #endif -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QTest::newRow("data11") << "//foo//bar" << "//foo/bar"; #endif QTest::newRow("data12") << "ab/a/" << "ab/a"; // Path item with length of 2 @@ -1186,11 +1201,13 @@ tst_QDir::cleanPath_data() QTest::newRow("data14") << "c://foo" << "c:/foo"; // Drive letters and unc path in one string +#ifndef Q_OS_WINRT #ifdef Q_OS_WIN QTest::newRow("data15") << "//c:/foo" << "//c:/foo"; #else QTest::newRow("data15") << "//c:/foo" << "/c:/foo"; #endif +#endif // !Q_OS_WINRT QTest::newRow("QTBUG-23892_0") << "foo/.." << "."; QTest::newRow("QTBUG-23892_1") << "foo/../" << "."; @@ -1309,7 +1326,7 @@ void tst_QDir::absoluteFilePath_data() QTest::newRow("2") << "/" << "passwd" << "/passwd"; QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path"; QTest::newRow("4") << "" << "" << QDir::currentPath(); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QTest::newRow("5") << "//machine" << "share" << "//machine/share"; #endif @@ -1333,7 +1350,7 @@ void tst_QDir::absolutePath_data() QTest::addColumn<QString>("expectedPath"); QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1"; -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)) QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1"; QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1"; QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1"; @@ -1401,10 +1418,12 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("27") << "C:" << "D:/" << "D:/"; QTest::newRow("28") << "C:/" << "D:" << "D:"; QTest::newRow("29") << "C:/" << "D:/" << "D:/"; +#ifndef Q_OS_WINRT QTest::newRow("30") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar"; QTest::newRow("31") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar"; QTest::newRow("32") << "//anotherHost/foo" << "bar" << "bar"; QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; +#endif // !Q_OS_WINRT #endif QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar"; @@ -1589,7 +1608,11 @@ void tst_QDir::homePath() qputenv("HOME", envHome); #elif defined(Q_OS_WIN) - if (strHome.length() > 3) // root dir = "c:/"; "//" is not really valid... + if (strHome.length() > 3 // root dir = "c:/"; "//" is not really valid... +#if defined(Q_OS_WINRT) + && strHome.length() > QDir::rootPath().length() +#endif + ) QVERIFY(!strHome.endsWith('/')); #endif @@ -2054,6 +2077,9 @@ void tst_QDir::drives() QVERIFY(list.count() >= 1); //system QLatin1Char systemdrive('c'); #endif +#if defined(Q_OS_WINRT) + QSKIP("WinRT has no concept of drives"); +#endif #if defined(Q_OS_WIN) QVERIFY(list.count() <= 26); bool foundsystem = false; @@ -2110,7 +2136,9 @@ void tst_QDir::equalityOperator_data() << true; //need a path in the root directory that is unlikely to be a symbolic link. -#if defined (Q_OS_WIN) +#if defined (Q_OS_WINRT) + QString pathinroot(QDir::rootPath() + QLatin1String("assets/..")); +#elif defined (Q_OS_WIN) QString pathinroot("c:/windows/.."); #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) QString pathinroot("/system/.."); @@ -2241,6 +2269,10 @@ void tst_QDir::cdBelowRoot() #define ROOT QString("/") #define DIR QString("/tmp") #define CD_INTO "tmp" +#elif defined (Q_OS_WINRT) +#define ROOT QDir::rootPath() +#define DIR QDir::rootPath() +#define CD_INTO QDir::rootPath() #else #define ROOT QString::fromLocal8Bit(qgetenv("SystemDrive"))+"/" #define DIR QString::fromLocal8Bit(qgetenv("SystemRoot")).replace('\\', '/') @@ -2256,6 +2288,9 @@ void tst_QDir::cdBelowRoot() if (::getuid() == 0) QSKIP("Running this test as root doesn't make sense"); #endif +#ifdef Q_OS_WINRT + QSKIP("WinRT has no concept of system root"); +#endif QDir dir(DIR); QVERIFY(!dir.cd("../..")); QCOMPARE(dir.path(), DIR); diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro index 2b50f97ac5..2d8dfba996 100644 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro @@ -5,6 +5,7 @@ SOURCES = tst_qdiriterator.cpp RESOURCES += qdiriterator.qrc TESTDATA += entrylist +contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index d928ddd998..9727ccb407 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -37,7 +37,7 @@ #include <QtCore/private/qfsfileengine_p.h> -#if defined(Q_OS_VXWORKS) +#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT) #define Q_NO_SYMLINKS #endif @@ -110,6 +110,10 @@ private slots: #ifndef Q_OS_WIN void hiddenDirs_hiddenFiles(); #endif +#ifdef BUILTIN_TESTDATA +private: + QSharedPointer<QTemporaryDir> m_dataDir; +#endif }; void tst_QDirIterator::initTestCase() @@ -136,6 +140,10 @@ void tst_QDirIterator::initTestCase() } testdata_dir += QStringLiteral("/entrylist"); +#elif defined(BUILTIN_TESTDATA) + m_dataDir = QEXTRACTTESTDATA("/"); + QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data")); + QString testdata_dir = m_dataDir->path(); #else // chdir into testdata directory, then find testdata by relative paths. @@ -212,6 +220,11 @@ void tst_QDirIterator::cleanupTestCase() Q_FOREACH(QString dirName, createdDirectories) currentDir.rmdir(dirName); + +#ifdef Q_OS_WINRT + QDir::setCurrent(QCoreApplication::applicationDirPath()); +#endif // Q_OS_WINRT + } void tst_QDirIterator::iterateRelativeDirectory_data() diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 14e37226e5..4362bace8c 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -61,7 +61,7 @@ #include <private/qfileinfo_p.h> #include "../../../../shared/filesystem.h" -#if defined(Q_OS_VXWORKS) +#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT) #define Q_NO_SYMLINKS #endif @@ -422,12 +422,12 @@ void tst_QFileInfo::isDir_data() QTest::newRow("broken link") << "brokenlink.lnk" << false; -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)) QTest::newRow("drive 1") << "c:" << true; QTest::newRow("drive 2") << "c:/" << true; //QTest::newRow("drive 2") << "t:s" << false; #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; @@ -464,7 +464,7 @@ void tst_QFileInfo::isRoot_data() QTest::newRow("simple dir") << m_resourcesDir << false; QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << false; -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)) QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 2") << "c:/" << true; QTest::newRow("drive 3") << "p:/" << false; @@ -508,7 +508,12 @@ void tst_QFileInfo::exists_data() QTest::newRow("data8") << (m_resourcesDir + "/*.ext1") << false; QTest::newRow("data9") << (m_resourcesDir + "/file?.ext1") << false; QTest::newRow("data10") << "." << true; + + // Skip for the WinRT case, as GetFileAttributesEx removes _any_ + // trailing whitespace and "." is a valid entry as seen in data10 +#ifndef Q_OS_WINRT QTest::newRow("data11") << ". " << false; +#endif QTest::newRow("empty") << "" << false; QTest::newRow("simple dir") << m_resourcesDir << true; @@ -549,7 +554,7 @@ void tst_QFileInfo::absolutePath_data() QTest::addColumn<QString>("filename"); QString drivePrefix; -#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)) drivePrefix = QDir::currentPath().left(2); QString nonCurrentDrivePrefix = drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:"); @@ -559,6 +564,8 @@ void tst_QFileInfo::absolutePath_data() QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "my.dll" << nonCurrentDrivePrefix + "/" << "my.dll"; +#elif defined(Q_OS_WINRT) + drivePrefix = QDir::currentPath().left(2); #endif QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1"; @@ -566,7 +573,7 @@ void tst_QFileInfo::absolutePath_data() QTest::newRow("3") << "/usr/local/bin/" << drivePrefix + "/usr/local/bin" << ""; QTest::newRow("/test") << "/test" << drivePrefix + "/" << "test"; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/" << "autoexec.bat"; QTest::newRow("c:autoexec.bat") << QDir::currentPath().left(2) + "autoexec.bat" << QDir::currentPath() @@ -730,7 +737,7 @@ void tst_QFileInfo::canonicalFilePath() } #endif -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD); PtrCreateSymbolicLink ptrCreateSymbolicLink = (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW"); @@ -826,7 +833,7 @@ void tst_QFileInfo::dir_data() QTest::newRow("absFilePath") << QDir::currentPath() + "/tmp.txt" << false << QDir::currentPath(); QTest::newRow("absFilePathAbsPath") << QDir::currentPath() + "/tmp.txt" << true << QDir::currentPath(); QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << true << ":/tst_qfileinfo/resources"; -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QTest::newRow("driveWithSlash") << "C:/file1.ext1.ext2" << true << "C:/"; QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath().left(2); #endif @@ -1017,7 +1024,7 @@ void tst_QFileInfo::size() void tst_QFileInfo::systemFiles() { -#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) +#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT) QSKIP("This is a Windows only test"); #endif QFileInfo fi("c:\\pagefile.sys"); @@ -1188,6 +1195,8 @@ void tst_QFileInfo::fileTimes() #endif #if defined(Q_OS_WINCE) QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); +#elif defined(Q_OS_WINRT) + QEXPECT_FAIL("", "WinRT does not allow timestamp handling change in the filesystem due to sandboxing", 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) @@ -1623,7 +1632,7 @@ void tst_QFileInfo::isWritable() QVERIFY(QFileInfo("tempfile.txt").isWritable()); tempfile.remove(); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #ifdef Q_OS_WINCE QFileInfo fi("\\Windows\\wince.nls"); #else diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/+winrt/test b/tests/auto/corelib/io/qfileselector/platforms/+windows/+winrt/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+windows/+winrt/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+winrt/test b/tests/auto/corelib/io/qfileselector/platforms/+winrt/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+winrt/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+winrt/test2 b/tests/auto/corelib/io/qfileselector/platforms/+winrt/test2 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+winrt/test2 diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index 47ace78528..ab7a4d7f23 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -23,6 +23,7 @@ <file>platforms/+unix/test</file> <file>platforms/+windows/+wince/test</file> <file>platforms/+windows/+winnt/test</file> + <file>platforms/+windows/+winrt/test</file> <file>platforms/+windows/test</file> <file>platforms/+android/test</file> <file>platforms/+ios/test</file> @@ -32,6 +33,7 @@ <file>platforms/+haiku/test</file> <file>platforms/+linux/test</file> <file>platforms/+wince/test</file> + <file>platforms/+winrt/test</file> <!-- platforms/test2: shallow selection for the deepest selector --> <file>platforms/test2</file> @@ -42,6 +44,7 @@ <file>platforms/+linux/test2</file> <file>platforms/+wince/test2</file> <file>platforms/+winnt/test2</file> + <file>platforms/+winrt/test2</file> <!-- platforms/test3: selection for the family only --> <file>platforms/test3</file> diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 0498f3958d..4c5ca1a7bb 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -94,7 +94,7 @@ void tst_QFileSelector::basicTest_data() expectedPlatform2File = QString(":/platforms/test2"); #else QString distributionName; -# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) +# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) || defined(Q_OS_WINRT) distributionName = QSysInfo::productType(); # endif foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) { diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index a0c136c886..2253173d08 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -38,6 +38,7 @@ class tst_QIODevice : public QObject private slots: void initTestCase(); + void cleanupTestCase(); void getSetCheck(); void constructing_QTcpSocket(); void constructing_QFile(); @@ -57,6 +58,10 @@ private slots: void transaction_data(); void transaction(); + +private: + QSharedPointer<QTemporaryDir> m_tempDir; + QString m_previousCurrent; }; void tst_QIODevice::initTestCase() @@ -65,6 +70,15 @@ void tst_QIODevice::initTestCase() QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists() || QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp"))); #endif + m_previousCurrent = QDir::currentPath(); + m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir); + QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory.")); + QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory")); +} + +void tst_QIODevice::cleanupTestCase() +{ + QDir::setCurrent(m_previousCurrent); } // Testing get/set functions diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index 6be5fb1067..a311173c0e 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -6,6 +6,7 @@ QT = core core-private testlib SOURCES += tst_qloggingregistry.cpp OTHER_FILES += qtlogging.ini +TESTDATA += qtlogging.ini android:!android-no-sdk: { RESOURCES += \ diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 14b139632c..5b18ab9d68 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -424,6 +424,8 @@ void tst_qstandardpaths::testFindExecutable() void tst_qstandardpaths::testFindExecutableLinkToDirectory() { + // WinRT has no link support +#ifndef Q_OS_WINRT // link to directory const QString target = QDir::tempPath() + QDir::separator() + QLatin1String("link.lnk"); QFile::remove(target); @@ -431,15 +433,16 @@ void tst_qstandardpaths::testFindExecutableLinkToDirectory() QVERIFY(appFile.link(target)); QVERIFY(QStandardPaths::findExecutable(target).isEmpty()); QFile::remove(target); +#endif } void tst_qstandardpaths::testRuntimeDirectory() { +#ifdef Q_XDG_PLATFORM const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); QVERIFY(!runtimeDir.isEmpty()); // Check that it can automatically fix permissions -#ifdef Q_XDG_PLATFORM QFile file(runtimeDir); const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser; const QFile::Permissions additionalPerms = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner; diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index fe36ab4c9c..410f512a77 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -67,11 +67,14 @@ private slots: void QTBUG43352_failedSetPermissions(); -public: +private: + QString m_previousCurrent; }; void tst_QTemporaryDir::initTestCase() { + m_previousCurrent = QDir::currentPath(); + QDir::setCurrent(QDir::tempPath()); QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QCoreApplication::setApplicationName("tst_qtemporarydir"); } @@ -79,6 +82,8 @@ void tst_QTemporaryDir::initTestCase() void tst_QTemporaryDir::cleanupTestCase() { QVERIFY(QDir().rmdir("test-XXXXXX")); + + QDir::setCurrent(m_previousCurrent); } void tst_QTemporaryDir::construction() diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index a41f1aa06f..72dedf8be7 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -80,10 +80,15 @@ private slots: void QTBUG_4796_data(); void QTBUG_4796(); void guaranteeUnique(); +private: + QString m_previousCurrent; }; void tst_QTemporaryFile::initTestCase() { + m_previousCurrent = QDir::currentPath(); + QDir::setCurrent(QDir::tempPath()); + // For QTBUG_4796 QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QCoreApplication::setApplicationName("tst_qtemporaryfile"); @@ -111,6 +116,8 @@ void tst_QTemporaryFile::cleanupTestCase() { // From QTBUG_4796 QVERIFY(QDir().rmdir("test-XXXXXX")); + + QDir::setCurrent(m_previousCurrent); } void tst_QTemporaryFile::construction() @@ -673,8 +680,11 @@ void tst_QTemporaryFile::createNativeFile_data() const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); #endif - QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); - QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); + // File might not exist locally in case of sandboxing or remote testing + if (!nativeFilePath.startsWith(QLatin1String(":/"))) { + QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); + QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); + } QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test"); QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test"); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 38fd33526b..470d5b6434 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -3009,15 +3009,21 @@ void tst_QUrl::fromUserInputWithCwd_data() it.next(); QUrl url = QUrl::fromLocalFile(it.filePath()); if (it.fileName() == QLatin1String(".")) { - url = QUrl::fromLocalFile(QDir::currentPath()); // fromUserInput cleans the path + url = QUrl::fromLocalFile(QDir::currentPath() +#ifdef Q_OS_WINRT + + QLatin1Char('/') +#endif + ); // fromUserInput cleans the path } QTest::newRow(("file-" + QByteArray::number(c++)).constData()) << it.fileName() << QDir::currentPath() << url << url; } +#ifndef Q_OS_WINRT // WinRT cannot cd outside current / sandbox QDir parent = QDir::current(); QVERIFY(parent.cdUp()); QUrl parentUrl = QUrl::fromLocalFile(parent.path()); QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl; +#endif QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting"); QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org"); diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 2153efbd7f..9cadf60afb 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -798,16 +798,18 @@ void tst_QDateTime::toString_textDate_data() QTest::addColumn<QDateTime>("datetime"); QTest::addColumn<QString>("expected"); + QString wednesdayJanuary = QDate::shortDayName(3) + ' ' + QDate::shortMonthName(1); + QTest::newRow("localtime") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::LocalTime) - << QString("Wed Jan 2 01:02:03 2013"); + << wednesdayJanuary + QString(" 2 01:02:03 2013"); QTest::newRow("utc") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::UTC) - << QString("Wed Jan 2 01:02:03 2013 GMT"); + << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT"); QTest::newRow("offset+") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC, 10 * 60 * 60) - << QString("Wed Jan 2 01:02:03 2013 GMT+1000"); + << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT+1000"); QTest::newRow("offset-") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC, -10 * 60 * 60) - << QString("Wed Jan 2 01:02:03 2013 GMT-1000"); + << wednesdayJanuary + QString(" 2 01:02:03 2013 GMT-1000"); QTest::newRow("invalid") << QDateTime() << QString(""); } @@ -817,9 +819,6 @@ void tst_QDateTime::toString_textDate() QFETCH(QDateTime, datetime); QFETCH(QString, expected); - QLocale oldLocale; - QLocale::setDefault(QLocale("en_US")); - QString result = datetime.toString(Qt::TextDate); QCOMPARE(result, expected); @@ -829,8 +828,6 @@ void tst_QDateTime::toString_textDate() QCOMPARE(resultDatetime.time(), datetime.time()); QCOMPARE(resultDatetime.timeSpec(), datetime.timeSpec()); QCOMPARE(resultDatetime.utcOffset(), datetime.utcOffset()); - - QLocale::setDefault(oldLocale); } void tst_QDateTime::toString_rfcDate_data() diff --git a/tests/auto/gui/text/qtextcursor/qtextcursor.pro b/tests/auto/gui/text/qtextcursor/qtextcursor.pro index bae85d9c37..1660ecf35d 100644 --- a/tests/auto/gui/text/qtextcursor/qtextcursor.pro +++ b/tests/auto/gui/text/qtextcursor/qtextcursor.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qtextcursor SOURCES += tst_qtextcursor.cpp -QT += testlib +QT += core-private gui-private testlib diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp index d4bd9c26db..d2c4adb888 100644 --- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp @@ -29,7 +29,6 @@ #include <QtTest/QtTest> - #include <qtextdocument.h> #include <qtexttable.h> #include <qvariant.h> @@ -40,6 +39,8 @@ #include <qtextobject.h> #include <qdebug.h> +#include <private/qtextcursor_p.h> + QT_FORWARD_DECLARE_CLASS(QTextDocument) class tst_QTextCursor : public QObject @@ -1278,7 +1279,7 @@ void tst_QTextCursor::anchorInitialized1() void tst_QTextCursor::anchorInitialized2() { cursor.insertBlock(); - cursor = QTextCursor(cursor.block().docHandle(), 1); + cursor = QTextCursorPrivate::fromPosition(cursor.block().docHandle(), 1); QCOMPARE(cursor.position(), 1); QCOMPARE(cursor.anchor(), 1); QCOMPARE(cursor.selectionStart(), 1); diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index 3beb1b1741..594b791938 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -233,13 +233,6 @@ void tst_QNetworkInterface::interfaceFromXXX() // but only for IPv4 (there is no such thing as broadcast in IPv6) if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) { QVERIFY(!entry.broadcast().isNull()); - - // verify that the broadcast address is correct - quint32 ip = entry.ip().toIPv4Address(); - quint32 mask = entry.netmask().toIPv4Address(); - quint32 bcast = entry.broadcast().toIPv4Address(); - - QCOMPARE(bcast, ip | ~mask); } } |