aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-10-28 11:12:54 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2024-02-14 19:44:16 +0200
commitd942ab199807fa18eee2c153a1b1c5e3f09c9f3b (patch)
tree4dc98598eb20b238742bb3277856c160c3c2bdb3
parent53eb9f12bb16d83a7f9b087243c7fff8d1945abc (diff)
Make QQmlLocale test robust against time and locale variations
JavaScript months start at 0, so don't check 1st of January and expect 1st of February. And don't hardcode the string we expect, test that we pass the result of the QQmlLocale wrapper correctly back to QML instead. Fixes: QTBUG-122081 Change-Id: I50a0875ec3b442bcfd8117cf261201ced4b87f0b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b5568a42f6ddefdbc26afab7f540768b684e9541) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit f3c35c119832bc01197b97d74e9e9099a20031cc)
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index 1f005ae5ca..67d15e5043 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -457,9 +457,10 @@ void tst_qqmllocale::toString_data()
const QDateTime midnight2000(QDate(2000, 1, 1), QTime(0, 0));
// 12 AM might not exist in this timezone (some timezones have transitions at midnight).
if (midnight2000.isValid()) {
- functionCallScript = "locale.toString(new Date(2000, 1, 1))";
- QTest::newRow(qPrintable(functionCallScript)) << "en_AU" << functionCallScript
- << QLatin1String("Tuesday, 1 February 2000 12:00:00 AM ") + midnight2000.timeZoneAbbreviation() << QString();
+ functionCallScript = "locale.toString(new Date(2000, 0, 1))";
+ const QLocale locale("en_AU");
+ QTest::newRow(qPrintable(functionCallScript)) << locale.name() << functionCallScript
+ << locale.toString(midnight2000, QLocale::LongFormat) << QString();
}
functionCallScript = "locale.toString(new Date(2022, 7, 16), [])";