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

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 74
Merged at revision: 82
Proposed branch: lp:~renatofilho/qtorganizer5-eds/fix-1347836
Merge into: lp:qtorganizer5-eds
Prerequisite: lp:~renatofilho/qtorganizer5-eds/fix-1440878
Diff against target: 192 lines (+57/-11)
5 files modified
organizer/qorganizer-eds-source-registry.cpp (+16/-2)
organizer/qorganizer-eds-source-registry.h (+4/-1)
tests/unittest/collections-test.cpp (+34/-4)
tests/unittest/event-test.cpp (+0/-2)
tests/unittest/run-eds-test.sh (+3/-2)
To merge this branch: bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1347836
Reviewer Review Type Date Requested Status
Kunal Parmar (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+255726@code.launchpad.net

This proposal supersedes a proposal from 2014-10-21.

Commit message

Added a new extra metadata property in collection (read-only property).

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
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
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
Kunal Parmar (pkunal-parmar) wrote : Posted in a previous version of this proposal

I am not getting readonly true for birth day calendar

qml: Personal - collectin-readonly : false
qml: Birthdays & Anniversaries - collectin-readonly : false

Where creating event on Birthdays calendar fails as its readonly

ail to create items: Cannot create calendar object: Permission denied

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
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
72. By Renato Araujo Oliveira Filho

Update collection test.

Instead of compare all the colection data to check if it exists, I am using only the collection id in case of the other properties changed during the process.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
73. By Renato Araujo Oliveira Filho

Fix collection test.

Wait for collection to be writable before try to remove id.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
74. By Renato Araujo Oliveira Filho

Do not try to compare secs on unit test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

tested and works great for me.

Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'organizer/qorganizer-eds-source-registry.cpp'
2--- organizer/qorganizer-eds-source-registry.cpp 2014-05-21 14:50:20 +0000
3+++ organizer/qorganizer-eds-source-registry.cpp 2015-04-13 21:30:31 +0000
4@@ -182,6 +182,12 @@
5 qWarning() << "Fail to connect with client" << gError->message;
6 g_error_free(gError);
7 } else {
8+ // If the client is read only update the collection
9+ if (e_client_is_readonly(client)) {
10+ QOrganizerCollection &c = m_collections[collectionId];
11+ c.setExtendedMetaData(COLLECTION_READONLY_METADATA, true);
12+ Q_EMIT sourceUpdated(collectionId);
13+ }
14 m_clients.insert(collectionId, client);
15 }
16 }
17@@ -282,7 +288,7 @@
18 QString collectionId = self->findCollection(source);
19 if (!collectionId.isEmpty() && self->m_collections.contains(collectionId)) {
20 QOrganizerCollection &collection = self->m_collections[collectionId];
21- self->updateCollection(&collection, source);
22+ self->updateCollection(&collection, source, self->m_clients.value(collectionId));
23 Q_EMIT self->sourceUpdated(collectionId);
24 } else {
25 qWarning() << "Source changed not found";
26@@ -298,7 +304,8 @@
27 }
28
29 void SourceRegistry::updateCollection(QOrganizerCollection *collection,
30- ESource *source)
31+ ESource *source,
32+ EClient *client)
33 {
34 // name
35 collection->setMetaData(QOrganizerCollection::KeyName,
36@@ -325,4 +332,11 @@
37 bool selected = (e_source_selectable_get_selected(E_SOURCE_SELECTABLE(extCalendar)) == TRUE);
38 collection->setExtendedMetaData(COLLECTION_SELECTED_METADATA, selected);
39
40+ // writable
41+ bool writable = e_source_get_writable(source);
42+ // the source and client need to be writable
43+ if (client) {
44+ writable = writable && !e_client_is_readonly(client);
45+ }
46+ collection->setExtendedMetaData(COLLECTION_READONLY_METADATA, !writable);
47 }
48
49=== modified file 'organizer/qorganizer-eds-source-registry.h'
50--- organizer/qorganizer-eds-source-registry.h 2014-03-21 18:04:50 +0000
51+++ organizer/qorganizer-eds-source-registry.h 2015-04-13 21:30:31 +0000
52@@ -30,6 +30,7 @@
53
54 #define COLLECTION_CALLENDAR_TYPE_METADATA "collection-type"
55 #define COLLECTION_SELECTED_METADATA "collection-selected"
56+#define COLLECTION_READONLY_METADATA "collection-readonly"
57
58 class SourceRegistry : public QObject
59 {
60@@ -79,7 +80,9 @@
61
62 QString findCollection(ESource *source) const;
63 QtOrganizer::QOrganizerCollection registerSource(ESource *source);
64- static void updateCollection(QtOrganizer::QOrganizerCollection *collection, ESource *source);
65+ static void updateCollection(QtOrganizer::QOrganizerCollection *collection,
66+ ESource *source,
67+ EClient *client = 0);
68
69
70 // glib callback
71
72=== modified file 'tests/unittest/collections-test.cpp'
73--- tests/unittest/collections-test.cpp 2014-10-29 02:25:45 +0000
74+++ tests/unittest/collections-test.cpp 2015-04-13 21:30:31 +0000
75@@ -40,6 +40,17 @@
76 QOrganizerEDSEngine *m_engineWrite;
77 QOrganizerEDSEngine *m_engineRead;
78
79+ bool containsCollection(const QList<QOrganizerCollection> &lst, const QOrganizerCollection &collection )
80+ {
81+ bool found = false;
82+ Q_FOREACH(const QOrganizerCollection &col, lst) {
83+ if (col.id() == collection.id()) {
84+ found = true;
85+ }
86+ }
87+ return found;
88+ }
89+
90 private Q_SLOTS:
91 void initTestCase()
92 {
93@@ -190,6 +201,9 @@
94 QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red"));
95 QCOMPARE(newCollection.extendedMetaData(QStringLiteral("collection-selected")).toBool(), false);
96
97+ // wait collection to became writable
98+ QTRY_VERIFY_WITH_TIMEOUT(!m_engineRead->collection(newCollection.id(), 0).extendedMetaData("collection-readonly").toBool(), 5000);
99+
100 // update the collection
101 QSignalSpy updateCollection(m_engineRead, SIGNAL(collectionsChanged(QList<QOrganizerCollectionId>)));
102 collection.setMetaData(QOrganizerCollection::KeyColor, "blue");
103@@ -230,8 +244,8 @@
104 QList<QVariant> args = createdCollection.takeFirst();
105 QCOMPARE(args.count(), 1);
106
107- QVERIFY(m_engineWrite->collections(&error).contains(collection));
108- QVERIFY(m_engineRead->collections(&error).contains(collection));
109+ QVERIFY(containsCollection(m_engineWrite->collections(&error), collection));
110+ QVERIFY(containsCollection(m_engineRead->collections(&error), collection));
111 }
112
113 void testRemoveCollection()
114@@ -250,6 +264,9 @@
115 QVERIFY(m_engineWrite->saveCollection(&collection, &error));
116 QTRY_COMPARE(createCollection.count(), 1);
117
118+ // wait collection to became writable
119+ QTRY_VERIFY_WITH_TIMEOUT(!m_engineRead->collection(collection.id(), 0).extendedMetaData("collection-readonly").toBool(), 5000);
120+
121 // remove recent created collection
122 QSignalSpy removeCollection(m_engineRead, SIGNAL(collectionsRemoved(QList<QOrganizerCollectionId>)));
123 QVERIFY(m_engineWrite->removeCollection(collection.id(), &error));
124@@ -257,11 +274,24 @@
125
126 collections = m_engineWrite->collections(&error);
127 QCOMPARE(collections.count(), initalCollectionCount);
128- QVERIFY(!collections.contains(collection));
129+ QVERIFY(!containsCollection(collections, collection));
130
131 collections = m_engineRead->collections(&error);
132 QCOMPARE(collections.count(), initalCollectionCount);
133- QVERIFY(!collections.contains(collection));
134+ QVERIFY(!containsCollection(collections, collection));
135+ }
136+
137+ void testReadOnlyCollection()
138+ {
139+ // check if the anniversaries collection is read-only
140+ static const QString anniversariesCollectionName = QStringLiteral("Birthdays & Anniversaries");
141+ QtOrganizer::QOrganizerManager::Error error;
142+ QList<QOrganizerCollection> collections = m_engineRead->collections(&error);
143+ Q_FOREACH(const QOrganizerCollection &col, collections) {
144+ if (col.metaData(QOrganizerCollection::KeyName) == anniversariesCollectionName) {
145+ QVERIFY(col.extendedMetaData("collection-readonly").toBool());
146+ }
147+ }
148 }
149 };
150
151
152=== modified file 'tests/unittest/event-test.cpp'
153--- tests/unittest/event-test.cpp 2015-04-13 21:30:31 +0000
154+++ tests/unittest/event-test.cpp 2015-04-13 21:30:31 +0000
155@@ -705,7 +705,6 @@
156 QCOMPARE(newTodo.startDateTime().date(), startDate.date());
157 QCOMPARE(newTodo.startDateTime().time().hour(), startDate.time().hour());
158 QCOMPARE(newTodo.startDateTime().time().minute(), startDate.time().minute());
159- QCOMPARE(newTodo.startDateTime().time().second(), startDate.time().second());
160
161 // Update floating event
162 QSignalSpy updateItem(m_engine, SIGNAL(itemsChanged(QList<QOrganizerItemId>)));
163@@ -730,7 +729,6 @@
164 QCOMPARE(newTodo.startDateTime().date(), startDate.date());
165 QCOMPARE(newTodo.startDateTime().time().hour(), startDate.time().hour());
166 QCOMPARE(newTodo.startDateTime().time().minute(), startDate.time().minute());
167- QCOMPARE(newTodo.startDateTime().time().second(), startDate.time().second());
168
169 // Remove floating event
170 QOrganizerItemRemoveByIdRequest req;
171
172=== modified file 'tests/unittest/run-eds-test.sh'
173--- tests/unittest/run-eds-test.sh 2015-04-13 21:30:31 +0000
174+++ tests/unittest/run-eds-test.sh 2015-04-13 21:30:31 +0000
175@@ -29,6 +29,7 @@
176 export XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}
177 export XDG_TEMPLATES_DIR=${TEST_TMP_DIR}
178 export XDG_VIDEOS_DIR=${TEST_TMP_DIR}
179+export EDS_TESTING=1
180 export QORGANIZER_EDS_DEBUG=On
181 export GIO_USE_VFS=local # needed to ensure GVFS shuts down cleanly after the test is over
182
183@@ -38,8 +39,8 @@
184 # run dbus-test-runner
185 $1 --keep-env --max-wait=90 \
186 --task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \
187---task $4 --task-name "evolution" --wait-until-complete -r
188-#--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \
189+--task $4 --task-name "evolution" --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Sources3 -r \
190+--task $6 --task-name "source-registry" -r
191 #--task $7 --task-name "gvfsd" -r
192 rv=$?
193

Subscribers

People subscribed via source and target branches