Merge lp:~elopio/messaging-app/delete_multiple into lp:messaging-app
- delete_multiple
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tiago Salem Herrmann |
Approved revision: | 83 |
Merged at revision: | 78 |
Proposed branch: | lp:~elopio/messaging-app/delete_multiple |
Merge into: | lp:messaging-app |
Diff against target: |
374 lines (+147/-58) 5 files modified
src/qml/MainPage.qml (+2/-1) src/qml/MessageDelegate.qml (+7/-5) src/qml/Messages.qml (+5/-3) tests/autopilot/messaging_app/emulators.py (+84/-1) tests/autopilot/messaging_app/tests/test_messaging.py (+49/-48) |
To merge this branch: | bzr merge lp:~elopio/messaging-app/delete_multiple |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tiago Salem Herrmann (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+210983@code.launchpad.net |
Commit message
Refactor the test_delete_
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:78
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:79
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:81
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:82
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:83
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:83
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tiago Salem Herrmann (tiagosh) wrote : | # |
looks good.
thanks.
Preview Diff
1 | === modified file 'src/qml/MainPage.qml' |
2 | --- src/qml/MainPage.qml 2014-02-13 17:28:20 +0000 |
3 | +++ src/qml/MainPage.qml 2014-03-14 14:23:02 +0000 |
4 | @@ -1,5 +1,5 @@ |
5 | /* |
6 | - * Copyright 2012-2013 Canonical Ltd. |
7 | + * Copyright 2012, 2013, 2014 Canonical Ltd. |
8 | * |
9 | * This file is part of messaging-app. |
10 | * |
11 | @@ -83,6 +83,7 @@ |
12 | |
13 | listDelegate: ThreadDelegate { |
14 | id: threadDelegate |
15 | + objectName: "thread%1".arg(participants) |
16 | selectionMode: threadList.isInSelectionMode |
17 | selected: threadList.isSelected(threadDelegate) |
18 | removable: !selectionMode |
19 | |
20 | === modified file 'src/qml/MessageDelegate.qml' |
21 | --- src/qml/MessageDelegate.qml 2014-02-18 21:12:44 +0000 |
22 | +++ src/qml/MessageDelegate.qml 2014-03-14 14:23:02 +0000 |
23 | @@ -1,5 +1,5 @@ |
24 | /* |
25 | - * Copyright 2012-2013 Canonical Ltd. |
26 | + * Copyright 2012, 2013, 2014 Canonical Ltd. |
27 | * |
28 | * This file is part of messaging-app. |
29 | * |
30 | @@ -97,7 +97,7 @@ |
31 | |
32 | visible: running && !selectionMode |
33 | // if temporarily failed or unknown status, then show the spinner |
34 | - running: (textMessageStatus == HistoryThreadModel.MessageStatusUnknown || |
35 | + running: (textMessageStatus == HistoryThreadModel.MessageStatusUnknown || |
36 | textMessageStatus == HistoryThreadModel.MessageStatusTemporarilyFailed) && !incoming |
37 | } |
38 | |
39 | @@ -175,22 +175,24 @@ |
40 | |
41 | Label { |
42 | id: date |
43 | + objectName: 'messageDate' |
44 | anchors.top: senderName.bottom |
45 | height: paintedHeight |
46 | fontSize: "x-small" |
47 | color: textColor |
48 | text: { |
49 | - if (indicator.visible) |
50 | - i18n.tr("Sending...") |
51 | + if (indicator.visible) |
52 | + i18n.tr("Sending...") |
53 | else if (warningButton.visible) |
54 | i18n.tr("Failed") |
55 | - else |
56 | + else |
57 | DateUtils.friendlyDay(timestamp) + " " + Qt.formatDateTime(timestamp, "hh:mm AP") |
58 | } |
59 | } |
60 | |
61 | Label { |
62 | id: messageText |
63 | + objectName: 'messageText' |
64 | anchors.top: date.bottom |
65 | anchors.topMargin: units.gu(1) |
66 | anchors.left: parent.left |
67 | |
68 | === modified file 'src/qml/Messages.qml' |
69 | --- src/qml/Messages.qml 2014-03-05 04:58:13 +0000 |
70 | +++ src/qml/Messages.qml 2014-03-14 14:23:02 +0000 |
71 | @@ -1,5 +1,5 @@ |
72 | /* |
73 | - * Copyright 2012-2013 Canonical Ltd. |
74 | + * Copyright 2012, 2013, 2014 Canonical Ltd. |
75 | * |
76 | * This file is part of messaging-app. |
77 | * |
78 | @@ -93,7 +93,7 @@ |
79 | Item { |
80 | height: childrenRect.height |
81 | width: popover.width |
82 | - ListItem.Standard { |
83 | + ListItem.Standard { |
84 | id: listItem |
85 | text: contactWatcher.isUnknown ? contactWatcher.phoneNumber : contactWatcher.alias |
86 | } |
87 | @@ -375,6 +375,7 @@ |
88 | |
89 | MultipleSelectionListView { |
90 | id: messageList |
91 | + objectName: "messageList" |
92 | clip: true |
93 | acceptAction.text: i18n.tr("Delete") |
94 | anchors { |
95 | @@ -396,6 +397,7 @@ |
96 | highlightFollowsCurrentItem: false |
97 | listDelegate: MessageDelegate { |
98 | id: messageDelegate |
99 | + objectName: "message%1".arg(index) |
100 | incoming: senderId != "self" |
101 | selected: messageList.isSelected(messageDelegate) |
102 | removable: !messages.selectionMode |
103 | @@ -434,7 +436,7 @@ |
104 | if (messages.pendingMessage) { |
105 | messageList.contentY = 0 |
106 | messages.pendingMessage = false |
107 | - } |
108 | + } |
109 | } |
110 | } |
111 | |
112 | |
113 | === modified file 'tests/autopilot/messaging_app/emulators.py' |
114 | --- tests/autopilot/messaging_app/emulators.py 2014-02-19 19:24:28 +0000 |
115 | +++ tests/autopilot/messaging_app/emulators.py 2014-03-14 14:23:02 +0000 |
116 | @@ -1,5 +1,5 @@ |
117 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
118 | -# Copyright 2013 Canonical |
119 | +# Copyright 2013, 2014 Canonical |
120 | # |
121 | # This file is part of messaging-app. |
122 | # |
123 | @@ -18,11 +18,15 @@ |
124 | import tempfile |
125 | import time |
126 | |
127 | +from autopilot import logging as autopilot_logging |
128 | from autopilot.input import Keyboard |
129 | from autopilot.platform import model |
130 | from ubuntuuitoolkit import emulators as toolkit_emulators |
131 | |
132 | |
133 | +logger = logging.getLogger(__name__) |
134 | + |
135 | + |
136 | class EmulatorException(Exception): |
137 | """Exception raised when there is an error with the emulator.""" |
138 | |
139 | @@ -394,3 +398,82 @@ |
140 | script_proxy.SetPath(script_dir) |
141 | script_proxy.Run("sms.js") |
142 | shutil.rmtree(script_dir) |
143 | + |
144 | + |
145 | +class MainPage(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
146 | + """Autopilot helper for the Main Page.""" |
147 | + |
148 | + def get_thread_count(self): |
149 | + """Return the number of message threads.""" |
150 | + return self.select_single( |
151 | + 'MultipleSelectionListView', objectName='threadList').count |
152 | + |
153 | + @autopilot_logging.log_action(logger.info) |
154 | + def open_thread(self, participants): |
155 | + thread = self.select_single( |
156 | + 'ThreadDelegate', objectName='thread{}'.format(participants)) |
157 | + self.pointing_device.click_object(thread) |
158 | + return self.get_root_instance().wait_select_single(Messages) |
159 | + |
160 | + |
161 | +class Messages(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
162 | + """Autopilot helper for the Messages Page.""" |
163 | + |
164 | + def get_messages_count(self): |
165 | + """Return the number of meesages.""" |
166 | + return self.select_single( |
167 | + 'MultipleSelectionListView', objectName='messageList').count |
168 | + |
169 | + @autopilot_logging.log_action(logger.info) |
170 | + def select_messages(self, *indexes): |
171 | + """Select messages. |
172 | + |
173 | + :param indexes: The indexes of the messages to select. The most |
174 | + recently received message has the 0 index, and the oldest message |
175 | + has the higher index. |
176 | + |
177 | + """ |
178 | + first_message_delegate = self._get_message_delegate(indexes[0]) |
179 | + self._long_press(first_message_delegate) |
180 | + for index in indexes[1:]: |
181 | + message_delegate = self._get_message_delegate(index) |
182 | + self.pointing_device.click_object(message_delegate) |
183 | + |
184 | + def _get_message_delegate(self, index): |
185 | + return self.wait_select_single( |
186 | + 'MessageDelegate', objectName='message{}'.format(index)) |
187 | + |
188 | + def _long_press(self, object_): |
189 | + if model() == 'Desktop': |
190 | + self.pointing_device.click_object(object_, press_duration=3) |
191 | + else: |
192 | + # Work around for http://pad.lv/1268782 |
193 | + self.pointing_device.move_to_object(object_) |
194 | + self.pointing_device.press() |
195 | + time.sleep(3) |
196 | + self.pointing_device.release() |
197 | + |
198 | + @autopilot_logging.log_action(logger.info) |
199 | + def delete(self): |
200 | + """Delete the selected messages.""" |
201 | + button = self.select_single( |
202 | + 'Button', objectName='DialogButtons.acceptButton') |
203 | + self.pointing_device.click_object(button) |
204 | + |
205 | + def get_messages(self): |
206 | + """Return a list with the information of the messages. |
207 | + |
208 | + Each item of the returned list is a tuple of (date, text). |
209 | + |
210 | + """ |
211 | + messages = [] |
212 | + # TODO return the messages in the same order that they are displayed. |
213 | + # --elopio - 2014-03-14 |
214 | + for index in range(self.get_messages_count()): |
215 | + message_delegate = self._get_message_delegate(index) |
216 | + date = message_delegate.select_single( |
217 | + 'Label', objectName='messageDate').text |
218 | + text = message_delegate.select_single( |
219 | + 'Label', objectName='messageText').text |
220 | + messages.append((date, text)) |
221 | + return messages |
222 | |
223 | === modified file 'tests/autopilot/messaging_app/tests/test_messaging.py' |
224 | --- tests/autopilot/messaging_app/tests/test_messaging.py 2014-02-19 19:24:28 +0000 |
225 | +++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-03-14 14:23:02 +0000 |
226 | @@ -1,5 +1,5 @@ |
227 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
228 | -# Copyright 2012 Canonical |
229 | +# Copyright 2012, 2014 Canonical |
230 | # |
231 | # This file is part of messaging-app. |
232 | # |
233 | @@ -15,18 +15,17 @@ |
234 | import subprocess |
235 | import time |
236 | |
237 | -from autopilot.introspection import dbus |
238 | from autopilot.matchers import Eventually |
239 | -from testtools.matchers import Equals |
240 | +from testtools.matchers import Equals, HasLength |
241 | from testtools import skipIf |
242 | |
243 | +from messaging_app import emulators |
244 | from messaging_app.tests import MessagingAppTestCase |
245 | |
246 | |
247 | @skipIf(os.uname()[2].endswith('maguro'), |
248 | 'tests cause Unity crashes on maguro') |
249 | -class TestMessaging(MessagingAppTestCase): |
250 | - """Tests for the communication panel.""" |
251 | +class BaseMessagingTestCase(MessagingAppTestCase): |
252 | |
253 | def setUp(self): |
254 | |
255 | @@ -50,7 +49,7 @@ |
256 | subprocess.call(['pkill', 'history-daemon']) |
257 | subprocess.call(['pkill', '-f', 'telephony-service-handler']) |
258 | |
259 | - super(TestMessaging, self).setUp() |
260 | + super(BaseMessagingTestCase, self).setUp() |
261 | |
262 | # no initial messages |
263 | self.thread_list = self.app.select_single(objectName='threadList') |
264 | @@ -58,7 +57,7 @@ |
265 | self.assertThat(self.thread_list.count, Equals(0)) |
266 | |
267 | def tearDown(self): |
268 | - super(TestMessaging, self).tearDown() |
269 | + super(BaseMessagingTestCase, self).tearDown() |
270 | |
271 | # restore history |
272 | try: |
273 | @@ -74,6 +73,10 @@ |
274 | # received"), don't make that stay around for the tests |
275 | subprocess.call(['pkill', '-f', 'notify-osd']) |
276 | |
277 | + |
278 | +class TestMessaging(BaseMessagingTestCase): |
279 | + """Tests for the communication panel.""" |
280 | + |
281 | def test_write_new_message_to_group(self): |
282 | recipient_list = ["123", "321"] |
283 | self.main_view.click_new_message_button() |
284 | @@ -221,47 +224,6 @@ |
285 | self.main_view.get_message('{} 2'.format(message)) |
286 | self.main_view.get_message(message) |
287 | |
288 | - def test_delete_multiple_messages(self): |
289 | - """Verify we can delete multiple messages""" |
290 | - number = '5555559876' |
291 | - message = 'delete me' |
292 | - # send 5 messages |
293 | - for num in range(1, 6): |
294 | - self.main_view.receive_sms(number, '{} {}'.format(message, num)) |
295 | - time.sleep(1) |
296 | - # verify messages show up in thread |
297 | - self.assertThat(self.thread_list.count, Eventually(Equals(1))) |
298 | - |
299 | - mess_thread = self.thread_list.wait_select_single('Label', text=number) |
300 | - self.pointing_device.click_object(mess_thread) |
301 | - |
302 | - # long press on message 5 |
303 | - bubble5 = self.main_view.get_label('delete me 5') |
304 | - self.main_view.long_press(bubble5) |
305 | - |
306 | - # tap message 2 - 4 |
307 | - for num in range(2, 5): |
308 | - bubble = self.main_view.get_label( |
309 | - '{} {}'.format(message, num) |
310 | - ) |
311 | - self.pointing_device.click_object(bubble) |
312 | - |
313 | - # delete messages 2 - 5 |
314 | - self.main_view.click_delete_dialog_button() |
315 | - |
316 | - #verify message 2 - 5 are destroyed |
317 | - for num in range(2, 6): |
318 | - try: |
319 | - bubble = self.main_view.get_label( |
320 | - '{} {}'.format(message, num) |
321 | - ) |
322 | - bubble.wait_until_destroyed() |
323 | - ## if the message is not there it was already destroyed |
324 | - except dbus.StateNotFoundError: |
325 | - pass |
326 | - #verify message bubble 1 exists |
327 | - self.main_view.get_label('delete me 1') |
328 | - |
329 | def test_toolbar_delete_message(self): |
330 | """Verify we can use the toolbar to delete a message""" |
331 | self.main_view.click_new_message_button() |
332 | @@ -507,3 +469,42 @@ |
333 | #delete message |
334 | self.main_view.delete_message(message, direction='left') |
335 | self.assertThat(list_view.count, Eventually(Equals(0))) |
336 | + |
337 | + |
338 | +class MessagingTestCaseWithExistingThread(BaseMessagingTestCase): |
339 | + |
340 | + def setUp(self): |
341 | + super(MessagingTestCaseWithExistingThread, self).setUp() |
342 | + self.main_page = self.main_view.select_single(emulators.MainPage) |
343 | + self.number = '5555559876' |
344 | + self.messages = self.receive_messages() |
345 | + |
346 | + def receive_messages(self): |
347 | + # send 3 messages. Reversed because on the QML, the one with the |
348 | + # 0 index is the latest received. |
349 | + messages = [] |
350 | + message_indexes = list(reversed(range(3))) |
351 | + for index in message_indexes: |
352 | + message_text = 'test message {}'.format(index) |
353 | + self.main_view.receive_sms( |
354 | + self.number, message_text) |
355 | + time.sleep(1) |
356 | + # Prepend to make sure that the indexes match. |
357 | + messages.insert(0, message_text) |
358 | + # Wait for the thread. |
359 | + self.assertThat( |
360 | + self.main_page.get_thread_count, Eventually(Equals(1))) |
361 | + return messages |
362 | + |
363 | + def test_delete_multiple_messages(self): |
364 | + """Verify we can delete multiple messages""" |
365 | + messages_page = self.main_page.open_thread(self.number) |
366 | + |
367 | + messages_page.select_messages(1, 2) |
368 | + messages_page.delete() |
369 | + |
370 | + remaining_messages = messages_page.get_messages() |
371 | + self.assertThat(remaining_messages, HasLength(1)) |
372 | + _, remaining_message_text = remaining_messages[0] |
373 | + self.assertEqual( |
374 | + remaining_message_text, self.messages[0]) |
PASSED: Continuous integration, rev:77 jenkins. qa.ubuntu. com/job/ messaging- app-ci/ 174/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 3901 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/3486 jenkins. qa.ubuntu. com/job/ messaging- app-trusty- amd64-ci/ 89 jenkins. qa.ubuntu. com/job/ messaging- app-trusty- armhf-ci/ 90 jenkins. qa.ubuntu. com/job/ messaging- app-trusty- armhf-ci/ 90/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ messaging- app-trusty- i386-ci/ 89 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 3409 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3934 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3934/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3488 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3488/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/5827 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 4762
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/messaging- app-ci/ 174/rebuild
http://