diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2018-02-14 18:07:15 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-03-09 10:34:00 +0000 |
commit | bc008afb0e3724a89890e9bd68451b1903bc8e17 (patch) | |
tree | 6fd085baff0d5efadc297a8cd1f2debeed4eb54a | |
parent | 7a1d77b6e4ec38ae8fc1760048313a6eae12676d (diff) |
Adjust tst_QTimeZone's Q_OS_WIN #if-ery now that ICU is the default
Various tests were adapted to Q_OS_WIN to take account of the
deficiencies in its TZ APIs; which are now bypassed when ICU is
configured, as we use it instead. Replace some #if-ery on a local
define with QT_CONFIG(icu) and QMAKE_USE_PRIVATE += icu here, to match
in corelib/tools/tools.pri
Task-number: QTBUG-66367
Change-Id: Ia93abdeb7d12046310f0bb4a78c2669f8eecbbc2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
-rw-r--r-- | tests/auto/corelib/tools/qtimezone/qtimezone.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 22 |
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/auto/corelib/tools/qtimezone/qtimezone.pro b/tests/auto/corelib/tools/qtimezone/qtimezone.pro index 19ebc13306..5ec8d008e7 100644 --- a/tests/auto/corelib/tools/qtimezone/qtimezone.pro +++ b/tests/auto/corelib/tools/qtimezone/qtimezone.pro @@ -3,7 +3,7 @@ TARGET = tst_qtimezone QT = core-private testlib SOURCES = tst_qtimezone.cpp qtConfig(icu) { - DEFINES += QT_USE_ICU + QMAKE_USE_PRIVATE += icu } darwin { diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index cb963ceeb6..df4ae59631 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -31,6 +31,10 @@ #include <private/qtimezoneprivate_p.h> #include <qlocale.h> +#if defined(Q_OS_WIN) && !QT_CONFIG(icu) +# define USING_WIN_TZ +#endif + class tst_QTimeZone : public QObject { Q_OBJECT @@ -413,7 +417,7 @@ void tst_QTimeZone::specificTransition_data() QTest::addColumn<int>("dstoff"); // Moscow ditched DST on 2010-10-31 but has since changed standard offset twice. -#ifdef Q_OS_WIN +#ifdef USING_WIN_TZ // Win7 is too old to know about this transition: if (QOperatingSystemVersion::current() > QOperatingSystemVersion::Windows7) #endif @@ -500,7 +504,7 @@ void tst_QTimeZone::transitionEachZone() QTimeZone named(zone); for (int i = start; i < stop; i++) { -#ifdef Q_OS_WIN +#ifdef USING_WIN_TZ // See QTBUG-64985: MS's TZ APIs' misdescription of Europe/Samara leads // to mis-disambiguation of its fall-back here. if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7 @@ -829,7 +833,7 @@ void tst_QTimeZone::utcTest() void tst_QTimeZone::icuTest() { -#if defined(QT_BUILD_INTERNAL) && defined(QT_USE_ICU) +#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(icu) // 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(); @@ -877,7 +881,7 @@ void tst_QTimeZone::icuTest() testCetPrivate(tzp); testEpochTranPrivate(QIcuTimeZonePrivate("America/Toronto")); -#endif // QT_USE_ICU +#endif // icu } void tst_QTimeZone::tzTest() @@ -903,7 +907,7 @@ void tst_QTimeZone::tzTest() QLocale enUS("en_US"); // Only test names in debug mode, names used can vary by ICU version installed if (debug) { -#ifdef QT_USE_ICU +#ifdef QT_CONFIG(icu) QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS), QString("Central European Standard Time")); QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS), @@ -942,7 +946,7 @@ void tst_QTimeZone::tzTest() QString("CET")); QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS), QString("CET")); -#endif // QT_USE_ICU +#endif // icu // Test Abbreviations QCOMPARE(tzp.abbreviation(std), QString("CET")); @@ -1119,7 +1123,7 @@ void tst_QTimeZone::darwinTypes() void tst_QTimeZone::winTest() { -#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) +#if defined(QT_BUILD_INTERNAL) && defined(USING_WIN_TZ) // 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(); @@ -1170,7 +1174,7 @@ void tst_QTimeZone::winTest() testCetPrivate(tzp); testEpochTranPrivate(QWinTimeZonePrivate("America/Toronto")); -#endif // Q_OS_WIN +#endif // QT_BUILD_INTERNAL && USING_WIN_TZ } #ifdef QT_BUILD_INTERNAL @@ -1282,7 +1286,7 @@ void tst_QTimeZone::testEpochTranPrivate(const QTimeZonePrivate &tzp) // 1970-04-26 02:00 EST, -5 -> -4 const QDateTime after = QDateTime(QDate(1970, 4, 26), QTime(2, 0), Qt::OffsetFromUTC, -5 * 3600); const QDateTime found = QDateTime::fromMSecsSinceEpoch(tran.atMSecsSinceEpoch, Qt::UTC); -#ifdef Q_OS_WIN // MS gets the date wrong: 5th April instead of 26th. +#ifdef USING_WIN_TZ // MS gets the date wrong: 5th April instead of 26th. QCOMPARE(found.toOffsetFromUtc(-5 * 3600).time(), after.time()); #else QCOMPARE(found, after); |