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>
This commit is contained in:
parent
d75d22f785
commit
26f6aa3e50
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user