Merge lp:~ubuntu-calendar-dev/ubuntu-calendar-app/revised-fix-for-bug1334883-dev into lp:ubuntu-calendar-app

Proposed by Jason
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 365
Merged at revision: 373
Proposed branch: lp:~ubuntu-calendar-dev/ubuntu-calendar-app/revised-fix-for-bug1334883-dev
Merge into: lp:ubuntu-calendar-app
Diff against target: 256 lines (+96/-53)
3 files modified
TimeLineBaseComponent.qml (+2/-0)
tests/autopilot/calendar_app/emulators.py (+42/-17)
tests/autopilot/calendar_app/tests/test_new_event.py (+52/-36)
To merge this branch: bzr merge lp:~ubuntu-calendar-dev/ubuntu-calendar-app/revised-fix-for-bug1334883-dev
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Leo Arias Pending
Kunal Parmar Pending
Review via email: mp+228960@code.launchpad.net

Commit message

A revised fix for Launchpad Bug 1334883 in the Ubuntu Calendar App.

Description of the change

A revised fix for Launchpad Bug 1334883 in the Ubuntu Calendar App. In this bug, the 'delete' button appeared to have no effect as events appeared to remain on the DayView after being deleted.

This was happening because the destroyAllChildren() function, which is responsible for cleaning up existing events on the DayView was not getting triggered when the model changed (due to an event being removed).

To reproduce this bug (without this branch):
1) Navigate to the DayView
2) Create an event.
3) Click on the Event to see its EventDetails page
4) Hit the 'Trash Can'/Delete icon.
5) You should be taken back to the DayView, but the event is still there.

With this branch, the behavior is changed to
5') You are taken back to the DayView, and the event is deleted.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:360
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ubuntu-calendar-dev/ubuntu-calendar-app/revised-fix-for-bug1334883-dev/+merge/228960/+edit-commit-message

http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/653/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/generic-mediumtests-utopic/1215/console
    FAILURE: http://91.189.93.70:8080/job/ubuntu-calendar-app-utopic-amd64-ci/211/console

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/653/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I think this is ready to roll. The bug we discovered is noted in the tests, and we can write a new test for it when we merge the fix.

https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1350605

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'TimeLineBaseComponent.qml'
2--- TimeLineBaseComponent.qml 2014-07-12 02:08:13 +0000
3+++ TimeLineBaseComponent.qml 2014-07-31 17:11:55 +0000
4@@ -136,9 +136,11 @@
5
6 model: mainModel
7 Component.onCompleted: {
8+ model.addModelChangeListener(destroyAllChildren);
9 model.addModelChangeListener(createEvents);
10 }
11 Component.onDestruction: {
12+ model.removeModelChangeListener(destroyAllChildren);
13 model.removeModelChangeListener(createEvents);
14 }
15 }
16
17=== modified file 'tests/autopilot/calendar_app/emulators.py'
18--- tests/autopilot/calendar_app/emulators.py 2014-07-23 18:17:21 +0000
19+++ tests/autopilot/calendar_app/emulators.py 2014-07-31 17:11:55 +0000
20@@ -240,14 +240,16 @@
21
22 """Autopilot helper for the Day View page."""
23
24- def get_events(self, filter_duplicates=False):
25+ @autopilot.logging.log_action(logger.info)
26+ def get_events(self, visible=True):
27 """Return the events for this day.
28
29+ :param visible: toggles filtering for only visible events
30 :return: A list with the events. Each event is a tuple with name, start
31 time and end time.
32
33 """
34- event_bubbles = self._get_selected_day_event_bubbles(filter_duplicates)
35+ event_bubbles = self._get_selected_day_event_bubbles()
36
37 # sort by y, x
38 event_bubbles = sorted(
39@@ -256,10 +258,40 @@
40
41 events = []
42 for event in event_bubbles:
43- events.append(event.get_information())
44+ # Event-bubbles objects are recycled, only show visible ones.
45+ if visible:
46+ if event.visible:
47+ events.append(event.get_information())
48+ else:
49+ events.append(event.get_information())
50
51 return events
52
53+ @autopilot.logging.log_action(logger.info)
54+ def get_event(self, event_name, visible=True):
55+ """Return a specific event from current day.
56+
57+ :param visible: toggles filtering for only visible events
58+ :param event_name: the name of the event.
59+ If more than one name matches, return the first matching event
60+ :return: The event object
61+ """
62+ event_bubbles = self._get_selected_day_event_bubbles()
63+
64+ # sort by y, x
65+ event_bubbles = sorted(
66+ event_bubbles,
67+ key=lambda bubble: (bubble.globalRect.y, bubble.globalRect.x))
68+
69+ for event in event_bubbles:
70+ # Event-bubbles objects are recycled, only show visible ones.
71+ if event.get_name() == event_name:
72+ if (visible and event.visible) or not visible:
73+ matched_event = event
74+ return matched_event
75+
76+ raise CalendarException('No event found for %s' % event_name)
77+
78 def _get_current_day_component(self):
79 components = self.select_many('TimeLineBaseComponent')
80 for component in components:
81@@ -270,19 +302,12 @@
82 raise CalendarException(
83 'Could not find the current day component.')
84
85- def _get_selected_day_event_bubbles(self, filter_duplicates):
86+ def _get_selected_day_event_bubbles(self):
87 selected_day = self._get_current_day_component()
88- return self._get_event_bubbles(selected_day, filter_duplicates)
89+ return self._get_event_bubbles(selected_day)
90
91- def _get_event_bubbles(self, selected_day, filter_duplicates):
92+ def _get_event_bubbles(self, selected_day):
93 event_bubbles = selected_day.select_many(EventBubble)
94- if filter_duplicates:
95- # XXX remove this once bug http://pad.lv/1334833 is fixed.
96- # --elopio - 2014-06-26
97- separator_id = selected_day.select_single(
98- 'QQuickRectangle', objectName='separator').id
99- event_bubbles = self._remove_duplicate_events(
100- separator_id, event_bubbles)
101 return event_bubbles
102
103 def _remove_duplicate_events(self, separator_id, event_bubbles):
104@@ -294,14 +319,14 @@
105 return events
106
107 @autopilot.logging.log_action(logger.info)
108- def open_event(self, name, filter_duplicates=False):
109+ def open_event(self, name):
110 """Open an event.
111
112 :param name: The name of the event to open.
113 :return: The Event Details page.
114
115 """
116- event_bubbles = self._get_selected_day_event_bubbles(filter_duplicates)
117+ event_bubbles = self._get_selected_day_event_bubbles()
118 for bubble in event_bubbles:
119 if bubble.get_name() == name:
120 return bubble.open_event()
121@@ -310,14 +335,14 @@
122 'Could not find event with name {}.'.format(name))
123
124 @autopilot.logging.log_action(logger.info)
125- def delete_event(self, name, filter_duplicates=False):
126+ def delete_event(self, name):
127 """Delete an event.
128
129 :param name: The name of the event to delete.
130 :return: The Day View page.
131
132 """
133- event_details_page = self.open_event(name, filter_duplicates)
134+ event_details_page = self.open_event(name)
135 return event_details_page.delete()
136
137 @autopilot.logging.log_action(logger.info)
138
139=== modified file 'tests/autopilot/calendar_app/tests/test_new_event.py'
140--- tests/autopilot/calendar_app/tests/test_new_event.py 2014-07-23 18:19:42 +0000
141+++ tests/autopilot/calendar_app/tests/test_new_event.py 2014-07-31 17:11:55 +0000
142@@ -21,7 +21,7 @@
143 import logging
144
145 from autopilot.matchers import Eventually
146-from testtools.matchers import HasLength
147+from testtools.matchers import Equals, NotEquals
148
149 from calendar_app import data
150 from calendar_app.tests import CalendarTestCase
151@@ -39,13 +39,44 @@
152 # http://pad.lv/1328600 on Autopilot.
153 # --elopio - 2014-06-26
154
155- def try_delete_event(self, event_name, filter_duplicates):
156+ def _try_delete_event(self, event_name):
157 try:
158 day_view = self.main_view.go_to_day_view()
159- day_view.delete_event(event_name, filter_duplicates)
160+ day_view.delete_event(event_name)
161 except Exception as exception:
162 logger.warn(str(exception))
163
164+ def _add_event(self):
165+ test_event = data.Event.make_unique()
166+ day_view = self.main_view.go_to_day_view()
167+
168+ new_event_page = self.main_view.go_to_new_event()
169+ new_event_page.add_event(test_event)
170+
171+ # workaround bug 1350605
172+ day_view = self._workaround_bug_1350605()
173+
174+ return day_view, test_event
175+
176+ def _event_exists(self, event_name):
177+ try:
178+ day_view = self.main_view.go_to_day_view()
179+ day_view.get_event(event_name, False)
180+ except Exception:
181+ return False
182+ return True
183+
184+ def _workaround_bug_1350605(self):
185+ # due to bug 1350605, let's force load another view
186+ # before returning to dayview to prevent refresh issues
187+ self.main_view.go_to_month_view()
188+ day_view = self.main_view.go_to_day_view()
189+ return day_view
190+
191+ # TODO, add test to check events are displayed properly
192+ # after multiple operations
193+ # https://bugs.launchpad.net/ubuntu-calendar-app/+bug/1350605
194+
195 def test_add_new_event_with_default_values(self):
196 """Test adding a new event with the default values.
197
198@@ -53,40 +84,25 @@
199 with an end time, without recurrence and without reminders.
200
201 """
202- test_event = data.Event.make_unique()
203-
204- day_view = self.main_view.go_to_day_view()
205- original_events = day_view.get_events()
206-
207- new_event_page = self.main_view.go_to_new_event()
208- # XXX remove this once bug http://pad.lv/1334833 is fixed.
209- # --elopio - 2014-06-26
210- filter_duplicates = len(original_events) > 0
211- self.addCleanup(
212- self.try_delete_event, test_event.name, filter_duplicates)
213- day_view = new_event_page.add_event(test_event)
214-
215- def get_new_events():
216- return day_view.get_events(filter_duplicates)
217-
218- self.assertThat(
219- get_new_events, Eventually(HasLength(len(original_events) + 1)))
220+ day_view, test_event = self._add_event()
221+
222+ self.addCleanup(self._try_delete_event, test_event.name)
223+
224+ event_bubble = lambda: day_view.get_event(test_event.name)
225+ self.assertThat(event_bubble, Eventually(NotEquals(None)))
226+
227 event_details_page = day_view.open_event(test_event.name)
228- self.assertEqual(
229- test_event, event_details_page.get_event_information())
230+
231+ self.assertEqual(test_event,
232+ event_details_page.get_event_information())
233
234 def test_delete_event_must_remove_it_from_day_view(self):
235 """Test deleting an event must no longer show it on the day view."""
236- # TODO remove the skip once the bug is fixed. --elopio - 2014-06-26
237- self.skipTest('This test fails because of bug http://pad.lv/1334883')
238- event = data.Event.make_unique()
239-
240- day_view = self.main_view.go_to_day_view()
241- original_events = day_view.get_events()
242-
243- new_event_page = self.main_view.go_to_new_event()
244- day_view = new_event_page.add_event(event)
245- day_view = day_view.delete_event(event.name, len(original_events) > 0)
246-
247- events_after_delete = day_view.get_events()
248- self.assertEqual(original_events, events_after_delete)
249+ day_view, test_event = self._add_event()
250+
251+ day_view.delete_event(test_event.name)
252+
253+ self._workaround_bug_1350605()
254+
255+ self.assertThat(lambda: self._event_exists(test_event.name),
256+ Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches

to status/vote changes: