summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-08-10 12:17:49 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-11-14 10:47:57 +0100
commitad11cab4842a4d35fe80641ae3eec7f2d8817652 (patch)
treef6c4a2454692edda7e82c8290835c3489cf8bcb9
parent103d307f2e596e5e7d2eb706117223bf65264e5f (diff)
Allow longer time-zone components on Android
Android uses its own time-zone naming, which includes a zone called "Canada/East-Saskatchewan", whose second component is 17 characters long. This violates a rule in the IANA naming scheme for zones, that limits components to 14 characters each. So tweak the isValidId() check to allow Android its long names. Android has added Outer Mongolian time-zones, which are as borked as many others in 1970, so blacklist those transitionEachZone() tests. Fixes: QTBUG-69128 Change-Id: I46f674f095431335b16900860d83b624257ae3bb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r--src/corelib/time/qtimezoneprivate.cpp6
-rw-r--r--tests/auto/corelib/time/qtimezone/BLACKLIST12
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp11
3 files changed, 25 insertions, 4 deletions
diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp
index 569b343187..00dc8b4ced 100644
--- a/src/corelib/time/qtimezoneprivate.cpp
+++ b/src/corelib/time/qtimezoneprivate.cpp
@@ -632,7 +632,13 @@ bool QTimeZonePrivate::isValidId(const QByteArray &ianaId)
// Somewhat slack hand-rolled version:
const int MinSectionLength = 1;
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+ // Android has its own naming of zones.
+ // "Canada/East-Saskatchewan" has a 17-character second component.
+ const int MaxSectionLength = 17;
+#else
const int MaxSectionLength = 14;
+#endif
int sectionLength = 0;
for (const char *it = ianaId.begin(), * const end = ianaId.end(); it != end; ++it, ++sectionLength) {
const char ch = *it;
diff --git a/tests/auto/corelib/time/qtimezone/BLACKLIST b/tests/auto/corelib/time/qtimezone/BLACKLIST
index 840c3b1181..b820bab3d9 100644
--- a/tests/auto/corelib/time/qtimezone/BLACKLIST
+++ b/tests/auto/corelib/time/qtimezone/BLACKLIST
@@ -2,10 +2,6 @@
[dataStreamTest]
android
-# QTBUG-69128
-[isTimeZoneIdAvailable]
-android
-
# QTBUG-69129
[specificTransition]
android
@@ -75,10 +71,14 @@ android
android
[transitionEachZone:Asia/Chita@1970]
android
+[transitionEachZone:Asia/Choibalsan@1970]
+android
[transitionEachZone:Asia/Dushanbe@1970]
android
[transitionEachZone:Asia/Ho_Chi_Minh@1970]
android
+[transitionEachZone:Asia/Hovd@1970]
+android
[transitionEachZone:Asia/Kathmandu@1970]
android
[transitionEachZone:Asia/Katmandu@1970]
@@ -109,6 +109,10 @@ android
android
[transitionEachZone:Asia/Thimphu@1970]
android
+[transitionEachZone:Asia/Ulaanbaatar@1970]
+android
+[transitionEachZone:Asia/Ulan_Bator@1970]
+android
[transitionEachZone:Asia/Ust-Nera@1970]
android
[transitionEachZone:Atlantic/Cape_Verde@1970]
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index 9f51ff8ba8..f425691d9c 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -706,6 +706,7 @@ void tst_QTimeZone::isValidId_data()
// a-z, A-Z, 0-9, '.', '-', '_' are valid chars
// Can't start with '-'
// Parts separated by '/', each part min 1 and max of 14 chars
+ // (Android has parts with lengths up to 17, so tolerates this as a special case.)
#define TESTSET(name, section, valid) \
QTest::newRow(name " front") << QByteArray(section "/xyz/xyz") << valid; \
QTest::newRow(name " middle") << QByteArray("xyz/" section "/xyz") << valid; \
@@ -713,8 +714,13 @@ void tst_QTimeZone::isValidId_data()
TESTSET("empty", "", false);
TESTSET("minimal", "m", true);
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+ TESTSET("maximal", "East-Saskatchewan", true); // Android actually uses this
+ TESTSET("too long", "North-Saskatchewan", false); // ... but thankfully not this.
+#else
TESTSET("maximal", "12345678901234", true);
TESTSET("too long", "123456789012345", false);
+#endif
TESTSET("bad hyphen", "-hyphen", false);
TESTSET("good hyphen", "hy-phen", true);
@@ -759,8 +765,13 @@ void tst_QTimeZone::isValidId_data()
QTest::newRow("a,z alone") << QByteArray("a,z") << false;
QTest::newRow("/z alone") << QByteArray("/z") << false;
QTest::newRow("-z alone") << QByteArray("-z") << false;
+#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+ QTest::newRow("long alone") << QByteArray("12345678901234567") << true;
+ QTest::newRow("over-long alone") << QByteArray("123456789012345678") << false;
+#else
QTest::newRow("long alone") << QByteArray("12345678901234") << true;
QTest::newRow("over-long alone") << QByteArray("123456789012345") << false;
+#endif
#else
QSKIP("This test requires a Qt -developer-build.");