diff options
Diffstat (limited to 'tests/auto/corelib')
6 files changed, 176 insertions, 131 deletions
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp index d9292b8460..04c083e653 100644 --- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp +++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp @@ -56,6 +56,29 @@ # include <windows.h> #endif +// Restore permissions so that the QTemporaryDir cleanup can happen +class PermissionRestorer +{ + Q_DISABLE_COPY(PermissionRestorer) +public: + explicit PermissionRestorer(const QString& path) : m_path(path) {} + ~PermissionRestorer() { restore(); } + + inline void restore() + { + QFile file(m_path); +#ifdef Q_OS_UNIX + file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)); +#else + file.setPermissions(QFile::WriteOwner); + file.remove(); +#endif + } + +private: + const QString m_path; +}; + class tst_QSaveFile : public QObject { Q_OBJECT @@ -73,13 +96,21 @@ private slots: void transactionalWriteErrorRenaming(); }; +static inline QByteArray msgCannotOpen(const QFileDevice &f) +{ + QString result = QStringLiteral("Cannot open ") + QDir::toNativeSeparators(f.fileName()) + + QStringLiteral(": ") + f.errorString(); + return result.toLocal8Bit(); +} + void tst_QSaveFile::transactionalWrite() { QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QFile::remove(targetFile); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QVERIFY(file.isOpen()); QCOMPARE(file.fileName(), targetFile); QVERIFY(!QFile::exists(targetFile)); @@ -102,27 +133,29 @@ void tst_QSaveFile::saveTwice() // Check that we can reuse a QSaveFile object // (and test the case of an existing target file) QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE(file.write("Hello"), Q_INT64_C(5)); QVERIFY2(file.commit(), qPrintable(file.errorString())); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE(file.write("World"), Q_INT64_C(5)); QVERIFY2(file.commit(), qPrintable(file.errorString())); QFile reader(targetFile); - QVERIFY(reader.open(QIODevice::ReadOnly)); + QVERIFY2(reader.open(QIODevice::ReadOnly), msgCannotOpen(reader).constData()); QCOMPARE(QString::fromLatin1(reader.readAll()), QString::fromLatin1("World")); } void tst_QSaveFile::textStreamManualFlush() { QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QTextStream ts(&file); ts << "Manual flush"; @@ -140,9 +173,10 @@ void tst_QSaveFile::textStreamManualFlush() void tst_QSaveFile::textStreamAutoFlush() { QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QTextStream ts(&file); ts << "Auto-flush."; @@ -166,28 +200,8 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir() { #ifdef Q_OS_UNIX QFETCH(bool, directWriteFallback); - // Restore permissions so that the QTemporaryDir cleanup can happen - class PermissionRestorer - { - QString m_path; - public: - PermissionRestorer(const QString& path) - : m_path(path) - {} - - ~PermissionRestorer() - { - restore(); - } - void restore() - { - QFile file(m_path); - file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)); - } - }; - - QTemporaryDir dir; + QVERIFY(dir.isValid()); QVERIFY(QFile(dir.path()).setPermissions(QFile::ReadOwner | QFile::ExeOwner)); PermissionRestorer permissionRestorer(dir.path()); @@ -212,7 +226,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir() file.setDirectWriteFallback(directWriteFallback); QCOMPARE(file.directWriteFallback(), directWriteFallback); if (directWriteFallback) { - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE((int)file.error(), (int)QFile::NoError); QCOMPARE(file.write("World"), Q_INT64_C(5)); QVERIFY(file.commit()); @@ -222,7 +236,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir() QCOMPARE(QString::fromLatin1(reader.readAll()), QString::fromLatin1("World")); reader.close(); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE((int)file.error(), (int)QFile::NoError); QCOMPARE(file.write("W"), Q_INT64_C(1)); file.cancelWriting(); // no effect, as per the documentation @@ -241,9 +255,11 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile() { // Setup an existing but readonly file QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + PermissionRestorer permissionRestorer(targetFile); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE(file.write("Hello"), Q_INT64_C(5)); file.close(); file.setPermissions(QFile::ReadOwner); @@ -260,10 +276,11 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile() void tst_QSaveFile::transactionalWriteCanceled() { QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QFile::remove(targetFile); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QTextStream ts(&file); ts << "This writing operation will soon be canceled.\n"; @@ -283,35 +300,12 @@ void tst_QSaveFile::transactionalWriteCanceled() void tst_QSaveFile::transactionalWriteErrorRenaming() { QTemporaryDir dir; + QVERIFY(dir.isValid()); const QString targetFile = dir.path() + QString::fromLatin1("/outfile"); QSaveFile file(targetFile); - QVERIFY(file.open(QIODevice::WriteOnly)); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); QCOMPARE(file.write("Hello"), qint64(5)); QVERIFY(!QFile::exists(targetFile)); - - // Restore permissions so that the QTemporaryDir cleanup can happen - class PermissionRestorer - { - public: - PermissionRestorer(const QString& path) - : m_path(path) - {} - - ~PermissionRestorer() - { - QFile file(m_path); -#ifdef Q_OS_UNIX - file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)); -#else - file.setPermissions(QFile::WriteOwner); - file.remove(); -#endif - } - - private: - QString m_path; - }; - #ifdef Q_OS_UNIX // Make rename() fail for lack of permissions in the directory QFile dirAsFile(dir.path()); // yay, I have to use QFile to change a dir's permissions... @@ -320,7 +314,7 @@ void tst_QSaveFile::transactionalWriteErrorRenaming() #else // Windows: Make rename() fail for lack of permissions on an existing target file QFile existingTargetFile(targetFile); - QVERIFY(existingTargetFile.open(QIODevice::WriteOnly)); + QVERIFY2(existingTargetFile.open(QIODevice::WriteOnly), msgCannotOpen(existingTargetFile).constData()); QCOMPARE(file.write("Target"), qint64(6)); existingTargetFile.close(); QVERIFY(existingTargetFile.setPermissions(QFile::ReadOwner)); diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index b63dbc449c..9ac1526f07 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -308,13 +308,16 @@ void tst_qstandardpaths::testDataLocation() #ifndef Q_OS_WIN // Find "sh" on Unix. +// It may exist twice, in /bin/sh and /usr/bin/sh, in that case use the PATH order. static inline QFileInfo findSh() { - const char *shPaths[] = {"/bin/sh", "/usr/bin/sh", 0}; - for (const char **shPath = shPaths; *shPath; ++shPath) { - const QFileInfo fi = QFileInfo(QLatin1String(*shPath)); - if (fi.exists()) - return fi; + QLatin1String sh("/sh"); + QByteArray pEnv = qgetenv("PATH"); + const QLatin1Char pathSep(':'); + const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts); + foreach (const QString &path, rawPaths) { + if (QFile::exists(path + sh)) + return path + sh; } return QFileInfo(); } diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index 14df20c986..0602b9fc38 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -2,3 +2,4 @@ CONFIG += testcase parallel_test TARGET = tst_qcoreapplication QT = core testlib core-private SOURCES = tst_qcoreapplication.cpp +HEADERS = tst_qcoreapplication.h diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 78f2cdae69..760303a027 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include "tst_qcoreapplication.h" + #include <QtCore/QtCore> #include <QtTest/QtTest> @@ -46,31 +48,12 @@ #include <private/qeventloop_p.h> #include <private/qthread_p.h> -class tst_QCoreApplication: public QObject -{ - Q_OBJECT -private slots: - void sendEventsOnProcessEvents(); // this must be the first test - void getSetCheck(); - void qAppName(); -#ifndef Q_OS_WIN - void argc(); -#endif - void postEvent(); - void removePostedEvents(); -#ifndef QT_NO_THREAD - void deliverInDefinedOrder(); +#ifdef QT_GUI_LIB +#include <QtGui/QGuiApplication> +typedef QGuiApplication TestApplication; +#else +typedef QCoreApplication TestApplication; #endif - void applicationPid(); - void globalPostedEventsCount(); - void processEventsAlwaysSendsPostedEvents(); - void reexec(); - void execAfterExit(); - void eventLoopExecAfterExit(); - void customEventDispatcher(); - void testQuitLock(); - void QTBUG31606_QEventDestructorDeadLock(); -}; class EventSpy : public QObject { @@ -89,7 +72,7 @@ void tst_QCoreApplication::sendEventsOnProcessEvents() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); EventSpy spy; app.installEventFilter(&spy); @@ -111,7 +94,7 @@ void tst_QCoreApplication::getSetCheck() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCOMPARE(app.property("applicationVersion").toString(), v); } v = QString(); @@ -121,11 +104,17 @@ void tst_QCoreApplication::getSetCheck() void tst_QCoreApplication::qAppName() { +#ifdef QT_GUI_LIB + const char* appName = "tst_qguiapplication"; +#else + const char* appName = "tst_qcoreapplication"; +#endif + int argc = 1; - char *argv[] = { const_cast<char*>("tst_qcoreapplication") }; - QCoreApplication app(argc, argv); - QCOMPARE(::qAppName(), QString::fromLatin1("tst_qcoreapplication")); - QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qcoreapplication")); + char *argv[] = { const_cast<char*>(appName) }; + TestApplication app(argc, argv); + QCOMPARE(::qAppName(), QString::fromLatin1(appName)); + QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1(appName)); } // "QCoreApplication::arguments() always parses arguments from actual command line on Windows @@ -136,7 +125,7 @@ void tst_QCoreApplication::argc() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCOMPARE(argc, 1); QCOMPARE(app.arguments().count(), 1); } @@ -147,7 +136,7 @@ void tst_QCoreApplication::argc() const_cast<char*>("arg1"), const_cast<char*>("arg2"), const_cast<char*>("arg3") }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCOMPARE(argc, 4); QCOMPARE(app.arguments().count(), 4); } @@ -155,7 +144,7 @@ void tst_QCoreApplication::argc() { int argc = 0; char **argv = 0; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCOMPARE(argc, 0); QCOMPARE(app.arguments().count(), 0); } @@ -164,7 +153,7 @@ void tst_QCoreApplication::argc() int argc = 2; char *argv[] = { const_cast<char*>(QTest::currentAppName()), const_cast<char*>("-qmljsdebugger=port:3768,block") }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCOMPARE(argc, 1); QCOMPARE(app.arguments().count(), 1); } @@ -197,7 +186,7 @@ void tst_QCoreApplication::postEvent() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); EventSpy spy; EventGenerator odd, even; @@ -282,7 +271,7 @@ void tst_QCoreApplication::removePostedEvents() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); EventSpy spy; QObject one, two; @@ -461,7 +450,7 @@ void tst_QCoreApplication::deliverInDefinedOrder() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); DeliverInDefinedOrderObject obj(&app); // causes sendPostedEvents() to recurse twice @@ -501,7 +490,7 @@ void tst_QCoreApplication::globalPostedEventsCount() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QCoreApplication::sendPostedEvents(); QCOMPARE(qGlobalPostedEventsCount(), 0u); @@ -547,7 +536,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); ProcessEventsAlwaysSendsPostedEventsObject object; QTime t; @@ -565,7 +554,7 @@ void tst_QCoreApplication::reexec() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); // exec once QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); @@ -580,7 +569,7 @@ void tst_QCoreApplication::execAfterExit() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); app.exit(1); QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); @@ -591,7 +580,7 @@ void tst_QCoreApplication::eventLoopExecAfterExit() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); // exec once and exit QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); @@ -649,7 +638,7 @@ void tst_QCoreApplication::customEventDispatcher() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); // instantiating app should not overwrite the ED QCOMPARE(QCoreApplication::eventDispatcher(), ed); QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); @@ -764,7 +753,7 @@ void tst_QCoreApplication::testQuitLock() { int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); QuitTester tester; app.exec(); @@ -783,7 +772,7 @@ void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock() int argc = 1; char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; - QCoreApplication app(argc, argv); + TestApplication app(argc, argv); EventSpy spy; app.installEventFilter(&spy); @@ -810,5 +799,8 @@ static void createQObjectOnDestruction() } Q_DESTRUCTOR_FUNCTION(createQObjectOnDestruction) +#ifndef QT_GUI_LIB QTEST_APPLESS_MAIN(tst_QCoreApplication) +#endif + #include "tst_qcoreapplication.moc" diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h new file mode 100644 index 0000000000..16ade27f83 --- /dev/null +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TST_QCOREAPPLICATION_H +#define TST_QCOREAPPLICATION_H + +#include <QtCore/QtCore> + +class tst_QCoreApplication: public QObject +{ + Q_OBJECT +private slots: + void sendEventsOnProcessEvents(); // this must be the first test + void getSetCheck(); + void qAppName(); +#ifndef Q_OS_WIN + void argc(); +#endif + void postEvent(); + void removePostedEvents(); +#ifndef QT_NO_THREAD + void deliverInDefinedOrder(); +#endif + void applicationPid(); + void globalPostedEventsCount(); + void processEventsAlwaysSendsPostedEvents(); + void reexec(); + void execAfterExit(); + void eventLoopExecAfterExit(); + void customEventDispatcher(); + void testQuitLock(); + void QTBUG31606_QEventDestructorDeadLock(); +}; + +#endif // TST_QCOREAPPLICATION_H diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 039f5cbc44..ffc4baa55d 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2387,8 +2387,6 @@ void tst_QDateTime::daylightTransitions() const // 2011-10-30 03:00:00 CEST became 02:00:00 CET at msecs = 1319936400000 // 2012-03-25 02:00:00 CET became 03:00:00 CEST at msecs = 1332637200000 // 2012-10-28 03:00:00 CEST became 02:00:00 CET at msecs = 1351386000000 - const qint64 daylight2011 = 1301187600000; - const qint64 standard2011 = 1319936400000; const qint64 daylight2012 = 1332637200000; const qint64 standard2012 = 1351386000000; const qint64 msecsOneHour = 3600000; @@ -2538,10 +2536,6 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(hourBefore.isValid()); QCOMPARE(hourBefore.date(), QDate(2012, 10, 28)); QCOMPARE(hourBefore.time(), QTime(2, 0, 0)); -#ifndef Q_OS_MAC - // Linux mktime bug uses last calculation - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); -#endif // Q_OS_MAC QCOMPARE(hourBefore.toMSecsSinceEpoch(), standard2012 - msecsOneHour); // 1 msec before transition is 2:59:59.999 FirstOccurrence @@ -2549,7 +2543,6 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(msecBefore.isValid()); QCOMPARE(msecBefore.date(), QDate(2012, 10, 28)); QCOMPARE(msecBefore.time(), QTime(2, 59, 59, 999)); - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); QCOMPARE(msecBefore.toMSecsSinceEpoch(), standard2012 - 1); // At transition is 2:00:00 SecondOccurrence @@ -2557,10 +2550,6 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(atTran.isValid()); QCOMPARE(atTran.date(), QDate(2012, 10, 28)); QCOMPARE(atTran.time(), QTime(2, 0, 0)); -#ifdef Q_OS_MAC - // Mac defaults to FirstOccurrence here - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); -#endif // Q_OS_MAC QCOMPARE(atTran.toMSecsSinceEpoch(), standard2012); // 59:59.999 after transition is 2:59:59.999 SecondOccurrence @@ -2711,10 +2700,6 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(test.isValid()); QCOMPARE(test.date(), QDate(2012, 10, 28)); QCOMPARE(test.time(), QTime(2, 0, 0)); -#ifdef Q_OS_WIN - // Windows uses SecondOccurrence - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); -#endif // Q_OS_WIN QCOMPARE(test.toMSecsSinceEpoch(), standard2012 - msecsOneHour); // Add hour to tran FirstOccurrence to get to tran SecondOccurrence @@ -2727,11 +2712,10 @@ void tst_QDateTime::daylightTransitions() const QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_WIN QCOMPARE(test.time(), QTime(2, 0, 0)); -#ifndef Q_OS_MAC +#ifdef Q_OS_WIN // Windows uses SecondOccurrence - // Linux mktime bug uses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); -#endif // Q_OS_MAC +#endif // Q_OS_WIN QCOMPARE(test.toMSecsSinceEpoch(), standard2012); // Add hour to tran SecondOccurrence to get to after tran FirstOccurrence @@ -2739,15 +2723,13 @@ void tst_QDateTime::daylightTransitions() const test = test.addMSecs(msecsOneHour); QVERIFY(test.isValid()); QCOMPARE(test.date(), QDate(2012, 10, 28)); -#ifndef Q_OS_WIN - // Mac uses FirstOccurrence - // Linux mktime bug uses last calculation +#ifdef Q_OS_MAC + // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_WIN QCOMPARE(test.time(), QTime(3, 0, 0)); -#ifndef Q_OS_WIN - // Mac uses FirstOccurrence - // Linux mktime bug uses last calculation +#ifdef Q_OS_MAC + // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_WIN QCOMPARE(test.toMSecsSinceEpoch(), standard2012 + msecsOneHour); |