conversion/timezoneconverter.cpp tests/timezonetest.cpp tests/timezonetest.h
Christian Mollekopf
mollekopf at kolabsys.com
Wed Nov 27 15:21:48 CET 2013
conversion/timezoneconverter.cpp | 16 +++++++++-------
tests/timezonetest.cpp | 34 ++++++++++++++++++++++++++++++++++
tests/timezonetest.h | 2 ++
3 files changed, 45 insertions(+), 7 deletions(-)
New commits:
commit 65eb2db198f81175f3ec2665f46d717f5a9a4c33
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed Nov 27 15:19:50 2013 +0100
Removed legacy timezone conversion since it's broken, a couple of timezone conversion tests.
The legacy timezone support just accepted any random string, which is of course not very useful.
diff --git a/conversion/timezoneconverter.cpp b/conversion/timezoneconverter.cpp
index 4736b68..7a75a04 100644
--- a/conversion/timezoneconverter.cpp
+++ b/conversion/timezoneconverter.cpp
@@ -39,13 +39,15 @@ QString TimezoneConverter::normalizeTimezone(const QString& tz)
if (guessedTimezone.isEmpty()) {
guessedTimezone = fromGMTOffsetTimezone(tz);
}
- if (guessedTimezone.isEmpty()) {
- //slower but also finds outdated zones
- timezone = KSystemTimeZones::readZone(tz);
- if (timezone.isValid()) {
- return tz;
- }
- }
+// if (guessedTimezone.isEmpty()) {
+// //slower but also finds outdated zones
+// timezone = KSystemTimeZones::readZone(tz);
+// if (timezone.isValid()) {
+// //This thinks all kinds of shit is valid, including /etc/localtime. Let's verify again.
+// qDebug() << "found " << tz;
+// return tz;
+// }
+// }
Debug() << "Guessed timezone and found: " << guessedTimezone;
return guessedTimezone;
}
diff --git a/tests/timezonetest.cpp b/tests/timezonetest.cpp
index d382425..cf31012 100644
--- a/tests/timezonetest.cpp
+++ b/tests/timezonetest.cpp
@@ -160,9 +160,17 @@ void TimezoneTest::testFindLegacyTimezone()
{
const QString normalized = TimezoneConverter::normalizeTimezone("US/Pacific");
kDebug() << normalized;
+ QEXPECT_FAIL("", "Currently broken", Continue);
QVERIFY(!normalized.isEmpty());
}
+void TimezoneTest::testIgnoreInvalidTimezone()
+{
+ const QString normalized = TimezoneConverter::normalizeTimezone("FOOOOBAR");
+ kDebug() << normalized;
+ QVERIFY(normalized.isEmpty());
+}
+
void TimezoneTest::testTimezoneDaemonAvailable()
{
//With KDE it should be available and with libcalendaring it should return true
@@ -174,9 +182,35 @@ void TimezoneTest::testUTCOffset()
const Kolab::cDateTime expected(2013, 10, 23, 2, 0 ,0, true);
const KDateTime input(KDateTime::fromString("2013-10-23T04:00:00+02:00", KDateTime::RFC3339Date));
const Kolab::cDateTime result = Kolab::Conversion::fromDate(input);
+ QVERIFY(!Kolab::ErrorHandler::instance().errorOccured());
QCOMPARE(result, expected);
}
+void TimezoneTest::localTimezone()
+{
+ {
+ const Kolab::cDateTime result = Kolab::Conversion::fromDate(KDateTime(QDate(2013, 10, 10), QTime(2, 0, 0), KDateTime::LocalZone));
+ QVERIFY(!result.timezone().empty());
+ QVERIFY(!Kolab::ErrorHandler::instance().errorOccured());
+ }
+ {
+ const Kolab::cDateTime result = Kolab::Conversion::fromDate(KDateTime(QDate(2013, 10, 10), QTime(2, 0, 0), KDateTime::ClockTime));
+ QVERIFY(!Kolab::ErrorHandler::instance().errorOccured());
+ }
+ {
+ const Kolab::cDateTime result = Kolab::Conversion::fromDate(KDateTime(QDate(2013, 10, 10), QTime(2, 0, 0), KDateTime::TimeZone));
+ QVERIFY(result.timezone().empty());
+ QVERIFY(!Kolab::ErrorHandler::instance().errorOccured());
+ }
+ {
+ KDateTime dt(QDate(2013, 10, 10), QTime(2, 0, 0), KTimeZone("/etc/localzone"));
+ const Kolab::cDateTime result = Kolab::Conversion::fromDate(dt);
+ kDebug() << result.timezone();
+ QVERIFY(result.timezone().empty());
+ QVERIFY(!Kolab::ErrorHandler::instance().errorOccured());
+ }
+}
+
QTEST_MAIN( TimezoneTest )
#include "timezonetest.moc"
diff --git a/tests/timezonetest.h b/tests/timezonetest.h
index fa518a6..280e2cc 100644
--- a/tests/timezonetest.h
+++ b/tests/timezonetest.h
@@ -34,8 +34,10 @@ private slots:
void testKolabObjectWriter();
void testKolabObjectReader();
void testFindLegacyTimezone();
+ void testIgnoreInvalidTimezone();
void testTimezoneDaemonAvailable();
void testUTCOffset();
+ void localTimezone();
};
#endif // TIMEZONETEST_H
More information about the commits
mailing list