diff options
Diffstat (limited to 'tests/auto/qlocale/tst_qlocale.cpp')
-rw-r--r-- | tests/auto/qlocale/tst_qlocale.cpp | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 9ef7f1d..c65908a 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -68,6 +68,11 @@ extern "C" DWORD GetThreadLocale(void) { # include <stdlib.h> #endif +#if defined(Q_OS_SYMBIAN) +# include <e32std.h> +# include <private/qcore_symbian_p.h> +#endif + Q_DECLARE_METATYPE(qlonglong) Q_DECLARE_METATYPE(QDate) Q_DECLARE_METATYPE(QLocale::FormatType) @@ -130,6 +135,9 @@ private slots: void queryDateTime(); void queryMeasureSystem_data(); void queryMeasureSystem(); +#if defined(Q_OS_SYMBIAN) + void symbianSystemLocale(); +#endif void ampm(); @@ -317,8 +325,8 @@ void tst_QLocale::ctor() void tst_QLocale::emptyCtor() { -#ifdef Q_OS_WINCE - QSKIP("Uses unsupported Windows CE QProcess functionality", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Uses unsupported Windows CE / Symbian QProcess functionality (std streams, env)", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); @@ -663,7 +671,7 @@ void tst_QLocale::testInfAndNan() double nan = sqrt(-1.0); #ifdef Q_OS_WIN - // these causes INVALID floating point exception so we want to clare the status. + // these cause INVALID floating point exception so we want to clear the status. _clear87(); #endif @@ -1056,11 +1064,11 @@ void tst_QLocale::macDefaultLocale() QTime utcTime = QDateTime::currentDateTime().toUTC().time(); int diff = currentTime.hour() - utcTime.hour(); - + // Check if local time and utc time are on opposite sides of the 24-hour wrap-around. - if (diff < -12) + if (diff < -12) diff += 24; - if (diff > 12) + if (diff > 12) diff -= 24; const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat); @@ -1716,7 +1724,7 @@ void tst_QLocale::systemMeasurementSystems() // Theoretically, we could include HPUX in this test, but its setenv implementation // stinks. It's called putenv, and it requires you to keep the variable you pass // to it around forever. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) QFETCH(QString, lcAllLocale); QFETCH(QString, lcMeasurementLocale); QFETCH(QString, langLocale); @@ -1740,7 +1748,7 @@ void tst_QLocale::systemMeasurementSystems() qputenv("LC_MEASUREMENT", oldLcMeasurement.toLocal8Bit()); qputenv("LANG", oldLang.toLocal8Bit()); #else - QSKIP("Test doesn't work on Mac or Windows", SkipAll); + QSKIP("Test doesn't work on Mac, Windows or Symbian", SkipAll); #endif } @@ -1838,7 +1846,7 @@ void tst_QLocale::queryMeasureSystem() // Theoretically, we could include HPUX in this test, but its setenv implementation // stinks. It's called putenv, and it requires you to keep the variable you pass // to it around forever. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) QFETCH(QString, lcAllLocale); QFETCH(QString, lcMeasurementLocale); QFETCH(QString, langLocale); @@ -1862,7 +1870,7 @@ void tst_QLocale::queryMeasureSystem() qputenv("LC_MEASUREMENT", oldLcMeasurement.toLocal8Bit()); qputenv("LANG", oldLang.toLocal8Bit()); #else - QSKIP("Test doesn't work on Mac or Windows", SkipAll); + QSKIP("Test doesn't work on Mac, Windows or Symbian", SkipAll); #endif } #endif // QT_NO_SYSTEMLOCALE @@ -1979,5 +1987,64 @@ void tst_QLocale::standaloneMonthName() QCOMPARE(ru.standaloneMonthName(1, QLocale::NarrowFormat), QString::fromUtf8("\320\257")); } +#if defined(Q_OS_SYMBIAN) +void tst_QLocale::symbianSystemLocale() +{ +# if defined(__SERIES60_31__) + QSKIP("S60 3.1 doesn't support system format properly", SkipAll); +# else + // Simple test to verify that Symbian system locale works at all + const QSystemLocale locale; + TExtendedLocale s60Locale; + s60Locale.LoadSystemSettings(); + + TTime s60Date(_L("20090117:")); // Symbian offsets day and month from zero + QDate date(2009,2,18); + + TPtrC s60DateFormat = s60Locale.GetShortDateFormatSpec(); + QString dateFormat = locale.query(QSystemLocale::DateFormatShort, QVariant()).toString(); + +#if 0 + QTime nowTime = QTime::currentTime(); + QDateTime nowDateTime = QDateTime::currentDateTime(); + qDebug() << "locale.query(QSystemLocale::LanguageId)" << locale.query(QSystemLocale::LanguageId, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::CountryId)" << locale.query(QSystemLocale::CountryId, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DecimalPoint)" << locale.query(QSystemLocale::DecimalPoint, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::GroupSeparator)" << locale.query(QSystemLocale::GroupSeparator, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::ZeroDigit)" << locale.query(QSystemLocale::ZeroDigit, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::NegativeSign)" << locale.query(QSystemLocale::NegativeSign, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::PositiveSign)" << locale.query(QSystemLocale::PositiveSign, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DateFormatLong)" << locale.query(QSystemLocale::DateFormatLong, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DateFormatShort)" << locale.query(QSystemLocale::DateFormatShort, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::TimeFormatLong)" << locale.query(QSystemLocale::TimeFormatLong, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::TimeFormatShort)" << locale.query(QSystemLocale::TimeFormatShort, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DayNameLong)" << locale.query(QSystemLocale::DayNameLong, QVariant(1)).toString(); + qDebug() << "locale.query(QSystemLocale::DayNameShort)" << locale.query(QSystemLocale::DayNameShort, QVariant(1)).toString(); + qDebug() << "locale.query(QSystemLocale::MonthNameLong)" << locale.query(QSystemLocale::MonthNameLong, QVariant(2)).toString(); + qDebug() << "locale.query(QSystemLocale::MonthNameShort)" << locale.query(QSystemLocale::MonthNameShort, QVariant(2)).toString(); + qDebug() << "locale.query(QSystemLocale::DateToStringLong)" << locale.query(QSystemLocale::DateToStringLong, QVariant(date)).toString(); + qDebug() << "locale.query(QSystemLocale::DateToStringShort)" << locale.query(QSystemLocale::DateToStringShort, QVariant(date)).toString(); + qDebug() << "locale.query(QSystemLocale::TimeToStringLong)" << locale.query(QSystemLocale::TimeToStringLong, QVariant(nowTime)).toString(); + qDebug() << "locale.query(QSystemLocale::TimeToStringShort)" << locale.query(QSystemLocale::TimeToStringShort, QVariant(nowTime)).toString(); + qDebug() << "locale.query(QSystemLocale::DateTimeFormatLong)" << locale.query(QSystemLocale::DateTimeFormatLong, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DateTimeFormatShort)" << locale.query(QSystemLocale::DateTimeFormatShort, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::DateTimeToStringLong)" << locale.query(QSystemLocale::DateTimeToStringLong, QVariant(nowDateTime)).toString(); + qDebug() << "locale.query(QSystemLocale::DateTimeToStringShort)" << locale.query(QSystemLocale::DateTimeToStringShort, QVariant(nowDateTime)).toString(); + qDebug() << "locale.query(QSystemLocale::MeasurementSystem)" << locale.query(QSystemLocale::MeasurementSystem, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::AMText)" << locale.query(QSystemLocale::AMText, QVariant()).toString(); + qDebug() << "locale.query(QSystemLocale::PMText)" << locale.query(QSystemLocale::PMText, QVariant()).toString(); +#endif + + TBuf<50> s60FormattedDate; + TRAPD(err, s60Date.FormatL(s60FormattedDate, s60DateFormat)); + QVERIFY(err == KErrNone); + QString s60FinalResult = qt_TDes2QStringL(s60FormattedDate); + QString finalResult = date.toString(dateFormat); + + QCOMPARE(finalResult, s60FinalResult); +# endif +} +#endif + QTEST_APPLESS_MAIN(tst_QLocale) #include "tst_qlocale.moc" |