diff options
Diffstat (limited to 'tests/auto/corelib')
24 files changed, 276 insertions, 46 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp b/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp index 55c831bd35..09c3ac3c09 100644 --- a/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/echo/main.cpp @@ -47,8 +47,7 @@ int main(int argc, char **argv) { - static char lc_all[] = "LC_ALL=C"; - putenv(lc_all); + qputenv("LC_ALL", "C"); QCoreApplication app(argc, argv); QString string(QChar(0x410)); diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 20f99e9191..36e01a0ccd 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -44,6 +44,7 @@ #include <QtGlobal> #include <math.h> +#include <float.h> class tst_QNumeric: public QObject { @@ -53,6 +54,10 @@ private slots: void fuzzyCompare_data(); void fuzzyCompare(); void qNan(); + void floatDistance_data(); + void floatDistance(); + void floatDistance_double_data(); + void floatDistance_double(); }; void tst_QNumeric::fuzzyCompare_data() @@ -121,5 +126,93 @@ void tst_QNumeric::qNan() QVERIFY(qFuzzyCompare(1/inf, 0.0)); } +void tst_QNumeric::floatDistance_data() +{ + QTest::addColumn<float>("val1"); + QTest::addColumn<float>("val2"); + QTest::addColumn<quint32>("expectedDistance"); + + // exponent: 8 bits + // mantissa: 23 bits + const quint32 number_of_denormals = (1 << 23) - 1; // Set to 0 if denormals are not included + + quint32 _0_to_1 = quint32((1 << 23) * 126 + 1 + number_of_denormals); // We need +1 to include the 0 + quint32 _1_to_2 = quint32(1 << 23); + + // We don't need +1 because FLT_MAX has all bits set in the mantissa. (Thus mantissa + // have not wrapped back to 0, which would be the case for 1 in _0_to_1 + quint32 _0_to_FLT_MAX = quint32((1 << 23) * 254) + number_of_denormals; + + quint32 _0_to_FLT_MIN = 1 + number_of_denormals; + QTest::newRow("[0,FLT_MIN]") << 0.F << FLT_MIN << _0_to_FLT_MIN; + QTest::newRow("[0,FLT_MAX]") << 0.F << FLT_MAX << _0_to_FLT_MAX; + QTest::newRow("[1,1.5]") << 1.0F << 1.5F << quint32(1 << 22); + QTest::newRow("[0,1]") << 0.F << 1.0F << _0_to_1; + QTest::newRow("[0.5,1]") << 0.5F << 1.0F << quint32(1 << 23); + QTest::newRow("[1,2]") << 1.F << 2.0F << _1_to_2; + QTest::newRow("[-1,+1]") << -1.F << +1.0F << 2 * _0_to_1; + QTest::newRow("[-1,0]") << -1.F << 0.0F << _0_to_1; + QTest::newRow("[-1,FLT_MAX]") << -1.F << FLT_MAX << _0_to_1 + _0_to_FLT_MAX; + QTest::newRow("[-2,-1") << -2.F << -1.F << _1_to_2; + QTest::newRow("[-1,-2") << -1.F << -2.F << _1_to_2; + QTest::newRow("[FLT_MIN,FLT_MAX]") << FLT_MIN << FLT_MAX << _0_to_FLT_MAX - _0_to_FLT_MIN; + QTest::newRow("[-FLT_MAX,FLT_MAX]") << -FLT_MAX << FLT_MAX << (2*_0_to_FLT_MAX); + float denormal = FLT_MIN; + denormal/=2.0F; + QTest::newRow("denormal") << 0.F << denormal << _0_to_FLT_MIN/2; +} + +void tst_QNumeric::floatDistance() +{ + QFETCH(float, val1); + QFETCH(float, val2); + QFETCH(quint32, expectedDistance); + QCOMPARE(qFloatDistance(val1, val2), expectedDistance); +} + +void tst_QNumeric::floatDistance_double_data() +{ + QTest::addColumn<double>("val1"); + QTest::addColumn<double>("val2"); + QTest::addColumn<quint64>("expectedDistance"); + + // exponent: 11 bits + // mantissa: 52 bits + const quint64 number_of_denormals = (Q_UINT64_C(1) << 52) - 1; // Set to 0 if denormals are not included + + quint64 _0_to_1 = (Q_UINT64_C(1) << 52) * ((1 << (11-1)) - 2) + 1 + number_of_denormals; // We need +1 to include the 0 + quint64 _1_to_2 = Q_UINT64_C(1) << 52; + + // We don't need +1 because DBL_MAX has all bits set in the mantissa. (Thus mantissa + // have not wrapped back to 0, which would be the case for 1 in _0_to_1 + quint64 _0_to_DBL_MAX = quint64((Q_UINT64_C(1) << 52) * ((1 << 11) - 2)) + number_of_denormals; + + quint64 _0_to_DBL_MIN = 1 + number_of_denormals; + QTest::newRow("[0,DBL_MIN]") << 0.0 << DBL_MIN << _0_to_DBL_MIN; + QTest::newRow("[0,DBL_MAX]") << 0.0 << DBL_MAX << _0_to_DBL_MAX; + QTest::newRow("[1,1.5]") << 1.0 << 1.5 << (Q_UINT64_C(1) << 51); + QTest::newRow("[0,1]") << 0.0 << 1.0 << _0_to_1; + QTest::newRow("[0.5,1]") << 0.5 << 1.0 << (Q_UINT64_C(1) << 52); + QTest::newRow("[1,2]") << 1.0 << 2.0 << _1_to_2; + QTest::newRow("[-1,+1]") << -1.0 << +1.0 << 2 * _0_to_1; + QTest::newRow("[-1,0]") << -1.0 << 0.0 << _0_to_1; + QTest::newRow("[-1,DBL_MAX]") << -1.0 << DBL_MAX << _0_to_1 + _0_to_DBL_MAX; + QTest::newRow("[-2,-1") << -2.0 << -1.0 << _1_to_2; + QTest::newRow("[-1,-2") << -1.0 << -2.0 << _1_to_2; + QTest::newRow("[DBL_MIN,DBL_MAX]") << DBL_MIN << DBL_MAX << _0_to_DBL_MAX - _0_to_DBL_MIN; + QTest::newRow("[-DBL_MAX,DBL_MAX]") << -DBL_MAX << DBL_MAX << (2*_0_to_DBL_MAX); + double denormal = DBL_MIN; + denormal/=2.0; + QTest::newRow("denormal") << 0.0 << denormal << _0_to_DBL_MIN/2; +} + +void tst_QNumeric::floatDistance_double() +{ + QFETCH(double, val1); + QFETCH(double, val2); + QFETCH(quint64, expectedDistance); + QCOMPARE(qFloatDistance(val1, val2), expectedDistance); +} + QTEST_APPLESS_MAIN(tst_QNumeric) #include "tst_qnumeric.moc" diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index ab66323d3b..259463f976 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -43,7 +43,6 @@ SUBDIRS=\ qsettings !qtHaveModule(network): SUBDIRS -= \ - qfile \ qiodevice \ qprocess \ qtextstream @@ -56,3 +55,9 @@ SUBDIRS=\ win32:!contains(QT_CONFIG, private_tests): SUBDIRS -= \ qfilesystementry + +winrt: SUBDIRS -= \ + qprocess \ + qprocess-noapplication \ + qprocessenvironment \ + qwinoverlappedionotifier diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index bc6922b4e9..03863e9943 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -1,7 +1,10 @@ CONFIG += testcase CONFIG += parallel_test CONFIG -= app_bundle debug_and_release_target -QT = core-private core network testlib +QT = core-private core testlib +qtHaveModule(network): QT += network +else: DEFINES += QT_NO_NETWORK + TARGET = ../tst_qfile SOURCES = ../tst_qfile.cpp wince*: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp @@ -13,5 +16,5 @@ TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ ../Makefile ../forCopying.txt ../forRenaming.txt \ ../resources/file1.ext1 -win32: LIBS+=-lole32 -luuid +win32:!winrt: LIBS+=-lole32 -luuid DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 2b029203e9..77ac4bcd86 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -59,7 +59,7 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; QT_END_NAMESPACE #endif -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(QT_NO_NETWORK) #include <QHostInfo> #endif #include <QProcess> @@ -527,7 +527,7 @@ void tst_QFile::open_data() << false << QFile::OpenError; QTest::newRow("noreadfile") << QString::fromLatin1(noReadFile) << int(QIODevice::ReadOnly) << false << QFile::OpenError; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) //opening devices requires administrative privileges (and elevation). HANDLE hTest = CreateFile(_T("\\\\.\\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hTest != INVALID_HANDLE_VALUE) { @@ -1057,7 +1057,7 @@ void tst_QFile::ungetChar() QCOMPARE(buf[2], '4'); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) QString driveLetters() { wchar_t volumeName[MAX_PATH]; @@ -1094,7 +1094,7 @@ void tst_QFile::invalidFile_data() #if !defined(Q_OS_WIN) QTest::newRow( "x11" ) << QString( "qwe//" ); #else -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); #endif QTest::newRow( "colon3" ) << QString( ":failinvalid" ); @@ -1338,10 +1338,12 @@ void tst_QFile::copyFallback() #ifdef Q_OS_WIN #include <objbase.h> +#ifndef Q_OS_WINPHONE #include <shlobj.h> #endif +#endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) static QString getWorkingDirectoryForLink(const QString &linkFileName) { bool neededCoInit = false; @@ -1400,7 +1402,7 @@ void tst_QFile::link() QCOMPARE(QFile::symLinkTarget("myLink.lnk"), referenceTarget); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); QCOMPARE(QDir::fromNativeSeparators(wd), QDir::cleanPath(info1.absolutePath())); #endif @@ -2243,7 +2245,7 @@ void tst_QFile::writeLargeDataBlock_data() QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd; QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(QT_NO_NETWORK) // Some semi-randomness to avoid collisions. QTest::newRow("unc file") << QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt") @@ -2690,8 +2692,12 @@ void tst_QFile::nativeHandleLeaks() } #ifdef Q_OS_WIN +# ifndef Q_OS_WINRT handle1 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +# else + handle1 = ::CreateFile2(L"qt_file.tmp", GENERIC_READ, 0, OPEN_ALWAYS, NULL); +# endif QVERIFY( INVALID_HANDLE_VALUE != handle1 ); QVERIFY( ::CloseHandle(handle1) ); #endif @@ -2705,8 +2711,12 @@ void tst_QFile::nativeHandleLeaks() } #ifdef Q_OS_WIN +# ifndef Q_OS_WINRT handle2 = ::CreateFileA("qt_file.tmp", GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +# else + handle2 = ::CreateFile2(L"qt_file.tmp", GENERIC_READ, 0, OPEN_ALWAYS, NULL); +# endif QVERIFY( INVALID_HANDLE_VALUE != handle2 ); QVERIFY( ::CloseHandle(handle2) ); #endif diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index c4b37a8847..64d289bc3c 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -6,5 +6,5 @@ RESOURCES += qfileinfo.qrc TESTDATA += qfileinfo.qrc qfileinfo.pro tst_qfileinfo.cpp resources/file1 resources/file1.ext1 resources/file1.ext1.ext2 -win32*:!wince*:LIBS += -ladvapi32 -lnetapi32 +win32*:!wince*:!winrt:LIBS += -ladvapi32 -lnetapi32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index d2171cc64a..74667a951f 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -62,7 +62,7 @@ #ifdef Q_OS_WIN #include <qt_windows.h> #include <qlibrary.h> -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #include <lm.h> #endif #endif @@ -176,7 +176,7 @@ private slots: void refresh(); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) void ntfsJunctionPointsAndSymlinks_data(); void ntfsJunctionPointsAndSymlinks(); void brokenShortcut(); @@ -193,7 +193,7 @@ private slots: void detachingOperations(); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) void owner(); #endif void group(); @@ -1058,7 +1058,7 @@ void tst_QFileInfo::fileTimes() //In Vista the last-access timestamp is not updated when the file is accessed/touched (by default). //To enable this the HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisableLastAccessUpdate //is set to 0, in the test machine. -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) HKEY key; if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\FileSystem", 0, KEY_READ, &key)) { @@ -1085,8 +1085,8 @@ void tst_QFileInfo::fileTimes() void tst_QFileInfo::fileTimes_oldFile() { - // This is not supported on WinCE -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + // This is not supported on WinCE or WinRT +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) // All files are opened in share mode (both read and write). DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; @@ -1329,7 +1329,7 @@ void tst_QFileInfo::refresh() QCOMPARE(info2.size(), info.size()); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() { QTest::addColumn<QString>("path"); @@ -1680,7 +1680,7 @@ void tst_QFileInfo::detachingOperations() QVERIFY(!info1.caching()); } -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if defined (Q_OS_WIN) BOOL IsUserAdmin() { diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index fda6519d82..b681cec802 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -55,6 +55,7 @@ class tst_QFileSystemWatcher : public QObject public: tst_QFileSystemWatcher(); +#ifndef QT_NO_FILESYSTEMWATCHER private slots: void basicTest_data(); void basicTest(); @@ -83,16 +84,20 @@ private slots: private: QString m_tempDirPattern; +#endif // QT_NO_FILESYSTEMWATCHER }; tst_QFileSystemWatcher::tst_QFileSystemWatcher() { +#ifndef QT_NO_FILESYSTEMWATCHER m_tempDirPattern = QDir::tempPath(); if (!m_tempDirPattern.endsWith(QLatin1Char('/'))) m_tempDirPattern += QLatin1Char('/'); m_tempDirPattern += QStringLiteral("tst_qfilesystemwatcherXXXXXX"); +#endif // QT_NO_FILESYSTEMWATCHER } +#ifndef QT_NO_FILESYSTEMWATCHER void tst_QFileSystemWatcher::basicTest_data() { QTest::addColumn<QString>("backend"); @@ -676,6 +681,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() QTRY_COMPARE(changedSpy.count(), 10); } +#endif // QT_NO_FILESYSTEMWATCHER QTEST_MAIN(tst_QFileSystemWatcher) #include "tst_qfilesystemwatcher.moc" diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index c5a9b421ee..42c360f2d8 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -119,7 +119,7 @@ private slots: #if !defined(Q_OS_WIN) && !defined(QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER) void dontReorderIniKeysNeedlessly(); #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void consistentRegistryStorage(); #endif @@ -274,7 +274,7 @@ void tst_QSettings::init() QSettings::setSystemIniPath(settingsPath("__system__")); QSettings::setUserIniPath(settingsPath("__user__")); -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QSettings("HKEY_CURRENT_USER\\Software\\software.org", QSettings::NativeFormat).clear(); QSettings("HKEY_LOCAL_MACHINE\\Software\\software.org", QSettings::NativeFormat).clear(); QSettings("HKEY_CURRENT_USER\\Software\\other.software.org", QSettings::NativeFormat).clear(); @@ -1496,7 +1496,7 @@ void tst_QSettings::sync() // Now "some other app" will change other.software.org.ini QString userConfDir = settingsPath("__user__") + QDir::separator(); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) unlink((userConfDir + "other.software.org.ini").toLatin1()); rename((userConfDir + "software.org.ini").toLatin1(), (userConfDir + "other.software.org.ini").toLatin1()); @@ -3197,7 +3197,7 @@ void tst_QSettings::recursionBug() } } -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) static DWORD readKeyType(HKEY handle, const QString &rSubKey) { diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 35a59401b7..d19f4379c7 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -289,9 +289,9 @@ void tst_qstandardpaths::testDataLocation() { // On all platforms, DataLocation should be GenericDataLocation / organization name / app name // This allows one app to access the data of another app. - // Blackberry OS is an exception to this case, owing to the fact that + // Blackberry OS and WinRT are an exception to this case, owing to the fact that // applications are sandboxed. -#ifndef Q_OS_BLACKBERRY +#if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_WINRT) const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths"); QCoreApplication::instance()->setOrganizationName("Qt"); @@ -335,6 +335,7 @@ void tst_qstandardpaths::testFindExecutable_data() QTest::addColumn<QString>("needle"); QTest::addColumn<QString>("expected"); #ifdef Q_OS_WIN +# ifndef Q_OS_WINRT const QFileInfo cmdFi = QFileInfo(QDir::cleanPath(QString::fromLocal8Bit(qgetenv("COMSPEC")))); const QString cmdPath = cmdFi.absoluteFilePath(); @@ -358,6 +359,7 @@ void tst_qstandardpaths::testFindExecutable_data() QTest::newRow("win8-logo-nosuffix") << QString() << logo << logoPath; } +# endif // Q_OS_WINRT #else const QFileInfo shFi = findSh(); Q_ASSERT(shFi.exists()); diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 713d0c5c17..a6cc083d9c 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -257,7 +257,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir() void tst_QTemporaryDir::openOnRootDrives() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif // If it's possible to create a file in the root directory, it @@ -271,7 +271,7 @@ void tst_QTemporaryDir::openOnRootDrives() QVERIFY(dir.isValid()); } } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) SetErrorMode(lastErrorMode); #endif } diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 6eb6f83d2a..5ad798ae1f 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -371,7 +371,7 @@ void tst_QTemporaryFile::resize() void tst_QTemporaryFile::openOnRootDrives() { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) unsigned int lastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif // If it's possible to create a file in the root directory, it @@ -385,7 +385,7 @@ void tst_QTemporaryFile::openOnRootDrives() QVERIFY(file.open()); } } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) SetErrorMode(lastErrorMode); #endif } diff --git a/tests/auto/corelib/kernel/kernel.pro b/tests/auto/corelib/kernel/kernel.pro index fe3e4b7e0a..c1b867e6eb 100644 --- a/tests/auto/corelib/kernel/kernel.pro +++ b/tests/auto/corelib/kernel/kernel.pro @@ -34,6 +34,6 @@ SUBDIRS=\ qsharedmemory # This test is only applicable on Windows -!win32*:SUBDIRS -= qwineventnotifier +!win32*|winrt: SUBDIRS -= qwineventnotifier android|qnx: SUBDIRS -= qsharedmemory qsystemsemaphore diff --git a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro index e5bcc31e6a..5593aa2430 100644 --- a/tests/auto/corelib/kernel/qeventloop/qeventloop.pro +++ b/tests/auto/corelib/kernel/qeventloop/qeventloop.pro @@ -4,7 +4,7 @@ TARGET = tst_qeventloop QT = core network testlib core-private SOURCES = $$PWD/tst_qeventloop.cpp -win32:!wince*:LIBS += -luser32 +win32:!wince*:!winrt:LIBS += -luser32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 contains(QT_CONFIG, glib): DEFINES += HAVE_GLIB diff --git a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro index 23a8e6d23a..d19ec23760 100644 --- a/tests/auto/corelib/kernel/qmetatype/qmetatype.pro +++ b/tests/auto/corelib/kernel/qmetatype/qmetatype.pro @@ -6,11 +6,11 @@ SOURCES = tst_qmetatype.cpp TESTDATA=./typeFlags.bin DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -win32-msvc*|wince { +win32-msvc*|wince|winrt { # Prevents "fatal error C1128: number of sections exceeded object file format limit". QMAKE_CXXFLAGS += /bigobj # Reduce compile time - win32-msvc2012|wince { + win32-msvc2012|wince|winrt { QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CFLAGS_RELEASE -= -O2 } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index ece88d47e3..e4804e6079 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -102,6 +102,7 @@ private slots: #ifndef QT_NO_PROCESS void recursiveSignalEmission(); #endif + void signalBlocking(); void blockingQueuedConnection(); void childEvents(); void installEventFilter(); @@ -2980,6 +2981,54 @@ void tst_QObject::recursiveSignalEmission() } #endif +void tst_QObject::signalBlocking() +{ + SenderObject sender; + ReceiverObject receiver; + + receiver.connect(&sender, SIGNAL(signal1()), SLOT(slot1())); + + sender.emitSignal1(); + QVERIFY(receiver.called(1)); + receiver.reset(); + + { + QSignalBlocker blocker(&sender); + + sender.emitSignal1(); + QVERIFY(!receiver.called(1)); + receiver.reset(); + + sender.blockSignals(false); + + sender.emitSignal1(); + QVERIFY(receiver.called(1)); + receiver.reset(); + + sender.blockSignals(true); + + sender.emitSignal1(); + QVERIFY(!receiver.called(1)); + receiver.reset(); + + blocker.unblock(); + + sender.emitSignal1(); + QVERIFY(receiver.called(1)); + receiver.reset(); + + blocker.reblock(); + + sender.emitSignal1(); + QVERIFY(!receiver.called(1)); + receiver.reset(); + } + + sender.emitSignal1(); + QVERIFY(receiver.called(1)); + receiver.reset(); +} + void tst_QObject::blockingQueuedConnection() { { diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 5cc0e5bdb4..0e53139414 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -55,6 +55,8 @@ #endif #if defined(Q_OS_WINCE) #include <windows.h> +#elif defined(Q_OS_WINRT) +#include <thread> #elif defined(Q_OS_WIN) #include <process.h> #include <windows.h> @@ -326,6 +328,9 @@ void tst_QThread::isRunning() void tst_QThread::setPriority() { +#if defined(Q_OS_WINRT) + QSKIP("Thread priority is not supported on WinRT"); +#endif Simple_Thread thread; // cannot change the priority, since the thread is not running @@ -460,6 +465,10 @@ void tst_QThread::start() QVERIFY(!thread.isFinished()); QVERIFY(!thread.isRunning()); QMutexLocker locker(&thread.mutex); +#ifdef Q_OS_WINRT + if (priorities[i] != QThread::NormalPriority && priorities[i] != QThread::InheritPriority) + QTest::ignoreMessage(QtWarningMsg, "QThread::start: Failed to set thread priority (not implemented)"); +#endif thread.start(priorities[i]); QVERIFY(thread.isRunning()); QVERIFY(!thread.isFinished()); @@ -472,6 +481,9 @@ void tst_QThread::start() void tst_QThread::terminate() { +#if defined(Q_OS_WINRT) + QSKIP("Terminate is not supported on WinRT"); +#endif Terminate_Thread thread; { QMutexLocker locker(&thread.mutex); @@ -535,6 +547,9 @@ void tst_QThread::finished() void tst_QThread::terminated() { +#if defined(Q_OS_WINRT) + QSKIP("Terminate is not supported on WinRT"); +#endif SignalRecorder recorder; Terminate_Thread thread; connect(&thread, SIGNAL(finished()), &recorder, SLOT(slot()), Qt::DirectConnection); @@ -630,6 +645,8 @@ void noop(void*) { } #if defined Q_OS_UNIX typedef pthread_t ThreadHandle; +#elif defined Q_OS_WINRT + typedef std::thread ThreadHandle; #elif defined Q_OS_WIN typedef HANDLE ThreadHandle; #endif @@ -671,6 +688,8 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data) #if defined Q_OS_UNIX const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this); Q_UNUSED(state); +#elif defined(Q_OS_WINRT) + nativeThreadHandle = std::thread(NativeThreadWrapper::runWin, this); #elif defined(Q_OS_WINCE) nativeThreadHandle = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL); #elif defined Q_OS_WIN @@ -690,6 +709,8 @@ void NativeThreadWrapper::join() { #if defined Q_OS_UNIX pthread_join(nativeThreadHandle, 0); +#elif defined Q_OS_WINRT + nativeThreadHandle.join(); #elif defined Q_OS_WIN WaitForSingleObject(nativeThreadHandle, INFINITE); CloseHandle(nativeThreadHandle); @@ -780,6 +801,9 @@ void tst_QThread::adoptedThreadAffinity() void tst_QThread::adoptedThreadSetPriority() { +#if defined(Q_OS_WINRT) + QSKIP("Thread priority is not supported on WinRT"); +#endif NativeThreadWrapper nativeThread; nativeThread.setWaitForStop(); @@ -857,6 +881,9 @@ void tst_QThread::adoptedThreadFinished() nativeThread.join(); QTestEventLoop::instance().enterLoop(5); +#if defined(Q_OS_WINRT) + QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort); +#endif QVERIFY(!QTestEventLoop::instance().timeout()); } @@ -872,6 +899,9 @@ void tst_QThread::adoptedThreadExecFinished() nativeThread.join(); QTestEventLoop::instance().enterLoop(5); +#if defined(Q_OS_WINRT) + QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort); +#endif QVERIFY(!QTestEventLoop::instance().timeout()); } @@ -908,6 +938,9 @@ void tst_QThread::adoptMultipleThreads() } QTestEventLoop::instance().enterLoop(5); +#if defined(Q_OS_WINRT) + QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort); +#endif QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(recorder.activationCount.load(), numThreads); } @@ -950,6 +983,9 @@ void tst_QThread::adoptMultipleThreadsOverlap() } QTestEventLoop::instance().enterLoop(5); +#if defined(Q_OS_WINRT) + QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort); +#endif QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(recorder.activationCount.load(), numThreads); } diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 4a9932798c..859cd1b36a 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -80,6 +80,7 @@ private slots: void destruction(); void threadRecycling(); void expiryTimeout(); + void expiryTimeoutRace(); #ifndef QT_NO_EXCEPTIONS void exceptions(); #endif @@ -315,7 +316,7 @@ class ExpiryTimeoutTask : public QRunnable { public: QThread *thread; - int runCount; + QAtomicInt runCount; QSemaphore semaphore; ExpiryTimeoutTask() @@ -327,7 +328,7 @@ public: void run() { thread = QThread::currentThread(); - ++runCount; + runCount.ref(); semaphore.release(); } }; @@ -346,7 +347,7 @@ void tst_QThreadPool::expiryTimeout() // run the task threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount, 1); + QCOMPARE(task.runCount.load(), 1); QVERIFY(!task.thread->wait(100)); // thread should expire QThread *firstThread = task.thread; @@ -355,7 +356,7 @@ void tst_QThreadPool::expiryTimeout() // run task again, thread should be restarted threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount, 2); + QCOMPARE(task.runCount.load(), 2); QVERIFY(!task.thread->wait(100)); // thread should expire again QVERIFY(task.thread->wait(10000)); @@ -368,6 +369,22 @@ void tst_QThreadPool::expiryTimeout() QCOMPARE(threadPool.expiryTimeout(), expiryTimeout); } +void tst_QThreadPool::expiryTimeoutRace() // QTBUG-3786 +{ + ExpiryTimeoutTask task; + + QThreadPool threadPool; + threadPool.setMaxThreadCount(1); + threadPool.setExpiryTimeout(50); + const int numTasks = 20; + for (int i = 0; i < numTasks; ++i) { + threadPool.start(&task); + QThread::msleep(50); // exactly the same as the expiry timeout + } + QCOMPARE(task.runCount.load(), numTasks); + QVERIFY(threadPool.waitForDone(2000)); +} + #ifndef QT_NO_EXCEPTIONS class ExceptionTask : public QRunnable { @@ -503,7 +520,8 @@ void tst_QThreadPool::setMaxThreadCountStartsAndStopsThreads() QVERIFY(task->waitForStarted.tryAcquire(6, 1000)); task->waitToFinish.release(10); -// delete task; + threadPool.waitForDone(); + delete task; } void tst_QThreadPool::reserveThread_data() diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index 2072034f5f..c96de29b98 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -232,7 +232,7 @@ void tst_QThreadStorage::adoptedThreads() const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers); QCOMPARE(state, 0); pthread_join(thread, 0); -#elif defined Q_OS_WIN +#elif defined Q_OS_WIN && !defined(Q_OS_WINRT) HANDLE thread; #if defined(Q_OS_WINCE) thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)testAdoptedThreadStorageWin, &pointers, 0, NULL); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index f37e192ad3..d5b3323506 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -553,6 +553,9 @@ void tst_QCommandLineParser::testHelpOption() void tst_QCommandLineParser::testQuoteEscaping() { +#ifdef QT_NO_PROCESS + QSKIP("This test requires QProcess support"); +#else QCoreApplication app(empty_argc, empty_argv); QProcess process; process.start("testhelper/qcommandlineparser_test_helper", QStringList() << @@ -568,6 +571,7 @@ void tst_QCommandLineParser::testQuoteEscaping() QVERIFY2(output.contains("KEY2=\\\"VALUE2\\\""), qPrintable(output)); QVERIFY2(output.contains("QTBUG-15379=C:\\path\\'file.ext"), qPrintable(output)); QVERIFY2(output.contains("QTBUG-30628=C:\\temp\\'file'.ext"), qPrintable(output)); +#endif // !QT_NO_PROCESS } QTEST_APPLESS_MAIN(tst_QCommandLineParser) diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 6c80c5ff47..7d51696fe3 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -49,6 +49,9 @@ #ifdef Q_OS_WIN # include <qt_windows.h> +# if defined(Q_OS_WINRT) +# define tzset() +# endif #endif class tst_QDateTime : public QObject @@ -175,7 +178,7 @@ void tst_QDateTime::init() { #if defined(Q_OS_WINCE) SetUserDefaultLCID(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN32) SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); #endif } diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 028cea3d62..1bac5f39e7 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -133,7 +133,7 @@ public: private slots: void initTestCase(); void cleanupTestCase(); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void windowsDefaultLocale(); #endif #ifdef Q_OS_MAC @@ -1472,7 +1472,7 @@ void tst_QLocale::macDefaultLocale() } #endif // Q_OS_MAC -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #include <qt_windows.h> static QString getWinLocaleInfo(LCTYPE type) @@ -1526,7 +1526,7 @@ public: #endif // Q_OS_WIN -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void tst_QLocale::windowsDefaultLocale() { RestoreLocaleHelper systemLocale; diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 48874781c0..9a3aaebaaf 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -1440,6 +1440,8 @@ void tst_QString::contains() QVERIFY(a.contains('F',Qt::CaseInsensitive)); QVERIFY(a.contains("FG")); QVERIFY(a.contains("FG",Qt::CaseInsensitive)); + QVERIFY(a.contains(QLatin1String("FG"))); + QVERIFY(a.contains(QLatin1String("fg"),Qt::CaseInsensitive)); QVERIFY(a.contains( QString(), Qt::CaseInsensitive)); QVERIFY(a.contains( "", Qt::CaseInsensitive)); QVERIFY(a.contains(QRegExp("[FG][HI]"))); diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index d7643ff55d..0a63ffeeaf 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -796,7 +796,7 @@ void tst_QTimeZone::macTest() void tst_QTimeZone::winTest() { -#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // Known datetimes qint64 std = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); qint64 dst = QDateTime(QDate(2012, 6, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); |