From 492dd97f9b214b661cd45ab178fff316709b6382 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 9 Nov 2012 17:49:22 +0100 Subject: test: fix tst_QLocale::macDefaultLocale 1. There is a behaviour change for CFDateFormatterGetFormat() between 10.6 and later, QLocale::dateFormat(QLocale::LongFormat) will return "MMMM d, yyyy" for 10.6 and "MMMM d, y" for 10.7, 10.8 2. Add a comment for toCurrencyString() test, need another system settings (back port from qtbase 65685fbd2a3a587e654807d9ce44708064afdfa2) Task-number: QTBUG-27790 Change-Id: I668ff8882cf676d4420bf4dd66dc2cdd3b84fc18 Reviewed-by: Liang Qi --- tests/auto/qlocale/tst_qlocale.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 795a284..d7e278f 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -91,7 +91,9 @@ public: private slots: void initTestCase(); void windowsDefaultLocale(); +#ifdef Q_OS_MAC void macDefaultLocale(); +#endif void ctor(); void emptyCtor(); @@ -1106,12 +1108,9 @@ void tst_QLocale::toDateTime() QCOMPARE(l.toDateTime(string, QLocale::LongFormat), result); } +#ifdef Q_OS_MAC void tst_QLocale::macDefaultLocale() { -#ifndef Q_OS_MAC - QSKIP("This is a Mac OS X-only test", SkipAll); -#endif - QLocale locale = QLocale::system(); if (locale.name() != QLatin1String("en_US")) { QSKIP("This test only tests for en_US", SkipAll); @@ -1128,7 +1127,10 @@ void tst_QLocale::macDefaultLocale() QCOMPARE(locale.decimalPoint(), QChar('.')); QCOMPARE(locale.groupSeparator(), QChar(',')); QCOMPARE(locale.dateFormat(QLocale::ShortFormat), QString("M/d/yy")); - QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy")); + if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6) + QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, y")); + else + QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy")); QCOMPARE(locale.timeFormat(QLocale::ShortFormat), QString("h:mm AP")); QCOMPARE(locale.timeFormat(QLocale::LongFormat), QString("h:mm:ss AP t")); @@ -1154,6 +1156,7 @@ void tst_QLocale::macDefaultLocale() const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat); QVERIFY(timeString.contains(QString("1:02:03"))); + // System Preferences->Language & Text, Region Tab, should choose "United States" for Region field QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00")); QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), QString("($1,234.00)")); QCOMPARE(locale.toCurrencyString(double(1234.56)), QString("$1,234.56")); @@ -1190,6 +1193,7 @@ void tst_QLocale::macDefaultLocale() QCOMPARE(locale.weekdays(), days); } +#endif #ifdef Q_OS_WIN #include -- cgit v0.12