Merge lp:~charlesk/indicator-datetime/15.04-lp-1473068-sanitize-inputs-to-GTimeZoneNew into lp:indicator-datetime/15.04

Proposed by Charles Kerr
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 425
Merged at revision: 418
Proposed branch: lp:~charlesk/indicator-datetime/15.04-lp-1473068-sanitize-inputs-to-GTimeZoneNew
Merge into: lp:indicator-datetime/15.04
Diff against target: 719 lines (+397/-102)
8 files modified
debian/changelog (+23/-27)
src/engine-eds.cpp (+68/-28)
tests/CMakeLists.txt (+7/-16)
tests/run-eds-ics-test.sh (+30/-31)
tests/test-eds-ics-tzids-2.cpp (+88/-0)
tests/test-eds-ics-tzids-2.ics (+38/-0)
tests/test-eds-ics-tzids.cpp (+87/-0)
tests/test-eds-ics-tzids.ics (+56/-0)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/15.04-lp-1473068-sanitize-inputs-to-GTimeZoneNew
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Antti Kaijanmäki (community) Approve
dobey (community) Approve
Review via email: mp+264338@code.launchpad.net

Commit message

Get icaltimezone structures from EDS rather than assuming the tzid will always be GTimeZone friendly.

Description of the change

When we get a tzid from EDS, have EDS convert it into an icaltimezone struct itself, then use =that= to create our own GTimeZones. This way we have a better chance of getting a tzid that GTimeZone will be happy with.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
421. By Charles Kerr

avoid the round trip to EDS if we can figure out the tzid from libical first

422. By Charles Kerr

add dobey's test case that has 'TZID:Pacific Time (US & Canada)'

423. By Charles Kerr

oops, disabling the other tests was only supposed to be to speed up local tests & wasn't supposed to be pushed

424. By Charles Kerr

add dobey's tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
425. By Charles Kerr

add a g_warning() if we can't suss out the tzid

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
426. By Charles Kerr

sync with trunk

Revision history for this message
Charles Kerr (charlesk) wrote :

approving trunk sync to make build happy

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-06-18 19:25:41 +0000
+++ debian/changelog 2015-07-10 17:29:43 +0000
@@ -1,3 +1,26 @@
1indicator-datetime (13.10.0+15.10.20150624-0ubuntu1) wily; urgency=medium
2
3 [ Charles Kerr ]
4 * Speedups/cleanups to the EDS regression tests
5
6 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 24 Jun 2015 12:51:27 +0000
7
8indicator-datetime (13.10.0+15.10.20150622-0ubuntu1) wily; urgency=medium
9
10 [ Charles Kerr ]
11 * Fix bugs relating to timezones and triggers from clock-app alarms.
12 (LP: #1456281, #1465806)
13
14 -- CI Train Bot <ci-train-bot@canonical.com> Mon, 22 Jun 2015 18:03:38 +0000
15
16indicator-datetime (13.10.0+15.10.20150515-0ubuntu1) wily; urgency=medium
17
18 [ Charles Kerr ]
19 * Honor the 'other vibrations' setting to enable/disable vibrations
20 when alarm notifications are shown.
21
22 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 15 May 2015 16:41:41 +0000
23
1indicator-datetime (13.10.0+15.04.20150618-0ubuntu1) vivid; urgency=medium24indicator-datetime (13.10.0+15.04.20150618-0ubuntu1) vivid; urgency=medium
225
3 [ Charles Kerr ]26 [ Charles Kerr ]
@@ -5,33 +28,6 @@
528
6 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 18 Jun 2015 19:25:41 +000029 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 18 Jun 2015 19:25:41 +0000
730
8indicator-datetime (13.10.0+15.04.20150521-0ubuntu1) vivid; urgency=medium
9
10 [ Charles Kerr ]
11 * Fix regression that caused nonrepeating alarms to go off at the
12 wrong time. (LP: #1456281)
13
14 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 21 May 2015 15:24:31 +0000
15
16indicator-datetime (13.10.0+15.04.20150515-0ubuntu1) vivid; urgency=medium
17
18 [ Charles Kerr ]
19 * Honor the 'other vibrations' setting to enable/disable vibrations
20 when alarm notifications are shown.
21
22 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 15 May 2015 19:33:54 +0000
23
24indicator-datetime (13.10.0+15.04.20150508.2-0ubuntu1) vivid; urgency=medium
25
26 [ CI Train Bot ]
27 * New rebuild forced.
28
29 [ Charles Kerr ]
30 * If the "X-CANONICAL-ACTIVATION-URL" x-prop is defined in the VTODO
31 or VEVENT, use it for url delegation. (LP: #1426519)
32
33 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 08 May 2015 20:01:09 +0000
34
35indicator-datetime (13.10.0+15.04.20150406-0ubuntu1) vivid; urgency=medium31indicator-datetime (13.10.0+15.04.20150406-0ubuntu1) vivid; urgency=medium
3632
37 [ Charles Kerr ]33 [ Charles Kerr ]
3834
=== modified file 'src/engine-eds.cpp'
--- src/engine-eds.cpp 2015-06-18 04:53:52 +0000
+++ src/engine-eds.cpp 2015-07-10 17:29:43 +0000
@@ -47,16 +47,21 @@
47{47{
48public:48public:
4949
50 Impl():50 Impl()
51 m_cancellable(g_cancellable_new())
52 {51 {
53 e_source_registry_new(m_cancellable, on_source_registry_ready, this);52 auto cancellable_deleter = [](GCancellable * c) {
53 g_cancellable_cancel(c);
54 g_clear_object(&c);
55 };
56
57 m_cancellable = std::shared_ptr<GCancellable>(g_cancellable_new(), cancellable_deleter);
58
59 e_source_registry_new(m_cancellable.get(), on_source_registry_ready, this);
54 }60 }
5561
56 ~Impl()62 ~Impl()
57 {63 {
58 g_cancellable_cancel(m_cancellable);64 m_cancellable.reset();
59 g_clear_object(&m_cancellable);
6065
61 while(!m_sources.empty())66 while(!m_sources.empty())
62 remove_source(*m_sources.begin());67 remove_source(*m_sources.begin());
@@ -131,9 +136,9 @@
131 e_cal_client_get_object_list_as_comps(136 e_cal_client_get_object_list_as_comps(
132 client,137 client,
133 sexp,138 sexp,
134 m_cancellable,139 m_cancellable.get(),
135 on_alarm_component_list_ready,140 on_alarm_component_list_ready,
136 new ClientSubtask(main_task, client, color));141 new ClientSubtask(main_task, client, m_cancellable, color));
137 g_clear_pointer(&sexp, g_free);142 g_clear_pointer(&sexp, g_free);
138143
139 // ask EDS about events that occur in this window...144 // ask EDS about events that occur in this window...
@@ -142,9 +147,9 @@
142 e_cal_client_get_object_list_as_comps(147 e_cal_client_get_object_list_as_comps(
143 client,148 client,
144 sexp,149 sexp,
145 m_cancellable,150 m_cancellable.get(),
146 on_event_component_list_ready,151 on_event_component_list_ready,
147 new ClientSubtask(main_task, client, color));152 new ClientSubtask(main_task, client, m_cancellable, color));
148 g_clear_pointer(&sexp, g_free);153 g_clear_pointer(&sexp, g_free);
149154
150 g_clear_pointer(&sexp_fmt, g_free);155 g_clear_pointer(&sexp_fmt, g_free);
@@ -160,7 +165,7 @@
160 e_cal_client_get_object(kv.second,165 e_cal_client_get_object(kv.second,
161 appointment.uid.c_str(),166 appointment.uid.c_str(),
162 nullptr,167 nullptr,
163 m_cancellable,168 m_cancellable.get(),
164 on_object_ready_for_disable,169 on_object_ready_for_disable,
165 this);170 this);
166 }171 }
@@ -271,7 +276,7 @@
271 g_debug("%s connecting a client to source %s", G_STRFUNC, source_uid);276 g_debug("%s connecting a client to source %s", G_STRFUNC, source_uid);
272 e_cal_client_connect(source,277 e_cal_client_connect(source,
273 source_type,278 source_type,
274 self->m_cancellable,279 self->m_cancellable.get(),
275 on_client_connected,280 on_client_connected,
276 gself);281 gself);
277 }282 }
@@ -306,7 +311,7 @@
306 // now create a view for it so that we can listen for changes311 // now create a view for it so that we can listen for changes
307 e_cal_client_get_view (ecc,312 e_cal_client_get_view (ecc,
308 "#t", // match all313 "#t", // match all
309 self->m_cancellable,314 self->m_cancellable.get(),
310 on_client_view_ready,315 on_client_view_ready,
311 self);316 self);
312317
@@ -429,7 +434,7 @@
429 e_cal_client_get_object_list_as_comps(434 e_cal_client_get_object_list_as_comps(
430 client,435 client,
431 sexp,436 sexp,
432 m_cancellable,437 m_cancellable.get(),
433 ensure_client_alarms_have_triggers_async_cb,438 ensure_client_alarms_have_triggers_async_cb,
434 this);439 this);
435440
@@ -510,7 +515,7 @@
510 e_cal_client_modify_objects(client,515 e_cal_client_modify_objects(client,
511 modify_slist,516 modify_slist,
512 E_CAL_OBJ_MOD_ALL,517 E_CAL_OBJ_MOD_ALL,
513 m_cancellable,518 m_cancellable.get(),
514 ensure_canonical_alarms_have_triggers_async_cb,519 ensure_canonical_alarms_have_triggers_async_cb,
515 this);520 this);
516521
@@ -580,13 +585,16 @@
580 {585 {
581 std::shared_ptr<Task> task;586 std::shared_ptr<Task> task;
582 ECalClient* client;587 ECalClient* client;
588 std::shared_ptr<GCancellable> cancellable;
583 std::string color;589 std::string color;
584590
585 ClientSubtask(const std::shared_ptr<Task>& task_in,591 ClientSubtask(const std::shared_ptr<Task>& task_in,
586 ECalClient* client_in,592 ECalClient* client_in,
593 const std::shared_ptr<GCancellable>& cancellable_in,
587 const char* color_in):594 const char* color_in):
588 task(task_in),595 task(task_in),
589 client(client_in)596 client(client_in),
597 cancellable(cancellable_in)
590 {598 {
591 if (color_in)599 if (color_in)
592 color = color_in;600 color = color_in;
@@ -720,15 +728,44 @@
720 }728 }
721729
722 static DateTime730 static DateTime
723 datetime_from_component_date_time(const ECalComponentDateTime & in,731 datetime_from_component_date_time(ECalClient * client,
724 GTimeZone * default_timezone)732 std::shared_ptr<GCancellable> & cancellable,
733 const ECalComponentDateTime & in,
734 GTimeZone * default_timezone)
725 {735 {
726 DateTime out;736 DateTime out;
727
728 g_return_val_if_fail(in.value != nullptr, out);737 g_return_val_if_fail(in.value != nullptr, out);
729738
730 auto gtz = in.tzid == nullptr ? g_time_zone_ref(default_timezone)739 GTimeZone * gtz {};
731 : g_time_zone_new(in.tzid);740 if (in.tzid != nullptr)
741 {
742 auto itz = icaltimezone_get_builtin_timezone_from_tzid(in.tzid); // usually works
743
744 if (itz == nullptr) // fallback
745 itz = icaltimezone_get_builtin_timezone(in.tzid);
746
747 if (itz == nullptr) // ok we have a strange tzid... ask EDS to look it up in VTIMEZONES
748 e_cal_client_get_timezone_sync(client, in.tzid, &itz, cancellable.get(), nullptr);
749
750 const char * tzid;
751 if (itz != nullptr)
752 {
753 tzid = icaltimezone_get_location(itz);
754 }
755 else
756 {
757 g_warning("Unrecognized TZID: '%s'", in.tzid);
758 tzid = nullptr;
759 }
760
761 gtz = g_time_zone_new(tzid);
762 g_debug("%s eccdt.tzid -> offset is %d", G_STRLOC, in.tzid, (int)g_time_zone_get_offset(gtz,0));
763 }
764 else
765 {
766 gtz = g_time_zone_ref(default_timezone);
767 }
768
732 out = DateTime(gtz,769 out = DateTime(gtz,
733 in.value->year,770 in.value->year,
734 in.value->month,771 in.value->month,
@@ -773,7 +810,10 @@
773 }810 }
774811
775 static Appointment812 static Appointment
776 get_appointment(ECalComponent * component, GTimeZone * gtz)813 get_appointment(ECalClient * client,
814 std::shared_ptr<GCancellable> & cancellable,
815 ECalComponent * component,
816 GTimeZone * gtz)
777 {817 {
778 Appointment baseline;818 Appointment baseline;
779819
@@ -792,13 +832,13 @@
792 // get appointment.begin832 // get appointment.begin
793 ECalComponentDateTime eccdt_tmp {};833 ECalComponentDateTime eccdt_tmp {};
794 e_cal_component_get_dtstart(component, &eccdt_tmp);834 e_cal_component_get_dtstart(component, &eccdt_tmp);
795 baseline.begin = datetime_from_component_date_time(eccdt_tmp, gtz);835 baseline.begin = datetime_from_component_date_time(client, cancellable, eccdt_tmp, gtz);
796 e_cal_component_free_datetime(&eccdt_tmp);836 e_cal_component_free_datetime(&eccdt_tmp);
797837
798 // get appointment.end838 // get appointment.end
799 e_cal_component_get_dtend(component, &eccdt_tmp);839 e_cal_component_get_dtend(component, &eccdt_tmp);
800 baseline.end = eccdt_tmp.value != nullptr840 baseline.end = eccdt_tmp.value != nullptr
801 ? datetime_from_component_date_time(eccdt_tmp, gtz)841 ? datetime_from_component_date_time(client, cancellable, eccdt_tmp, gtz)
802 : baseline.begin;842 : baseline.begin;
803 e_cal_component_free_datetime(&eccdt_tmp);843 e_cal_component_free_datetime(&eccdt_tmp);
804844
@@ -839,7 +879,7 @@
839 ClientSubtask * subtask,879 ClientSubtask * subtask,
840 GTimeZone * gtz)880 GTimeZone * gtz)
841 {881 {
842 // events with alarms are covered by add_alarm_to_subtask(),882 // events with alarms are covered by add_alarms_to_subtask(),
843 // so skip them here883 // so skip them here
844 auto auids = e_cal_component_get_alarm_uids(component);884 auto auids = e_cal_component_get_alarm_uids(component);
845 const bool has_alarms = auids != nullptr;885 const bool has_alarms = auids != nullptr;
@@ -850,7 +890,7 @@
850 // add it. simple, eh?890 // add it. simple, eh?
851 if (is_component_interesting(component))891 if (is_component_interesting(component))
852 {892 {
853 Appointment appointment = get_appointment(component, gtz);893 Appointment appointment = get_appointment(subtask->client, subtask->cancellable, component, gtz);
854 appointment.color = subtask->color;894 appointment.color = subtask->color;
855 subtask->task->appointments.push_back(appointment);895 subtask->task->appointments.push_back(appointment);
856 }896 }
@@ -866,7 +906,7 @@
866 if (!is_component_interesting(component))906 if (!is_component_interesting(component))
867 return;907 return;
868908
869 Appointment baseline = get_appointment(component, gtz);909 Appointment baseline = get_appointment(subtask->client, subtask->cancellable, component, gtz);
870 baseline.color = subtask->color;910 baseline.color = subtask->color;
871911
872 /**912 /**
@@ -958,7 +998,7 @@
958 e_cal_client_modify_object(E_CAL_CLIENT(client),998 e_cal_client_modify_object(E_CAL_CLIENT(client),
959 e_cal_component_get_icalcomponent(ecc),999 e_cal_component_get_icalcomponent(ecc),
960 E_CAL_OBJ_MOD_THIS,1000 E_CAL_OBJ_MOD_THIS,
961 static_cast<Impl*>(gself)->m_cancellable,1001 static_cast<Impl*>(gself)->m_cancellable.get(),
962 on_disable_done,1002 on_disable_done,
963 nullptr);1003 nullptr);
9641004
@@ -990,7 +1030,7 @@
990 std::set<ESource*> m_sources;1030 std::set<ESource*> m_sources;
991 std::map<ESource*,ECalClient*> m_clients;1031 std::map<ESource*,ECalClient*> m_clients;
992 std::map<ESource*,ECalClientView*> m_views;1032 std::map<ESource*,ECalClientView*> m_views;
993 GCancellable* m_cancellable {};1033 std::shared_ptr<GCancellable> m_cancellable;
994 ESourceRegistry* m_source_registry {};1034 ESourceRegistry* m_source_registry {};
995 guint m_rebuild_tag {};1035 guint m_rebuild_tag {};
996 time_t m_rebuild_deadline {};1036 time_t m_rebuild_deadline {};
9971037
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-06-18 04:52:52 +0000
+++ tests/CMakeLists.txt 2015-07-10 17:29:43 +0000
@@ -70,13 +70,6 @@
70## 70##
7171
72find_program(DBUS_RUNNER dbus-test-runner)72find_program(DBUS_RUNNER dbus-test-runner)
73find_program(EVOLUTION_CALENDAR_FACTORY evolution-calendar-factory PATHS /usr/lib/evolution/)
74find_program(EVOLUTION_SOURCE_REGISTRY evolution-source-registry PATHS /usr/lib/evolution/)
75find_program(GVFSD gvfsd PATHS /usr/lib/gvfs/)
76OPTION(EVOLUTION_SOURCE_SERVICE_NAME "DBus name for source registry")
77if(NOT EVOLUTION_SOURCE_SERVICE_NAME)
78 set(EVOLUTION_SOURCE_SERVICE_NAME "org.gnome.evolution.dataserver.Sources3")
79endif()
8073
81function(add_eds_ics_test_by_name name)74function(add_eds_ics_test_by_name name)
82 set (TEST_NAME ${name})75 set (TEST_NAME ${name})
@@ -84,21 +77,19 @@
84 target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})77 target_link_libraries (${TEST_NAME} indicatordatetimeservice gtest ${DBUSTEST_LIBRARIES} ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBS})
85 add_test (${TEST_NAME}78 add_test (${TEST_NAME}
86 ${CMAKE_CURRENT_SOURCE_DIR}/run-eds-ics-test.sh79 ${CMAKE_CURRENT_SOURCE_DIR}/run-eds-ics-test.sh
87 ${DBUS_RUNNER} # arg1: dbus-test-runner exec80 ${DBUS_RUNNER} # arg1: dbus-test-runner exec
88 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path81 ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} # arg2: test executable path
89 ${TEST_NAME} # arg3: test name82 ${TEST_NAME} # arg3: test name
90 ${EVOLUTION_CALENDAR_FACTORY} # arg4: evolution-calendar-factory exec83 ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg4: base directory for config file template
91 ${EVOLUTION_SOURCE_SERVICE_NAME} # arg5: dbus name for source registry 84 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics) # arg5: the ical file for this test
92 ${EVOLUTION_SOURCE_REGISTRY} # arg6: evolution-source-registry exec
93 ${GVFSD} # arg7: gvfsd exec
94 ${CMAKE_CURRENT_SOURCE_DIR}/test-eds-ics-config-files # arg8: base directory for config file template
95 ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}.ics) # arg9: the ical file for this test
96endfunction()85endfunction()
97add_eds_ics_test_by_name(test-eds-ics-all-day-events)86add_eds_ics_test_by_name(test-eds-ics-all-day-events)
98add_eds_ics_test_by_name(test-eds-ics-repeating-events)87add_eds_ics_test_by_name(test-eds-ics-repeating-events)
99add_eds_ics_test_by_name(test-eds-ics-nonrepeating-events)88add_eds_ics_test_by_name(test-eds-ics-nonrepeating-events)
100add_eds_ics_test_by_name(test-eds-ics-repeating-valarms)89add_eds_ics_test_by_name(test-eds-ics-repeating-valarms)
101add_eds_ics_test_by_name(test-eds-ics-missing-trigger)90add_eds_ics_test_by_name(test-eds-ics-missing-trigger)
91add_eds_ics_test_by_name(test-eds-ics-tzids)
92add_eds_ics_test_by_name(test-eds-ics-tzids-2)
10293
10394
104# disabling the timezone unit tests because they require95# disabling the timezone unit tests because they require
10596
=== modified file 'tests/run-eds-ics-test.sh'
--- tests/run-eds-ics-test.sh 2015-05-21 11:09:52 +0000
+++ tests/run-eds-ics-test.sh 2015-07-10 17:29:43 +0000
@@ -1,19 +1,22 @@
1#!/bin/sh1#!/bin/sh
22
3echo ARG0=$0 # this script3SELF=$0 # this script
4echo ARG1=$1 # full executable path of dbus-test-runner4TEST_RUNNER=$1 # full executable path of dbus-test-runner
5echo ARG2=$2 # full executable path of test app5TEST_EXEC=$2 # full executable path of test app
6echo ARG3=$3 # test name6TEST_NAME=$3 # test name
7echo ARG4=$4 # full executable path of evolution-calendar-factory7CONFIG_DIR=$4 # config files
8echo ARG5=$5 # bus service name of calendar factory8ICS_FILE=$5 # ical file holding test data
9echo ARG6=$6 # full exectuable path of evolution-source-registry9
10echo ARG7=$7 # full executable path of gvfs10echo "this script: ${SELF}"
11echo ARG8=$8 # config files11echo "test-runner: ${TEST_RUNNER}"
12echo ARG8=$9 # ics file12echo "test-exec: ${TEST_EXEC}"
1313echo "test-name: ${TEST_NAME}"
14# set up the tmpdir and tell the shell to purge it when we exit14echo "config-dir: ${CONFIG_DIR}"
15export TEST_TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d $3-XXXXXXXXXX) || exit 115echo "ics-file: ${ICS_FILE}"
16echo "running test '$3' in ${TEST_TMP_DIR}"16
17# set up the tmpdir
18export TEST_TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d ${TEST_NAME}-XXXXXXXXXX) || exit 1
19echo "running test '${TEST_NAME}' in ${TEST_TMP_DIR}"
1720
18# set up the environment variables21# set up the environment variables
19export QT_QPA_PLATFORM=minimal22export QT_QPA_PLATFORM=minimal
@@ -40,23 +43,19 @@
40rm -rf ${XDG_DATA_HOME}43rm -rf ${XDG_DATA_HOME}
4144
42# if there are canned config files for this test, move them into place now45# if there are canned config files for this test, move them into place now
43if [ -d $8 ]; then46if [ -d ${CONFIG_DIR} ]; then
44 echo "copying files from $8 to $HOME"47 echo "copying files from ${CONFIG_DIR} to $HOME"
45 cp --verbose --archive $8/. $HOME48 cp --verbose --archive ${CONFIG_DIR}/. $HOME
46fi49fi
4750
48# if there's a specific ics file to test, copy it on top of the canned confilg files51# if there's a specific ics file to test, copy it on top of the canned config files
49if [ -e $9 ]; then52if [ -e ${ICS_FILE} ]; then
50 echo "copying $9 into $HOME"53 echo "copying ${ICS_FILE} into $HOME"
51 cp --verbose --archive $9 ${XDG_DATA_HOME}/evolution/tasks/system/tasks.ics54 cp --verbose --archive ${ICS_FILE} ${XDG_DATA_HOME}/evolution/tasks/system/tasks.ics
52fi55fi
5356
54# run dbus-test-runner57# run the test
55$1 --keep-env --max-wait=90 \58${TEST_RUNNER} --keep-env --max-wait=90 --task ${TEST_EXEC} --task-name ${TEST_NAME} --wait-until-complete
56--task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \
57--task $4 --task-name "evolution" --wait-until-complete -r
58#--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \
59#--task $7 --task-name "gvfsd" -r
60rv=$?59rv=$?
6160
62# if the test passed, blow away the tmpdir61# if the test passed, blow away the tmpdir
6362
=== added file 'tests/test-eds-ics-tzids-2.cpp'
--- tests/test-eds-ics-tzids-2.cpp 1970-01-01 00:00:00 +0000
+++ tests/test-eds-ics-tzids-2.cpp 2015-07-10 17:29:43 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Charles Kerr <charles.kerr@canonical.com>
18 */
19
20#include <algorithm>
21
22#include <datetime/alarm-queue-simple.h>
23#include <datetime/clock-mock.h>
24#include <datetime/engine-eds.h>
25#include <datetime/planner-range.h>
26
27#include <gtest/gtest.h>
28
29#include "glib-fixture.h"
30#include "print-to.h"
31#include "timezone-mock.h"
32#include "wakeup-timer-mock.h"
33
34using namespace unity::indicator::datetime;
35using VAlarmFixture = GlibFixture;
36
37/***
38****
39***/
40
41TEST_F(VAlarmFixture, MultipleAppointments)
42{
43 // start the EDS engine
44 auto engine = std::make_shared<EdsEngine>();
45
46 // we need a consistent timezone for the planner and our local DateTimes
47 constexpr char const * zone_str {"America/Los_Angeles"};
48 auto tz = std::make_shared<MockTimezone>(zone_str);
49 auto gtz = g_time_zone_new(zone_str);
50
51 // make a planner that looks at the first half of 2015 in EDS
52 auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
53 const DateTime range_begin {gtz, 2006,1, 1, 0, 0, 0.0};
54 const DateTime range_end {gtz, 2015,12,31,23,59,59.5};
55 planner->range().set(std::make_pair(range_begin, range_end));
56
57 // give EDS a moment to load
58 if (planner->appointments().get().empty()) {
59 g_message("waiting a moment for EDS to load...");
60 auto on_appointments_changed = [this](const std::vector<Appointment>& appointments){
61 g_message("ah, they loaded");
62 if (!appointments.empty())
63 g_main_loop_quit(loop);
64 };
65 core::ScopedConnection conn(planner->appointments().changed().connect(on_appointments_changed));
66 constexpr int max_wait_sec = 10;
67 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
68 }
69
70 // what we expect to get...
71 std::array<Appointment,1> expected_appts;
72 auto appt = &expected_appts[0];
73 appt->uid = "109264742";
74 appt->color = "#becedd";
75 appt->summary = "National Incubator Initiative for Clean Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar";
76 appt->begin = DateTime{gtz,2014,1,21,11,0,0};
77 appt->end = DateTime{gtz,2014,1,21,13,0,0};
78 appt->alarms = std::vector<Alarm>{ Alarm({"Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) };
79
80 // compare it to what we actually loaded...
81 const auto appts = planner->appointments().get();
82 EXPECT_EQ(expected_appts.size(), appts.size());
83 for (size_t i=0, n=std::min(appts.size(),expected_appts.size()); i<n; i++)
84 EXPECT_EQ(expected_appts[i], appts[i]);
85
86 // cleanup
87 g_time_zone_unref(gtz);
88}
089
=== added file 'tests/test-eds-ics-tzids-2.ics'
--- tests/test-eds-ics-tzids-2.ics 1970-01-01 00:00:00 +0000
+++ tests/test-eds-ics-tzids-2.ics 2015-07-10 17:29:43 +0000
@@ -0,0 +1,38 @@
1BEGIN:VCALENDAR
2CALSCALE:GREGORIAN
3PRODID:-//Ximian//NONSGML Evolution Calendar//EN
4VERSION:2.0
5X-EVOLUTION-DATA-REVISION:2015-07-09T19:41:50.123217Z(3)
6BEGIN:VTIMEZONE
7TZID:Pacific Time (US & Canada)
8BEGIN:STANDARD
9DTSTART:20061105T020000
10RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
11TZOFFSETFROM:-0700
12TZOFFSETTO:-0800
13END:STANDARD
14BEGIN:DAYLIGHT
15DTSTART:20070311T020000
16RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
17TZOFFSETFROM:-0800
18TZOFFSETTO:-0700
19TZNAME:Daylight Savings Time
20END:DAYLIGHT
21END:VTIMEZONE
22BEGIN:VEVENT
23DTSTART;TZID=Pacific Time (US & Canada):20140121T110000
24DTEND;TZID=Pacific Time (US & Canada):20140121T130000
25UID:109264742
26DTSTAMP:20140120T000718Z
27DESCRIPTION: Event description
28SUMMARY;ENCODING=QUOTED-PRINTABLE:National Incubator Initiative for Clean
29 Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar
30CREATED:20140120T000741Z
31LAST-MODIFIED:20140120T000741Z
32BEGIN:VALARM
33TRIGGER;VALUE=DURATION:-PT15M
34ACTION:DISPLAY
35DESCRIPTION:Reminder
36END:VALARM
37END:VEVENT
38END:VCALENDAR
039
=== added file 'tests/test-eds-ics-tzids.cpp'
--- tests/test-eds-ics-tzids.cpp 1970-01-01 00:00:00 +0000
+++ tests/test-eds-ics-tzids.cpp 2015-07-10 17:29:43 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Charles Kerr <charles.kerr@canonical.com>
18 */
19
20#include <algorithm>
21
22#include <datetime/alarm-queue-simple.h>
23#include <datetime/clock-mock.h>
24#include <datetime/engine-eds.h>
25#include <datetime/planner-range.h>
26
27#include <gtest/gtest.h>
28
29#include "glib-fixture.h"
30#include "print-to.h"
31#include "timezone-mock.h"
32#include "wakeup-timer-mock.h"
33
34using namespace unity::indicator::datetime;
35using VAlarmFixture = GlibFixture;
36
37/***
38****
39***/
40
41TEST_F(VAlarmFixture, MultipleAppointments)
42{
43 // start the EDS engine
44 auto engine = std::make_shared<EdsEngine>();
45
46 // we need a consistent timezone for the planner and our local DateTimes
47 constexpr char const * zone_str {"Europe/Berlin"};
48 auto tz = std::make_shared<MockTimezone>(zone_str);
49 auto gtz = g_time_zone_new(zone_str);
50
51 // make a planner that looks at the first half of 2015 in EDS
52 auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
53 const DateTime range_begin {gtz, 2015,7, 1, 0, 0, 0.0};
54 const DateTime range_end {gtz, 2015,7,31,23,59,59.5};
55 planner->range().set(std::make_pair(range_begin, range_end));
56
57 // give EDS a moment to load
58 if (planner->appointments().get().empty()) {
59 g_message("waiting a moment for EDS to load...");
60 auto on_appointments_changed = [this](const std::vector<Appointment>& appointments){
61 g_message("ah, they loaded");
62 if (!appointments.empty())
63 g_main_loop_quit(loop);
64 };
65 core::ScopedConnection conn(planner->appointments().changed().connect(on_appointments_changed));
66 constexpr int max_wait_sec = 10;
67 wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND);
68 }
69
70 // what we expect to get...
71 std::array<Appointment,1> expected_appts;
72 auto appt = &expected_appts[0];
73 appt->uid = "8ggc30kh89qql8vjumgtug7l14@google.com";
74 appt->color = "#becedd";
75 appt->summary = "Hello";
76 appt->begin = DateTime{gtz,2015,7,1,20,0,0};
77 appt->end = DateTime{gtz,2015,7,1,22,0,0};
78
79 // compare it to what we actually loaded...
80 const auto appts = planner->appointments().get();
81 EXPECT_EQ(expected_appts.size(), appts.size());
82 for (size_t i=0, n=std::min(appts.size(),expected_appts.size()); i<n; i++)
83 EXPECT_EQ(expected_appts[i], appts[i]);
84
85 // cleanup
86 g_time_zone_unref(gtz);
87}
088
=== added file 'tests/test-eds-ics-tzids.ics'
--- tests/test-eds-ics-tzids.ics 1970-01-01 00:00:00 +0000
+++ tests/test-eds-ics-tzids.ics 2015-07-10 17:29:43 +0000
@@ -0,0 +1,56 @@
1BEGIN:VCALENDAR
2CALSCALE:GREGORIAN
3PRODID:-//Ximian//NONSGML Evolution Calendar//EN
4VERSION:2.0
5X-EVOLUTION-DATA-REVISION:2015-07-09T17:27:58.908570Z(0)
6BEGIN:VTIMEZONE
7TZID:/freeassociation.sourceforge.net/Tzfile/America/Sao_Paulo
8X-LIC-LOCATION:America/Sao_Paulo
9BEGIN:STANDARD
10TZNAME:BRT
11DTSTART:19700222T000000
12RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=2
13TZOFFSETFROM:-0200
14TZOFFSETTO:-0300
15END:STANDARD
16BEGIN:DAYLIGHT
17TZNAME:BRST
18DTSTART:19701018T000000
19RRULE:FREQ=YEARLY;BYDAY=3SU;BYMONTH=10
20TZOFFSETFROM:-0300
21TZOFFSETTO:-0200
22END:DAYLIGHT
23END:VTIMEZONE
24BEGIN:VTIMEZONE
25TZID:/freeassociation.sourceforge.net/Tzfile/Europe/Berlin
26X-LIC-LOCATION:Europe/Berlin
27BEGIN:STANDARD
28TZNAME:CET
29DTSTART:19701025T030000
30RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
31TZOFFSETFROM:+0200
32TZOFFSETTO:+0100
33END:STANDARD
34BEGIN:DAYLIGHT
35TZNAME:CEST
36DTSTART:19700329T020000
37RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
38TZOFFSETFROM:+0100
39TZOFFSETTO:+0200
40END:DAYLIGHT
41END:VTIMEZONE
42BEGIN:VEVENT
43STATUS:CONFIRMED
44DTSTAMP:20150708T095820Z
45CREATED:20150708T095820Z
46UID:8ggc30kh89qql8vjumgtug7l14@google.com
47SEQUENCE:0
48TRANSP:OPAQUE
49SUMMARY:Hello
50DTSTART;TZID=/freeassociation.sourceforge.net/Tzfile/Europe/Berlin:
51 20150701T200000
52DTEND;TZID=/freeassociation.sourceforge.net/Tzfile/Europe/Berlin:
53 20150701T220000
54LAST-MODIFIED:20150708T095820Z
55END:VEVENT
56END:VCALENDAR

Subscribers

People subscribed via source and target branches