aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllocale
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-19 10:10:52 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-25 10:09:25 +0200
commit510253aa0996a89e6029d244002a08615b2fb65b (patch)
tree90f34289ffe658189c2caa495a4b744df9ef0593 /tests/auto/qml/qqmllocale
parent5c672954e391d43e1fb94e6d76aaedc987dea468 (diff)
qv4dateobject.cpp: USE_QTZ_SYSTEM_TIMEZONE on more platforms
The only platform where we may have a semi-adequate native implementation of the time/date functions is windows. On all other platforms we should use QTimeZone::systemTimeZone() if possible as that at least gives us correct results when the system time zone doesn't change at runtime. Fixes: QTBUG-84474 Pick-to: 5.15 Change-Id: I34b01e12a751ee1c9b17735810e62e2e847f8446 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllocale')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index e3094db708..7d0c10a702 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -34,6 +34,7 @@
#include <QtCore/QDateTime>
#include <QtCore/qscopeguard.h>
#include <QtCore/qscopedpointer.h>
+#include <QtCore/qtimezone.h>
#include <qcolor.h>
#include "../../shared/util.h"
@@ -1297,6 +1298,13 @@ static void setTimeZone(const QByteArray &tz)
void tst_qqmllocale::timeZoneUpdated()
{
+ // Note: This test may not reliably hit the QEXPECT_FAIL clauses below if the initial
+ // system time zone is equivalent to either Australia/Brisbane or Asia/Kalkota.
+
+ // Initialize the system time zone, so that we actually _change_ something below.
+ QVERIFY2(QTimeZone::systemTimeZone().isValid(),
+ "You know, Toto, I do believe we're not in Kansas any more.");
+
QByteArray original(qgetenv("TZ"));
// Set the timezone to Brisbane time, AEST-10:00
@@ -1318,12 +1326,20 @@ void tst_qqmllocale::timeZoneUpdated()
QVERIFY2(!c.isError(), qPrintable(c.errorString()));
obj.reset(c.create());
QVERIFY(obj);
+
+#if !defined(Q_OS_WIN) && QT_CONFIG(timezone) && (!defined(Q_OS_LINUX) || defined(Q_OS_ANDROID))
+ QEXPECT_FAIL("", "Date.timeZoneUpdated() only works on non-Android Linux with QT_CONFIG(timezone).", Continue);
+#endif
QVERIFY(obj->property("success").toBool());
// Change to Indian time, IST-05:30
setTimeZone(QByteArray("Asia/Kolkata"));
QMetaObject::invokeMethod(obj.data(), "check");
+
+#if !defined(Q_OS_WIN) && QT_CONFIG(timezone) && (!defined(Q_OS_LINUX) || defined(Q_OS_ANDROID))
+ QEXPECT_FAIL("", "Date.timeZoneUpdated() only works on non-Android Linux with QT_CONFIG(timezone).", Continue);
+#endif
QVERIFY(obj->property("success").toBool());
}
#endif