summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-02-06 12:02:55 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-02-06 12:56:58 +0100
commit26f6aa3e50f8eb37a8f748c884537375298ceb2e (patch)
tree98e22fe4ae4f356b4075a70c89001a4178c33997
parentd75d22f785374b468cd56007b30864c52e896472 (diff)
Configure the MS-Win long time format rather than assuming we know it
In tst_QLocale::windowsDefaultLocale(), we configure the long and short date formats and the short time format eccentrically, then verify that QLocale::system() does actually get these eccentric formats. However, we did not configure the long time format (whose MS-API name doesn't match that of the other formats), so had to rely on a guess at the system locale's format. That, however, is not robust; so now configure the long time format, too. Removed a duplicated test, at the same time. Fixes: QTBUG-36306 Change-Id: I04dc22c7eb1b58af55412b598873868f79e9c74f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 45372c8b01..ec85a6c5c6 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -2042,6 +2042,8 @@ void tst_QLocale::windowsDefaultLocale()
setWinLocaleInfo(LOCALE_SLONGDATE, longDateFormat);
const QString shortTimeFormat = QStringLiteral("h^m^s");
setWinLocaleInfo(LOCALE_SSHORTTIME, shortTimeFormat);
+ const QString longTimeFormat = QStringLiteral("HH%mm%ss");
+ setWinLocaleInfo(LOCALE_STIMEFORMAT, longTimeFormat);
QSystemLocale dummy; // to provoke a refresh of the system locale
QLocale locale = QLocale::system();
@@ -2055,7 +2057,7 @@ void tst_QLocale::windowsDefaultLocale()
QCOMPARE(locale.dateTimeFormat(QLocale::ShortFormat),
shortDateFormat + QLatin1Char(' ') + shortTimeFormat);
const QString expectedLongDateTimeFormat
- = longDateFormat + QLatin1Char(' ') + QStringLiteral("h:mm:ss AP");
+ = longDateFormat + QLatin1Char(' ') + longTimeFormat;
QCOMPARE(locale.dateTimeFormat(QLocale::LongFormat), expectedLongDateTimeFormat);
// make sure we are using the system to parse them
@@ -2069,7 +2071,7 @@ void tst_QLocale::windowsDefaultLocale()
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime);
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat),
locale.toString(QTime(1,2,3), QLocale::ShortFormat));
- const QString expectedFormattedLongTime = QStringLiteral("1:02:03 AM");
+ const QString expectedFormattedLongTime = QStringLiteral("01%02%03");
QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime);
QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat),
QStringLiteral("1*12*1974 ") + expectedFormattedShortTime);
@@ -2077,7 +2079,6 @@ void tst_QLocale::windowsDefaultLocale()
locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat));
QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::LongFormat),
QStringLiteral("1@12@1974 ") + expectedFormattedLongTime);
- QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime);
}
#endif // Q_OS_WIN but !Q_OS_WINRT