aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmllocale/tst_qqmllocale.cpp')
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
index e74570261f..c39426375f 100644
--- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -47,6 +47,8 @@
#include <qcolor.h>
#include "../../shared/util.h"
+#include <time.h>
+
class tst_qqmllocale : public QQmlDataTest
{
Q_OBJECT
@@ -80,6 +82,7 @@ private slots:
void dateTimeFormat();
void timeFormat_data();
void timeFormat();
+ void timeZoneUpdated();
void dateToLocaleString_data();
void dateToLocaleString();
@@ -1214,6 +1217,44 @@ void tst_qqmllocale::stringLocaleCompare()
QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
}
+static void setTimeZone(const QByteArray &tz)
+{
+ qputenv("TZ", tz);
+#if defined(Q_OS_WIN32)
+ ::_tzset();
+#elif defined(Q_OS_UNIX)
+ ::tzset();
+#endif
+}
+
+void tst_qqmllocale::timeZoneUpdated()
+{
+#if !defined(Q_OS_WIN32) && !defined(Q_OS_UINX)
+ QSKIP("Timezone manipulation not available for this platform");
+#endif
+
+ QByteArray original(qgetenv("TZ"));
+
+ // Set the timezone to Brisbane time
+ setTimeZone(QByteArray("AEST-10:00"));
+
+ QQmlEngine e;
+ QQmlComponent c(&e, testFileUrl("timeZoneUpdated.qml"));
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->property("success").toBool(), true);
+
+ // Change to Indian time
+ setTimeZone(QByteArray("IST-05:30"));
+
+ QMetaObject::invokeMethod(obj.data(), "check");
+
+ // Reset to original time
+ setTimeZone(original);
+
+ QCOMPARE(obj->property("success").toBool(), true);
+}
+
QTEST_MAIN(tst_qqmllocale)
#include "tst_qqmllocale.moc"