Merge lp:~renatofilho/qtorganizer5-eds/fix-1440878 into lp:qtorganizer5-eds

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Charles Kerr
Approved revision: 85
Merged at revision: 81
Proposed branch: lp:~renatofilho/qtorganizer5-eds/fix-1440878
Merge into: lp:qtorganizer5-eds
Prerequisite: lp:~renatofilho/qtorganizer5-eds/fix-1426519
Diff against target: 301 lines (+164/-41)
5 files modified
organizer/qorganizer-eds-engine.cpp (+13/-9)
tests/unittest/eds-base-test.cpp (+61/-0)
tests/unittest/eds-base-test.h (+3/-0)
tests/unittest/event-test.cpp (+45/-6)
tests/unittest/run-eds-test.sh (+42/-26)
To merge this branch: bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1440878
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+255725@code.launchpad.net

This proposal supersedes a proposal from 2015-04-09.

Commit message

Save a trigger for reminders with with secondsBeforeStart equals 0.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

Some inline comments below.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

The code changes LGTM.

Approving in comments, feel free to top-approve for me once you've got the Jenkins issue sorted

review: Approve
85. By Renato Araujo Oliveira Filho

Removed test workaround.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'organizer/qorganizer-eds-engine.cpp'
--- organizer/qorganizer-eds-engine.cpp 2015-04-09 17:24:00 +0000
+++ organizer/qorganizer-eds-engine.cpp 2015-04-09 17:24:00 +0000
@@ -1798,11 +1798,17 @@
17981798
1799 ECalComponentAlarmTrigger trigger;1799 ECalComponentAlarmTrigger trigger;
1800 e_cal_component_alarm_get_trigger(alarm, &trigger);1800 e_cal_component_alarm_get_trigger(alarm, &trigger);
1801 int relSecs = 0;
1801 if (trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) {1802 if (trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) {
1802 aDetail->setSecondsBeforeStart(icaldurationtype_as_int(trigger.u.rel_duration) * -1);1803 relSecs = - icaldurationtype_as_int(trigger.u.rel_duration);
1803 } else {1804 if (relSecs < 0) {
1804 aDetail->setSecondsBeforeStart(0);1805 relSecs = 0;
1806 qWarning() << "QOrganizer does not support triggers after event start";
1807 }
1808 } else if (trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_NONE) {
1809 qWarning() << "QOrganizer only supports triggers relative to event start.";
1805 }1810 }
1811 aDetail->setSecondsBeforeStart(relSecs);
18061812
1807 ECalComponentAlarmRepeat aRepeat;1813 ECalComponentAlarmRepeat aRepeat;
1808 e_cal_component_alarm_get_repeat(alarm, &aRepeat);1814 e_cal_component_alarm_get_repeat(alarm, &aRepeat);
@@ -2414,12 +2420,10 @@
2414 break;2420 break;
2415 }2421 }
24162422
2417 if (reminder->secondsBeforeStart() > 0) {2423 ECalComponentAlarmTrigger trigger;
2418 ECalComponentAlarmTrigger trigger;2424 trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
2419 trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;2425 trigger.u.rel_duration = icaldurationtype_from_int(- reminder->secondsBeforeStart());
2420 trigger.u.rel_duration = icaldurationtype_from_int(- reminder->secondsBeforeStart());2426 e_cal_component_alarm_set_trigger(alarm, trigger);
2421 e_cal_component_alarm_set_trigger(alarm, trigger);
2422 }
24232427
2424 ECalComponentAlarmRepeat aRepeat;2428 ECalComponentAlarmRepeat aRepeat;
2425 // TODO: check if this is really necessary2429 // TODO: check if this is really necessary
24262430
=== modified file 'tests/unittest/eds-base-test.cpp'
--- tests/unittest/eds-base-test.cpp 2015-03-24 17:56:44 +0000
+++ tests/unittest/eds-base-test.cpp 2015-04-09 17:24:00 +0000
@@ -27,6 +27,26 @@
2727
28using namespace QtOrganizer;28using namespace QtOrganizer;
2929
30class GScopedPointerUnref
31{
32public:
33 static inline void cleanup(void *pointer)
34 {
35 if (pointer) {
36 g_clear_object(&pointer);
37 }
38 }
39};
40
41template<class KLASS>
42class GScopedPointer : public QScopedPointer<KLASS, GScopedPointerUnref>
43{
44public:
45 GScopedPointer(KLASS* obj = 0)
46 : QScopedPointer<KLASS, GScopedPointerUnref>(obj)
47 {}
48};
49
30EDSBaseTest::EDSBaseTest()50EDSBaseTest::EDSBaseTest()
31{51{
32 qRegisterMetaType<QList<QOrganizerCollectionId> >();52 qRegisterMetaType<QList<QOrganizerCollectionId> >();
@@ -52,6 +72,47 @@
52{72{
53}73}
5474
75QString EDSBaseTest::getEventFromEvolution(const QOrganizerItemId &id,
76 const QOrganizerCollectionId &collectionId)
77{
78 QString uid = id.toString().split("/").last();
79 GError *error = 0;
80 GScopedPointer<ESourceRegistry> sourceRegistry(e_source_registry_new_sync(0, &error));
81 if (error) {
82 qWarning() << "Fail to create source registry" << error->message;
83 g_error_free(error);
84 return QString();
85 }
86 GScopedPointer<ESource> calendar;
87 if (collectionId.isNull()) {
88 calendar.reset(e_source_registry_ref_default_calendar(sourceRegistry.data()));
89 } else {
90 calendar.reset(e_source_registry_ref_source(sourceRegistry.data(),
91 collectionId.toString().toUtf8().data()));
92 }
93 GScopedPointer<EClient> client(e_cal_client_connect_sync(calendar.data(),
94 E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
95 0,
96 &error));
97 if (error) {
98 qWarning() << "Fail to connect to calendar" << error->message;
99 g_error_free(error);
100 return QString();
101 }
102
103 icalcomponent *obj = 0;
104 e_cal_client_get_object_sync(reinterpret_cast<ECalClient*>(client.data()),
105 uid.toUtf8().data(), 0, &obj, 0, &error);
106 if (error) {
107 qWarning() << "Fail to retrieve object:" << error->message;
108 g_error_free(error);
109 }
110
111 QString result = QString::fromUtf8(icalcomponent_as_ical_string(obj));
112 icalcomponent_free (obj);
113 return result;
114}
115
55QString EDSBaseTest::uniqueCollectionName() const116QString EDSBaseTest::uniqueCollectionName() const
56{117{
57 return QUuid::createUuid().toString();118 return QUuid::createUuid().toString();
58119
=== modified file 'tests/unittest/eds-base-test.h'
--- tests/unittest/eds-base-test.h 2014-10-06 14:46:49 +0000
+++ tests/unittest/eds-base-test.h 2015-04-09 17:24:00 +0000
@@ -36,6 +36,9 @@
36 virtual void init();36 virtual void init();
37 virtual void cleanup();37 virtual void cleanup();
3838
39
40 QString getEventFromEvolution(const QtOrganizer::QOrganizerItemId &id,
41 const QtOrganizer::QOrganizerCollectionId &collectionId = QtOrganizer::QOrganizerCollectionId());
39 QString uniqueCollectionName() const;42 QString uniqueCollectionName() const;
40};43};
4144
4245
=== modified file 'tests/unittest/event-test.cpp'
--- tests/unittest/event-test.cpp 2015-04-09 17:24:00 +0000
+++ tests/unittest/event-test.cpp 2015-04-09 17:24:00 +0000
@@ -47,7 +47,6 @@
47 void initTestCase()47 void initTestCase()
48 {48 {
49 EDSBaseTest::init();49 EDSBaseTest::init();
50 qDebug() << "INIT TEST CASE";
5150
52 m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>());51 m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>());
5352
@@ -61,8 +60,6 @@
61 QVERIFY(saveResult);60 QVERIFY(saveResult);
62 QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError);61 QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError);
63 QTRY_COMPARE(createdCollection.count(), 1);62 QTRY_COMPARE(createdCollection.count(), 1);
64
65 qDebug() << "END TEST CASE";
66 }63 }
6764
68 void cleanupTestCase()65 void cleanupTestCase()
@@ -377,7 +374,6 @@
377374
378 QList<QOrganizerItemId> ids;375 QList<QOrganizerItemId> ids;
379 ids << items[0].id();376 ids << items[0].id();
380 qDebug() << "Check for item id:" << ids;
381 items = m_engine->items(ids, hint, 0, 0);377 items = m_engine->items(ids, hint, 0, 0);
382 QCOMPARE(items.count(), 1);378 QCOMPARE(items.count(), 1);
383 QOrganizerCollection collection = m_engine->defaultCollection(0);379 QOrganizerCollection collection = m_engine->defaultCollection(0);
@@ -819,10 +815,53 @@
819 QCOMPARE(newAttendee.participationStatus(), attendee.participationStatus());815 QCOMPARE(newAttendee.participationStatus(), attendee.participationStatus());
820 }816 }
821817
818 // BUG: #1440878
819 void testReminderOnTime()
820 {
821 static QString displayLabelValue = QStringLiteral("event reminder");
822 static QString descriptionValue = QStringLiteral("event with reminder");
823
824 QOrganizerEvent event;
825 QOrganizerItemAudibleReminder aReminder;
826 event.setStartDateTime(QDateTime::currentDateTime());
827 event.setDisplayLabel(displayLabelValue);
828 event.setDescription(descriptionValue);
829 aReminder.setSecondsBeforeStart(0);
830 aReminder.setDataUrl(QString());
831 event.saveDetail(&aReminder);
832
833 QOrganizerEvent event2;
834 aReminder = QOrganizerItemAudibleReminder();
835 event2.setStartDateTime(QDateTime::currentDateTime().addDays(2));
836 event2.setDisplayLabel(displayLabelValue + "_2");
837 event2.setDescription(descriptionValue);
838 aReminder.setSecondsBeforeStart(60);
839 aReminder.setDataUrl(QString());
840 event2.saveDetail(&aReminder);
841
842 QtOrganizer::QOrganizerManager::Error error;
843 QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap;
844 QList<QOrganizerItem> items;
845 QSignalSpy createdItem(m_engine, SIGNAL(itemsAdded(QList<QOrganizerItemId>)));
846 items << event << event2;
847 bool saveResult = m_engine->saveItems(&items,
848 QList<QtOrganizer::QOrganizerItemDetail::DetailType>(),
849 &errorMap,
850 &error);
851 QTRY_COMPARE(createdItem.count(), 1);
852 QVERIFY(saveResult);
853
854 QString vcard = getEventFromEvolution(items[0].id());
855 QVERIFY(vcard.contains("TRIGGER;VALUE=DURATION;RELATED=START:PT0S"));
856
857 vcard = getEventFromEvolution(items[1].id());
858 QVERIFY(vcard.contains("TRIGGER;VALUE=DURATION;RELATED=START:-PT1M"));
859 }
860
822 void testExtendedProperties()861 void testExtendedProperties()
823 {862 {
824 static QString displayLabelValue = QStringLiteral("event with collection attendee");863 static QString displayLabelValue = QStringLiteral("event with extended property");
825 static QString descriptionValue = QStringLiteral("event without collection");864 static QString descriptionValue = QStringLiteral("event with extended property");
826 QOrganizerItemId itemId;865 QOrganizerItemId itemId;
827 QDateTime currentTime = QDateTime::currentDateTime();866 QDateTime currentTime = QDateTime::currentDateTime();
828867
829868
=== modified file 'tests/unittest/run-eds-test.sh'
--- tests/unittest/run-eds-test.sh 2015-04-09 17:24:00 +0000
+++ tests/unittest/run-eds-test.sh 2015-04-09 17:24:00 +0000
@@ -1,35 +1,51 @@
1#!/bin/sh1#!/bin/sh
22
3#ARG1 - DBUS RUNNERN PATH3echo ARG0=$0 # this script
4#ARG2 - TEST EXECUTABLE FULL PATH4echo ARG1=$1 # full executable path of dbus-test-runner
5#ARG3 - TEST NAME5echo ARG2=$2 # full executable path of test app
6#ARG4 - EVOLUTION_CALENDAR_FACTORY FULL PATH6echo ARG3=$3 # test name
7#ARG5 - EVOLUTION_CALENDAR_FACTORY SERVICE NAME7echo ARG4=$4 # full executable path of evolution-calendar-factory
8#ARG6 - EVOLUTION_SOURCE_REGISTRY FULL PATH8echo ARG5=$5 # bus service name of calendar factory
99echo ARG6=$6 # full exectuable path of evolution-source-registry
1010echo ARG7=$7 # full executable path of gvfs
11export TEST_TMP_DIR=$(mktemp -d /tmp/$3_XXXX)11echo ARG8=$8 # config files
12
13# set up the tmpdir and tell the shell to purge it when we exit
14export TEST_TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d $3-XXXXXXXXXX) || exit 1
15echo "running test '$3' in ${TEST_TMP_DIR}"
16
17# set up the environment variables
12export QT_QPA_PLATFORM=minimal18export QT_QPA_PLATFORM=minimal
13export HOME=$TEST_TMP_DIR19export HOME=${TEST_TMP_DIR}
14export XDG_RUNTIME_DIR=$TEST_TMP_DIR20export XDG_RUNTIME_DIR=${TEST_TMP_DIR}
15export XDG_CACHE_HOME=$TEST_TMP_DIR/.cache21export XDG_CACHE_HOME=${TEST_TMP_DIR}/.cache
16export XDG_CONFIG_HOME=$TEST_TMP_DIR/.config22export XDG_CONFIG_HOME=${TEST_TMP_DIR}/.config
17export XDG_DATA_HOME=$TEST_TMP_DIR/.local/share23export XDG_DATA_HOME=${TEST_TMP_DIR}/.local/share
18export XDG_DESKTOP_DIR=$TEST_TMP_DIR24export XDG_DESKTOP_DIR=${TEST_TMP_DIR}
19export XDG_DOCUMENTS_DIR=$TEST_TMP_DIR25export XDG_DOCUMENTS_DIR=${TEST_TMP_DIR}
20export XDG_DOWNLOAD_DIR=$TEST_TMP_DIR26export XDG_DOWNLOAD_DIR=${TEST_TMP_DIR}
21export XDG_MUSIC_DIR=$TEST_TMP_DIR27export XDG_MUSIC_DIR=${TEST_TMP_DIR}
22export XDG_PICTURES_DIR=$TEST_TMP_DIR28export XDG_PICTURES_DIR=${TEST_TMP_DIR}
23export XDG_PUBLICSHARE_DIR=$TEST_TMP_DIR29export XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}
24export XDG_TEMPLATES_DIR=$TEST_TMP_DIR30export XDG_TEMPLATES_DIR=${TEST_TMP_DIR}
25export XDG_VIDEOS_DIR=$TEST_TMP_DIR31export XDG_VIDEOS_DIR=${TEST_TMP_DIR}
26export QORGANIZER_EDS_DEBUG=On32export QORGANIZER_EDS_DEBUG=On
2733export GIO_USE_VFS=local # needed to ensure GVFS shuts down cleanly after the test is over
28echo HOMEDIR=$HOME34
29rm -rf $XDG_DATA_HOME35echo HOMEDIR=${HOME}
36rm -rf ${XDG_DATA_HOME}
37
38# run dbus-test-runner
30$1 --keep-env --max-wait=90 \39$1 --keep-env --max-wait=90 \
31--task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \40--task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \
32--task $4 --task-name "evolution" --wait-until-complete -r41--task $4 --task-name "evolution" --wait-until-complete -r
33#--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \42#--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \
34#--task $7 --task-name "gvfsd" -r43#--task $7 --task-name "gvfsd" -r
35return $?44rv=$?
45
46# if the test passed, blow away the tmpdir
47if [ $rv -eq 0 ]; then
48 rm -rf $TEST_TMP_DIR
49fi
50
51return $rv

Subscribers

People subscribed via source and target branches