Merge lp:~chris.gagnon/messaging-app/autopilot-tests-with-contacts into lp:messaging-app

Proposed by Chris Gagnon
Status: Rejected
Rejected by: Tiago Salem Herrmann
Proposed branch: lp:~chris.gagnon/messaging-app/autopilot-tests-with-contacts
Merge into: lp:messaging-app
Prerequisite: lp:~chris.gagnon/messaging-app/autopilot-tests
Diff against target: 1120 lines (+550/-233)
5 files modified
debian/control (+3/-0)
tests/autopilot/messaging_app/data/contacts.sync (+99/-0)
tests/autopilot/messaging_app/emulators.py (+168/-170)
tests/autopilot/messaging_app/tests/__init__.py (+26/-1)
tests/autopilot/messaging_app/tests/test_messaging.py (+254/-62)
To merge this branch: bzr merge lp:~chris.gagnon/messaging-app/autopilot-tests-with-contacts
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+206554@code.launchpad.net

This proposal supersedes a proposal from 2014-02-14.

Commit message

Add contacts tests, re-factor emulator to use page objects

To post a comment you must log in.
Revision history for this message
Chris Gagnon (chris.gagnon) wrote : Posted in a previous version of this proposal

https://code.launchpad.net/~allanlesage/address-book-app/abook_navigation_favorites/+merge/205264/ must land before this MP will work, it's using a helper class from the address-book-app-autopilot, we do this instead of scattering code to add contacts to tests in every project.

Revision history for this message
Allan LeSage (allanlesage) wrote : Posted in a previous version of this proposal

Looks good--agreed that we want to use the pages when they exist, although I don't want to explicitly adopt the 'page' naming convention because the address-book's QML varies, e.g. it's sometimes called a 'view'. Concerning the use of vcards in data files, I think it's more convenient, expressive, and flexible to put the creation of the cards in the tests themselves, however our lib for this is pretty limited at the moment so I don't have much of an argument :) .

review: Approve
Revision history for this message
Allan LeSage (allanlesage) wrote : Posted in a previous version of this proposal

Note that the landing of the helper is blocked on an unrelated test harness improvement bug, possibly I'm make an independent merge of that, or can happen here instead. . . .

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:77
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/~chris.gagnon/messaging-app/autopilot-tests-with-contacts/+merge/206552/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/messaging-app-ci/159/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3256/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2926/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-amd64-ci/74
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/75
        deb: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/75/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-i386-ci/74
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2864/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3258
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3258/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2928
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2928/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5332/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3981

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/messaging-app-ci/159/rebuild

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

FAILED: Continuous integration, rev:77
http://jenkins.qa.ubuntu.com/job/messaging-app-ci/160/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3257/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2927/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-amd64-ci/75
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/76
        deb: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/76/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-i386-ci/75
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2865/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3259
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3259/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2929
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2929/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5333/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3982

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/messaging-app-ci/160/rebuild

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

FAILED: Continuous integration, rev:78
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/~chris.gagnon/messaging-app/autopilot-tests-with-contacts/+merge/206554/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/messaging-app-ci/161/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3258/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2928/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-amd64-ci/76
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/77
        deb: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-armhf-ci/77/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/messaging-app-trusty-i386-ci/76
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2866/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3260
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3260/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2930
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2930/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5334/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3983

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/messaging-app-ci/161/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote : Posted in a previous version of this proposal

the following package names are incorrect:
evolution-data-service should be evolution-data-server
address-boot-app-autopilot should be address-book-app-autopilot

review: Needs Fixing
79. By Chris Gagnon

fix build deps in control

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

Just a reminder from the first comment https://code.launchpad.net/~allanlesage/address-book-app/abook_navigation_favorites/+merge/205264/ must land before this MP will work, it's using a helper class from the address-book-app-autopilot, we do this instead of scattering code to add contacts to tests in every project.

Unmerged revisions

79. By Chris Gagnon

fix build deps in control

78. By Chris Gagnon

remove toolbar from message page object, it's in the main view and going away.

77. By Chris Gagnon

 use page objects for emulator

76. By Chris Gagnon

add a couple more tests

75. By Chris Gagnon

add test cases

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-11-21 13:26:32 +0000
3+++ debian/control 2014-02-17 16:29:41 +0000
4@@ -42,6 +42,9 @@
5 python-autopilot,
6 ubuntu-ui-toolkit-autopilot,
7 ofono-phonesim-autostart,
8+ evolution-data-server,
9+ address-book-app-autopilot,
10+ telephony-service,
11 Description: autopilot tests for messaging-app
12 This package contains the autopilot tests for messaging-app
13 .
14
15=== added directory 'tests/autopilot/messaging_app/data'
16=== added file 'tests/autopilot/messaging_app/data/contacts.sync'
17--- tests/autopilot/messaging_app/data/contacts.sync 1970-01-01 00:00:00 +0000
18+++ tests/autopilot/messaging_app/data/contacts.sync 2014-02-17 16:29:41 +0000
19@@ -0,0 +1,99 @@
20+BEGIN:VCARD
21+VERSION:3.0
22+UID:pas-id-52FD502C000000BE
23+N:;Aa;;;
24+X-EVOLUTION-FILE-AS:Aa
25+ADR;TYPE=home:;;;;;;
26+REV:2014-02-13T23:08:07Z(390)
27+FN:Aa
28+TEL;TYPE=mobile,home:1
29+TEL;TYPE=work,landline:9
30+END:VCARD
31+
32+BEGIN:VCARD
33+VERSION:3.0
34+UID:pas-id-52FD502D000000BF
35+N:;Aaa;;;
36+X-EVOLUTION-FILE-AS:Aaa
37+TEL;TYPE=mobile,home:11
38+ADR;TYPE=home:;;;;;;
39+REV:2014-02-12T01:56:20Z(92)
40+FN:Aaa
41+END:VCARD
42+
43+BEGIN:VCARD
44+VERSION:3.0
45+UID:pas-id-52FD502D000000C0
46+N:;Aaaa;;;
47+X-EVOLUTION-FILE-AS:Aaaa
48+TEL;TYPE=mobile,home:111
49+ADR;TYPE=home:;;;;;;
50+REV:2014-02-12T01:56:32Z(94)
51+FN:Aaaa
52+END:VCARD
53+
54+BEGIN:VCARD
55+VERSION:3.0
56+UID:pas-id-52FD502D000000C1
57+N:;Bbbb;;;
58+X-EVOLUTION-FILE-AS:Bbbb
59+TEL;TYPE=mobile,home:222
60+ADR;TYPE=home:;;;;;;
61+REV:2014-02-12T01:56:49Z(96)
62+FN:Bbbb
63+END:VCARD
64+
65+BEGIN:VCARD
66+VERSION:3.0
67+UID:pas-id-52FD502D000000C2
68+N:;Bb;;;
69+X-EVOLUTION-FILE-AS:Bb
70+TEL;TYPE=mobile,home:2
71+ADR;TYPE=home:;;;;;;
72+REV:2014-02-12T01:56:59Z(98)
73+FN:Bb
74+END:VCARD
75+
76+BEGIN:VCARD
77+VERSION:3.0
78+UID:pas-id-52FD502E000000C3
79+N:;Bbb;;;
80+X-EVOLUTION-FILE-AS:Bbb
81+ADR;TYPE=home:;;;;;;
82+FN:Bbb
83+TEL;TYPE=mobile,home:22
84+REV:2014-02-12T01:57:18Z(102)
85+END:VCARD
86+
87+BEGIN:VCARD
88+VERSION:3.0
89+UID:pas-id-52FD502E000000C4
90+N:;Cccc;;;
91+X-EVOLUTION-FILE-AS:Cccc
92+TEL;TYPE=mobile,home:333
93+ADR;TYPE=home:;;;;;;
94+REV:2014-02-12T14:22:48Z(104)
95+FN:Cccc
96+END:VCARD
97+
98+BEGIN:VCARD
99+VERSION:3.0
100+UID:pas-id-52FD502E000000C5
101+N:;Cc;;;
102+X-EVOLUTION-FILE-AS:Cc
103+TEL;TYPE=mobile,home:3
104+ADR;TYPE=home:;;;;;;
105+REV:2014-02-12T14:23:02Z(106)
106+FN:Cc
107+END:VCARD
108+
109+BEGIN:VCARD
110+VERSION:3.0
111+UID:pas-id-52FD502E000000C6
112+N:;Ccc;;;
113+X-EVOLUTION-FILE-AS:Ccc
114+TEL;TYPE=mobile,home:33
115+ADR;TYPE=home:;;;;;;
116+REV:2014-02-12T14:23:18Z(108)
117+FN:Ccc
118+END:VCARD
119\ No newline at end of file
120
121=== modified file 'tests/autopilot/messaging_app/emulators.py'
122--- tests/autopilot/messaging_app/emulators.py 2014-02-17 16:29:40 +0000
123+++ tests/autopilot/messaging_app/emulators.py 2014-02-17 16:29:41 +0000
124@@ -35,11 +35,25 @@
125 self.logger = logging.getLogger(__name__)
126
127 def get_pagestack(self):
128- """Return PageStack with objectName mainStack"""
129+ """Returns PageStack with objectName mainStack"""
130 return self.select_single("PageStack", objectName="mainStack")
131
132+ def click_new_message_button(self):
133+ """Click "Compose/ new message" button from toolbar on main page"""
134+
135+ toolbar = self.open_toolbar()
136+ toolbar.click_button("newMessageButton")
137+ toolbar.animating.wait_for(False)
138+
139+ def click_select_button(self):
140+ """Click select button from toolbar on main page"""
141+
142+ toolbar = self.open_toolbar()
143+ toolbar.click_button("selectButton")
144+ toolbar.animating.wait_for(False)
145+
146 def get_thread_from_number(self, phone_number):
147- """Return thread from number
148+ """Returns thread from number
149
150 :parameter phone_number: the phone_number of message thread
151
152@@ -54,112 +68,26 @@
153 raise EmulatorException('Could not find thread with the phone number '
154 '{}'.format(phone_number))
155
156- def get_message(self, text):
157- """Return message from text
158-
159- :parameter text: the text or date of the label in the message
160-
161- """
162-
163- time.sleep(2) # message is not always found on slow emulator
164- for message in self.select_many('MessageDelegate'):
165- for item in self.select_many('Label'):
166- if "text" in item.get_properties():
167- if item.get_properties()['text'] == text:
168- return message
169- raise EmulatorException('Could not find message with the text '
170- '{}'.format(text))
171-
172 def get_label(self, text):
173- """Return label from text
174+ """Returns label from text
175
176 :parameter text: the text of the label to return
177 """
178
179- return self.select_single('Label', visible=True, text=text)
180+ return self.wait_select_single('Label', visible=True, text=text)
181
182 def get_main_page(self):
183- """Return messages with objectName messagesPage"""
184+ """Returns messages with objectName messagesPage"""
185
186 return self.wait_select_single("MainPage", objectName="")
187
188- #messages page
189- def get_messages_page(self):
190- """Return messages with objectName messagesPage"""
191-
192- return self.wait_select_single("Messages", objectName="messagesPage")
193-
194- def get_newmessage_textfield(self):
195- """Return TextField with objectName newPhoneNumberField"""
196-
197- return self.select_single(
198- "TextField",
199- objectName="newPhoneNumberField",
200- )
201-
202- def get_multiple_selection_list_view(self):
203- """Return MultipleSelectionListView from the messages page"""
204-
205- page = self.get_messages_page()
206- return page.select_single('MultipleSelectionListView')
207-
208- def get_newmessage_textarea(self):
209- """Return TextArea with blank objectName"""
210-
211- return self.select_single('TextArea', objectName='')
212-
213- def get_send_button(self):
214- """Return Button with text Send"""
215-
216- return self.select_single('Button', text='Send')
217-
218- def get_toolbar_back_button(self):
219- """Return toolbar button with objectName back_toolbar_button"""
220-
221- return self.select_single(
222- 'ActionItem',
223- objectName='back_toolbar_button',
224- )
225-
226- def get_toolbar_select_messages_button(self):
227- """Return toolbar button with objectName selectMessagesButton"""
228-
229- return self.select_single(
230- 'ActionItem',
231- objectName='selectMessagesButton',
232- )
233-
234- def get_toolbar_add_contact_button(self):
235- """Return toolbar button with objectName addContactButton"""
236-
237- return self.select_single(
238- 'ActionItem',
239- objectName='addContactButton',
240- )
241-
242- def get_toolbar_contact_profile_button(self):
243- """Return toolbar button with objectName contactProfileButton"""
244-
245- return self.select_single(
246- 'ActionItem',
247- objectName='contactProfileButton',
248- )
249-
250- def get_toolbar_contact_call_button(self):
251- """Return toolbar button with objectName contactCallButton"""
252-
253- return self.select_single(
254- 'ActionItem',
255- objectName='contactCallButton',
256- )
257-
258 def get_header(self):
259- """return header object"""
260+ """Returns header object"""
261
262 return self.select_single('Header', objectName='MainView_Header')
263
264 def get_dialog_buttons(self, visible=True):
265- """Return DialogButtons
266+ """Returns DialogButtons
267
268 :parameter visible: the visible state of the dialog button
269 """
270@@ -170,30 +98,32 @@
271 return self.select_many('DialogButtons', visible=False)
272
273 def get_visible_cancel_dialog_button(self):
274- """Return dialog Button with text Cancel"""
275+ """Returns dialog Button with text Cancel"""
276
277 dialog_buttons = self.get_dialog_buttons()
278 return dialog_buttons.select_single('Button', text='Cancel')
279
280 def get_visible_delete_dialog_button(self):
281- """Return dialog Button with text Delete"""
282+ """Returns dialog Button with text Delete"""
283
284 dialog_buttons = self.get_dialog_buttons()
285 return dialog_buttons.select_single('Button', text='Delete')
286
287 def click_cancel_dialog_button(self):
288- """Click on dialog button cancel"""
289+ """Returns button, after clicking on dialog button cancel"""
290
291 button = self.get_visible_cancel_dialog_button()
292 self.pointing_device.click_object(button)
293 button.visible.wait_for(False)
294+ return button
295
296 def click_delete_dialog_button(self):
297- """Click on dialog button delete"""
298+ """Returns button after clicking on dialog button delete"""
299
300 button = self.get_visible_delete_dialog_button()
301 self.pointing_device.click_object(button)
302 button.visible.wait_for(False)
303+ return button
304
305 def long_press(self, obj):
306 """long press on object because press_duration is not honored on touch
307@@ -207,63 +137,6 @@
308 time.sleep(3)
309 self.pointing_device.release()
310
311- def type_message(self, message):
312- """Select and type message in new message text area in messages page
313-
314- :parameter message: the message to type
315- """
316-
317- text_entry = self.get_newmessage_textarea()
318- self.pointing_device.click_object(text_entry)
319- text_entry.focus.wait_for(True)
320- time.sleep(.3)
321- self.keyboard.type(str(message), delay=0.2)
322- self.logger.info(
323- 'typed: "{}" expected: "{}"'.format(text_entry.text, message))
324-
325- def type_contact_phone_num(self, num_or_contact):
326- """Select and type phone number or contact
327-
328- :parameter num_or_contact: number or contact to type
329- """
330-
331- text_entry = self.get_newmessage_textfield()
332- self.pointing_device.click_object(text_entry)
333- text_entry.focus.wait_for(True)
334- time.sleep(.3)
335- self.keyboard.type(str(num_or_contact), delay=0.2)
336- self.logger.info(
337- 'typed "{}" expected "{}"'.format(text_entry.text, num_or_contact))
338-
339- def click_send_button(self):
340- """Click the send button on the message page"""
341-
342- button = self.get_send_button()
343- button.enabled.wait_for(True)
344- self.pointing_device.click_object(button)
345- button.enabled.wait_for(False)
346-
347- def click_new_message_button(self):
348- """Click "Compose/ new message" button from toolbar on main page"""
349-
350- toolbar = self.open_toolbar()
351- toolbar.click_button("newMessageButton")
352- toolbar.animating.wait_for(False)
353-
354- def click_select_button(self):
355- """Click select button from toolbar on main page"""
356-
357- toolbar = self.open_toolbar()
358- toolbar.click_button("selectButton")
359- toolbar.animating.wait_for(False)
360-
361- def click_select_messages_button(self):
362- """Click select messages button from toolbar on messages page"""
363-
364- toolbar = self.open_toolbar()
365- toolbar.click_button("selectMessagesButton")
366- toolbar.animating.wait_for(False)
367-
368 def close_osk(self):
369 """Swipe down to close on-screen keyboard"""
370
371@@ -273,42 +146,74 @@
372 #wait for server to respawn
373 time.sleep(2)
374
375+ def click_visible_label(self, text):
376+ """Returns and clicks visible label with matching text
377+
378+ :parameter text: the text of the label you want to click
379+ """
380+
381+ label = self.get_label(text)
382+ self.pointing_device.click_object(label)
383+ return label
384+
385+ def click_close_contact_button(self):
386+ """Returns and clicks the close contact button"""
387+
388+ button = self.select_single('Button', text='close', visible=True)
389+ self.pointing_device.click_object(button)
390+ return button
391+
392+ def get_contact_list_view(self):
393+ """Returns the contact list view"""
394+
395+ return self.select_single('ContactListView', text='')
396+
397+ def delete_thread(self, phone_number, direction='right'):
398+ """Delete thread containing specified phone number
399+
400+ :parameter phone_number: phone number of thread to delete
401+ :parameter direction: right or left, the direction to swipe to delete
402+ """
403+
404+ thread = self.get_thread_from_number(phone_number)
405+ delete = self.swipe_to_delete(thread, direction=direction)
406+ delete_button = delete.wait_select_single('QQuickImage', visible=True)
407+ self.pointing_device.click_object(delete_button)
408+ thread.wait_until_destroyed()
409+
410+ def click_select_messages_button(self):
411+ """Click select messages button from toolbar on messages page"""
412+
413+ toolbar = self.open_toolbar()
414+ toolbar.click_button("selectMessagesButton")
415+ toolbar.animating.wait_for(False)
416+
417 def click_add_button(self):
418- """Click add button from toolbar on messages page"""
419+ """Returns and click add button from toolbar on messages page"""
420
421 toolbar = self.open_toolbar()
422 button = toolbar.wait_select_single("ActionItem", text=u"Add")
423 self.pointing_device.click_object(button)
424 toolbar.animating.wait_for(False)
425+ return button
426
427 def click_call_button(self):
428- """Click call button from toolbar on messages page"""
429+ """Returns and click call button from toolbar on messages page"""
430
431 toolbar = self.open_toolbar()
432 button = toolbar.wait_select_single("ActionItem", text=u"Call")
433 self.pointing_device.click_object(button)
434 toolbar.animating.wait_for(False)
435+ return button
436
437 def click_back_button(self):
438- """Click back button from toolbar on messages page"""
439+ """Returns and click back button from toolbar on messages page"""
440
441 toolbar = self.open_toolbar()
442 button = toolbar.wait_select_single("ActionItem", text=u"Back")
443 self.pointing_device.click_object(button)
444 toolbar.animating.wait_for(False)
445-
446- def delete_thread(self, phone_number, direction='right'):
447- """Delete thread containing specified phone number
448-
449- :parameter phone_number: phone number of thread to delete
450- :parameter direction: right or left, the direction to swipe to delete
451- """
452-
453- thread = self.get_thread_from_number(phone_number)
454- delete = self.swipe_to_delete(thread, direction=direction)
455- delete_button = delete.wait_select_single('QQuickImage', visible=True)
456- self.pointing_device.click_object(delete_button)
457- thread.wait_until_destroyed()
458+ return button
459
460 def delete_message(self, text, direction='right'):
461 """Deletes message with specified text
462@@ -323,6 +228,11 @@
463 self.pointing_device.click_object(delete_button)
464 message.wait_until_destroyed()
465
466+ def get_messages_page(self):
467+ """Returns messages with objectName messagesPage"""
468+
469+ return self.wait_select_single("Messages", objectName="messagesPage")
470+
471 def swipe_to_delete(self, obj, direction='right', offset=.1):
472 """Swipe and objet left or right
473
474@@ -385,3 +295,91 @@
475 script_proxy.SetPath(script_dir)
476 script_proxy.Run("sms.js")
477 shutil.rmtree(script_dir)
478+
479+
480+class Messages(MainView):
481+ def __init__(self, *args):
482+ super(Messages, self).__init__(*args)
483+
484+ def get_message(self, text):
485+ """Returns message from text
486+
487+ :parameter text: the text or date of the label in the message
488+
489+ """
490+
491+ time.sleep(2) # message is not always found on slow emulator
492+ for message in self.select_many('MessageDelegate'):
493+ for item in self.select_many('Label'):
494+ if "text" in item.get_properties():
495+ if item.get_properties()['text'] == text:
496+ return message
497+ raise EmulatorException('Could not find message with the text '
498+ '{}'.format(text))
499+
500+ def get_newmessage_textfield(self):
501+ """Returns TextField with objectName newPhoneNumberField"""
502+
503+ return self.select_single(
504+ "TextField",
505+ objectName="newPhoneNumberField",
506+ )
507+
508+ def get_multiple_selection_list_view(self):
509+ """Returns MultipleSelectionListView from the messages page"""
510+
511+ return self.select_single('MultipleSelectionListView')
512+
513+ def get_newmessage_textarea(self):
514+ """Returns TextArea with blank objectName"""
515+
516+ return self.select_single('TextArea', objectName='')
517+
518+ def get_send_button(self):
519+ """Returns Button with text Send"""
520+
521+ return self.select_single('Button', text='Send')
522+
523+ def type_message(self, message):
524+ """Select and type message in new message text area in messages page
525+
526+ :parameter message: the message to type
527+ """
528+
529+ text_entry = self.get_newmessage_textarea()
530+ self.pointing_device.click_object(text_entry)
531+ text_entry.focus.wait_for(True)
532+ time.sleep(.3)
533+ self.keyboard.type(str(message), delay=0.2)
534+ self.logger.info(
535+ 'typed: "{}" expected: "{}"'.format(text_entry.text, message))
536+
537+ def type_contact_phone_num(self, num_or_contact):
538+ """Select and type phone number or contact
539+
540+ :parameter num_or_contact: number or contact to type
541+ """
542+
543+ text_entry = self.get_newmessage_textfield()
544+ self.pointing_device.click_object(text_entry)
545+ text_entry.focus.wait_for(True)
546+ time.sleep(.3)
547+ self.keyboard.type(str(num_or_contact), delay=0.2)
548+ self.logger.info(
549+ 'typed "{}" expected "{}"'.format(text_entry.text, num_or_contact))
550+
551+ def click_send_button(self):
552+ """Returns and click the send button on the message page"""
553+
554+ button = self.get_send_button()
555+ button.enabled.wait_for(True)
556+ self.pointing_device.click_object(button)
557+ button.enabled.wait_for(False)
558+ return button
559+
560+ def click_add_new_contact_button(self):
561+ """Returns and clicks the add contact button on the message page"""
562+
563+ icon = self.select_single("Icon", name="new-contact")
564+ self.pointing_device.click_object(icon)
565+ return icon
566
567=== modified file 'tests/autopilot/messaging_app/tests/__init__.py'
568--- tests/autopilot/messaging_app/tests/__init__.py 2014-02-17 16:29:40 +0000
569+++ tests/autopilot/messaging_app/tests/__init__.py 2014-02-17 16:29:41 +0000
570@@ -15,8 +15,12 @@
571 from autopilot.testcase import AutopilotTestCase
572 from testtools.matchers import Equals
573
574+from address_book_app.helpers import (backup_evolution_contacts_db,
575+ restore_evolution_contacts_db,
576+ wipe_evolution_contacts_db)
577+
578+from messaging_app import emulators
579 from ubuntuuitoolkit import emulators as toolkit_emulators
580-from messaging_app import emulators
581
582 import os
583 import sys
584@@ -68,6 +72,16 @@
585
586 subprocess.call(['pkill', 'messaging-app'])
587
588+ # backup and add contacts
589+ current_dir = os.path.abspath(os.path.dirname(__file__))
590+ self.test_contacts_db = os.path.abspath(
591+ current_dir + "../../data/contacts.sync"
592+ )
593+
594+ self.tmp_contacts_backup = backup_evolution_contacts_db()
595+ wipe_evolution_contacts_db()
596+ restore_evolution_contacts_db(self.test_contacts_db)
597+
598 if os.path.exists(self.local_location):
599 self.launch_test_local()
600 else:
601@@ -75,6 +89,13 @@
602
603 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
604
605+ def tearDown(self):
606+ super(MessagingAppTestCase, self).tearDown()
607+ # restore contacts
608+ wipe_evolution_contacts_db()
609+ restore_evolution_contacts_db(self.tmp_contacts_backup)
610+ os.remove(self.tmp_contacts_backup)
611+
612 def launch_test_local(self):
613 self.app = self.launch_test_application(
614 self.local_location,
615@@ -100,3 +121,7 @@
616 @property
617 def main_view(self):
618 return self.app.select_single(emulators.MainView)
619+
620+ @property
621+ def message_page(self):
622+ return self.app.select_single(emulators.Messages)
623
624=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
625--- tests/autopilot/messaging_app/tests/test_messaging.py 2014-02-17 16:29:40 +0000
626+++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-02-17 16:29:41 +0000
627@@ -18,13 +18,10 @@
628 from autopilot.introspection import dbus
629 from autopilot.matchers import Eventually
630 from testtools.matchers import Equals
631-from testtools import skipIf
632
633 from messaging_app.tests import MessagingAppTestCase
634
635
636-@skipIf(os.uname()[2].endswith('maguro'),
637- 'tests cause Unity crashes on maguro')
638 class TestMessaging(MessagingAppTestCase):
639 """Tests for the communication panel."""
640
641@@ -96,20 +93,20 @@
642
643 # type contact/number
644 phone_num = 123
645- self.main_view.type_contact_phone_num(phone_num)
646+ self.message_page.type_contact_phone_num(phone_num)
647
648 # type message
649 message = 'hello from Ubuntu'
650- self.main_view.type_message(message)
651+ self.message_page.type_message(message)
652
653 # send
654- self.main_view.click_send_button()
655+ self.message_page.click_send_button()
656
657 # verify that we get a bubble with our message
658- list_view = self.main_view.get_multiple_selection_list_view()
659+ list_view = self.message_page.get_multiple_selection_list_view()
660 self.assertThat(list_view.count, Eventually(Equals(1)))
661 # verify label text
662- self.main_view.get_message('hello from Ubuntu')
663+ self.message_page.get_message('hello from Ubuntu')
664
665 # switch back to main page with thread list
666 self.main_view.close_osk()
667@@ -133,18 +130,18 @@
668
669 # type address number
670 phone_num = '555-555-4321'
671- self.main_view.type_contact_phone_num(phone_num)
672+ self.message_page.type_contact_phone_num(phone_num)
673 # type message
674 message = 'delete me'
675- self.main_view.type_message(message)
676+ self.message_page.type_message(message)
677
678 # send
679- self.main_view.click_send_button()
680+ self.message_page.click_send_button()
681
682 # verify that we get a bubble with our message
683- list_view = self.main_view.get_multiple_selection_list_view()
684+ list_view = self.message_page.get_multiple_selection_list_view()
685 self.assertThat(list_view.count, Eventually(Equals(1)))
686- bubble = self.main_view.get_message(message)
687+ bubble = self.message_page.get_message(message)
688
689 self.main_view.close_osk()
690
691@@ -164,19 +161,19 @@
692
693 # type address number
694 phone_num = '5555551234'
695- self.main_view.type_contact_phone_num(phone_num)
696+ self.message_page.type_contact_phone_num(phone_num)
697
698 # type message
699 message = 'do not delete'
700- self.main_view.type_message(message)
701+ self.message_page.type_message(message)
702
703 # send
704- self.main_view.click_send_button()
705+ self.message_page.click_send_button()
706
707 # verify that we get a bubble with our message
708- list_view = self.main_view.get_multiple_selection_list_view()
709+ list_view = self.message_page.get_multiple_selection_list_view()
710 self.assertThat(list_view.count, Eventually(Equals(1)))
711- bubble = self.main_view.get_message(message)
712+ bubble = self.message_page.get_message(message)
713
714 self.main_view.close_osk()
715
716@@ -185,7 +182,7 @@
717 self.main_view.click_cancel_dialog_button()
718 time.sleep(5) # on a slow machine it might return a false positive
719 #the bubble must exist
720- bubble = self.main_view.get_message(message)
721+ bubble = self.message_page.get_message(message)
722
723 def test_open_received_message(self):
724 """Verify we can open a txt message we have received"""
725@@ -197,13 +194,13 @@
726 # click message thread
727 mess_thread = self.thread_list.wait_select_single('Label', text=number)
728 self.pointing_device.click_object(mess_thread)
729- self.main_view.get_message(message)
730+ self.message_page.get_message(message)
731 # send new message
732- self.main_view.type_message('{} 2'.format(message))
733- self.main_view.click_send_button()
734+ self.message_page.type_message('{} 2'.format(message))
735+ self.message_page.click_send_button()
736 # verify both messages are seen in list
737- self.main_view.get_message('{} 2'.format(message))
738- self.main_view.get_message(message)
739+ self.message_page.get_message('{} 2'.format(message))
740+ self.message_page.get_message(message)
741
742 def test_delete_multiple_messages(self):
743 """Verify we can delete multiple messages"""
744@@ -253,18 +250,18 @@
745
746 # type address number
747 phone_num = '555-555-4321'
748- self.main_view.type_contact_phone_num(phone_num)
749+ self.message_page.type_contact_phone_num(phone_num)
750 # type message
751 message = 'delete me'
752- self.main_view.type_message(message)
753+ self.message_page.type_message(message)
754
755 # send
756- self.main_view.click_send_button()
757+ self.message_page.click_send_button()
758
759 # verify that we get a bubble with our message
760- list_view = self.main_view.get_multiple_selection_list_view()
761+ list_view = self.message_page.get_multiple_selection_list_view()
762 self.assertThat(list_view.count, Eventually(Equals(1)))
763- bubble = self.main_view.get_message(message)
764+ bubble = self.message_page.get_message(message)
765
766 self.main_view.close_osk()
767
768@@ -282,18 +279,18 @@
769
770 # type address number
771 phone_num = '555-555-4321'
772- self.main_view.type_contact_phone_num(phone_num)
773+ self.message_page.type_contact_phone_num(phone_num)
774 # type message
775 message = 'dont delete me'
776- self.main_view.type_message(message)
777+ self.message_page.type_message(message)
778
779 # send
780- self.main_view.click_send_button()
781+ self.message_page.click_send_button()
782
783 # verify that we get a bubble with our message
784- list_view = self.main_view.get_multiple_selection_list_view()
785+ list_view = self.message_page.get_multiple_selection_list_view()
786 self.assertThat(list_view.count, Eventually(Equals(1)))
787- self.main_view.get_message(message)
788+ self.message_page.get_message(message)
789
790 self.main_view.close_osk()
791
792@@ -305,7 +302,7 @@
793 time.sleep(5) # wait 5 seconds, the emulator is slow
794 list_view.select_single("Label", text=message)
795
796- def test_recieve_text_with_letters_in_phone_number(self):
797+ def test_receive_text_with_letters_in_phone_number(self):
798 """verify we can receive a text message with letters for a phone #"""
799 number = 'letters'
800 message = 'open me'
801@@ -318,13 +315,13 @@
802 text='letters@' # phonesim sends text with number as letters@
803 )
804 self.pointing_device.click_object(mess_thread)
805- self.main_view.get_message(message)
806+ self.message_page.get_message(message)
807 # send new message
808- self.main_view.type_message('{} 2'.format(message))
809- self.main_view.click_send_button()
810+ self.message_page.type_message('{} 2'.format(message))
811+ self.message_page.click_send_button()
812 # verify both messages are seen in list
813- self.main_view.get_message('{} 2'.format(message))
814- self.main_view.get_message(message)
815+ self.message_page.get_message('{} 2'.format(message))
816+ self.message_page.get_message(message)
817
818 def test_cancel_delete_thread_from_main_view(self):
819 """Verify we can cancel deleting a message thread"""
820@@ -334,20 +331,20 @@
821
822 # type contact/number
823 phone_num = 123
824- self.main_view.type_contact_phone_num(phone_num)
825+ self.message_page.type_contact_phone_num(phone_num)
826
827 # type message
828 message = 'hello from Ubuntu'
829- self.main_view.type_message(message)
830+ self.message_page.type_message(message)
831
832 # send
833- self.main_view.click_send_button()
834+ self.message_page.click_send_button()
835
836 # verify that we get a bubble with our message
837- list_view = self.main_view.get_multiple_selection_list_view()
838+ list_view = self.message_page.get_multiple_selection_list_view()
839 self.assertThat(list_view.count, Eventually(Equals(1)))
840 # verify label text
841- self.main_view.get_message('hello from Ubuntu')
842+ self.message_page.get_message('hello from Ubuntu')
843
844 # switch back to main page with thread list
845 self.main_view.close_osk()
846@@ -382,20 +379,20 @@
847
848 # type contact/number
849 phone_num = 123
850- self.main_view.type_contact_phone_num(phone_num)
851+ self.message_page.type_contact_phone_num(phone_num)
852
853 # type message
854 message = 'hello from Ubuntu'
855- self.main_view.type_message(message)
856+ self.message_page.type_message(message)
857
858 # send
859- self.main_view.click_send_button()
860+ self.message_page.click_send_button()
861
862 # verify that we get a bubble with our message
863- list_view = self.main_view.get_multiple_selection_list_view()
864+ list_view = self.message_page.get_multiple_selection_list_view()
865 self.assertThat(list_view.count, Eventually(Equals(1)))
866 # verify label text
867- self.main_view.get_message('hello from Ubuntu')
868+ self.message_page.get_message('hello from Ubuntu')
869
870 # switch back to main page with thread list
871 self.main_view.close_osk()
872@@ -439,21 +436,21 @@
873
874 # type address number
875 phone_num = '555-555-4321'
876- self.main_view.type_contact_phone_num(phone_num)
877+ self.message_page.type_contact_phone_num(phone_num)
878 # type message
879 message = 'delete me okay'
880- self.main_view.type_message(message)
881+ self.message_page.type_message(message)
882
883 # send
884- self.main_view.click_send_button()
885+ self.message_page.click_send_button()
886
887 # verify that we get a bubble with our message
888- list_view = self.main_view.get_multiple_selection_list_view()
889+ list_view = self.message_page.get_multiple_selection_list_view()
890 self.assertThat(list_view.count, Eventually(Equals(1)))
891- self.main_view.get_message(message)
892+ self.message_page.get_message(message)
893
894 #delete message
895- self.main_view.delete_message(message)
896+ self.message_page.delete_message(message)
897 self.assertThat(list_view.count, Eventually(Equals(0)))
898
899 def test_delete_message_thread_swipe_left(self):
900@@ -475,19 +472,214 @@
901
902 # type address number
903 phone_num = '555-555-4321'
904- self.main_view.type_contact_phone_num(phone_num)
905+ self.message_page.type_contact_phone_num(phone_num)
906 # type message
907 message = 'delete me okay'
908- self.main_view.type_message(message)
909+ self.message_page.type_message(message)
910
911 # send
912- self.main_view.click_send_button()
913+ self.message_page.click_send_button()
914
915 # verify that we get a bubble with our message
916- list_view = self.main_view.get_multiple_selection_list_view()
917+ list_view = self.message_page.get_multiple_selection_list_view()
918 self.assertThat(list_view.count, Eventually(Equals(1)))
919- self.main_view.get_message(message)
920+ self.message_page.get_message(message)
921
922 #delete message
923- self.main_view.delete_message(message, direction='left')
924+ self.message_page.delete_message(message, direction='left')
925 self.assertThat(list_view.count, Eventually(Equals(0)))
926+
927+ def test_receive_long_message(self):
928+ """Verify that we dont crash after receiving a realy long text message
929+ """
930+ # receive an sms message
931+ message = str('loong' * 4000)
932+ self.main_view.receive_sms('0815', message)
933+
934+ # verify that we got the message
935+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
936+
937+ # verify number
938+ self.thread_list.select_single('Label', text='0815')
939+ time.sleep(1) # make it visible to human users for a sec
940+ # verify text
941+ self.thread_list.select_single('Label', text=message)
942+
943+ def test_receiving_text_to_existing_contact(self):
944+ """Verify contact name is used when receiving message from existing
945+ contact
946+ """
947+ # receive an sms message
948+ message = 'message from Bb'
949+ self.main_view.receive_sms('2', message)
950+
951+ # verify that we got the message
952+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
953+
954+ # verify number
955+ self.thread_list.select_single('Label', text="Bb")
956+ time.sleep(1) # make it visible to human users for a sec
957+ # verify text
958+ self.thread_list.select_single('Label', text=message)
959+
960+ def test_send_message_using_new_contacts_button(self):
961+ """Verify new contacts name lets you send a message to existing contact
962+ """
963+ self.main_view.click_new_message_button()
964+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
965+
966+ # type address number
967+ phone_num = '111'
968+ contact_name = 'Aaaa'
969+
970+ # use new contacts to select contact
971+ self.message_page.click_add_new_contact_button()
972+
973+ contact_label = self.main_view.click_visible_label(contact_name)
974+ self.main_view.click_visible_label(phone_num)
975+
976+ contact_label.wait_until_destroyed()
977+
978+ # type message
979+ message = 'test message'
980+ self.message_page.type_message(message)
981+
982+ # send
983+ self.message_page.click_send_button()
984+
985+ # verify that we get a bubble with our message
986+ list_view = self.message_page.get_multiple_selection_list_view()
987+ self.assertThat(list_view.count, Eventually(Equals(1)))
988+ self.message_page.get_message(message)
989+
990+ # verify the header has the selected contact name
991+ self.assertThat(self.main_view.get_header().title,
992+ Eventually(Equals(contact_name)))
993+
994+ def test_receive_text_from_contact_with_more_than_one_phone_number(self):
995+ """Verify that a text can be received from a contact with more than one
996+ phone number
997+ """
998+ message1 = '1 from Aa'
999+ message2 = '2 from Aa'
1000+
1001+ # send messages
1002+ self.main_view.receive_sms('1', message1)
1003+ time.sleep(1) # The last message needs to be displayed as the thread
1004+ self.main_view.receive_sms('9', message2)
1005+
1006+ # we should have 2 threads
1007+ self.assertThat(self.thread_list.count, Eventually(Equals(2)))
1008+
1009+ # verify contact name and both numbers are displayed
1010+ self.thread_list.select_many('Label', text='Aa')
1011+ time.sleep(2) # make it human readable
1012+ self.thread_list.select_single('Label', text='Work')
1013+ self.thread_list.select_single('Label', text='Mobile')
1014+ # verify text
1015+ self.thread_list.select_single('Label', text=message2)
1016+ self.thread_list.select_single('Label', text=message1)
1017+
1018+ def test_contact_predictive_text(self):
1019+ """test predictive text when selecting contact"""
1020+ self.main_view.click_new_message_button()
1021+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1022+
1023+ # select contact via predictive text
1024+ self.message_page.type_contact_phone_num('a')
1025+ self.main_view.click_visible_label('Aaa')
1026+
1027+ self.assertThat(self.main_view.get_header().title,
1028+ Eventually(Equals('Aaa')))
1029+
1030+ def test_send_text_to_contact_with_more_than_one_number(self):
1031+ """Send a text to a contact with more than one number"""
1032+ message = 'Aa get this'
1033+
1034+ self.main_view.click_new_message_button()
1035+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1036+
1037+ self.message_page.type_contact_phone_num('1')
1038+
1039+ self.message_page.type_message(message)
1040+
1041+ self.message_page.click_send_button()
1042+
1043+ # verify that we get a bubble with our message
1044+ list_view = self.message_page.get_multiple_selection_list_view()
1045+ self.assertThat(list_view.count, Eventually(Equals(1)))
1046+ # verify label text
1047+ self.message_page.get_message(message)
1048+
1049+ self.assertThat(self.main_view.get_header().title,
1050+ Eventually(Equals('Aa')))
1051+
1052+ # switch back to main page with thread list
1053+ self.main_view.close_osk()
1054+ self.main_view.go_back()
1055+
1056+ # verify the main page with the contacts that have sent messages is
1057+ # visible
1058+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1059+
1060+ # verify a message in the thread list
1061+ self.assertThat(self.thread_list.count, Equals(1))
1062+ # verify our phone type and number
1063+ self.thread_list.select_single('Label', text='Aa')
1064+ self.thread_list.select_single('Label', text='Mobile')
1065+ # verify our text
1066+ self.thread_list.select_single('Label', text=message)
1067+
1068+ def test_more_than_one_message_to_contact_with_more_than_one_number(self):
1069+ """Send more than one message to a contact with more than one number"""
1070+ self.main_view.click_new_message_button()
1071+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1072+
1073+ self.message_page.type_contact_phone_num('1')
1074+ self.message_page.type_message('message1')
1075+
1076+ self.message_page.click_send_button()
1077+
1078+ self.assertThat(self.main_view.get_header().title,
1079+ Eventually(Equals('Aa')))
1080+
1081+ # switch back to main page with thread list
1082+ self.main_view.close_osk()
1083+ self.main_view.go_back()
1084+
1085+ # verify the main page with the contacts that have sent messages is
1086+ # visible
1087+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1088+
1089+ # verify a message in the thread list
1090+ self.assertThat(self.thread_list.count, Equals(1))
1091+ # verify our number
1092+ self.thread_list.select_single('Label', text='Aa')
1093+ self.thread_list.select_single('Label', text='message1')
1094+
1095+ # make second message
1096+ self.main_view.click_new_message_button()
1097+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1098+
1099+ self.message_page.type_contact_phone_num('9')
1100+ self.message_page.type_message('message9')
1101+
1102+ self.message_page.click_send_button()
1103+
1104+ self.assertThat(self.main_view.get_header().title,
1105+ Eventually(Equals('Aa')))
1106+
1107+ # switch back to main page with thread list
1108+ self.main_view.close_osk()
1109+ self.main_view.go_back()
1110+
1111+ # verify the main page with the contacts that have sent messages is
1112+ # visible
1113+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1114+
1115+ # verify a message in the thread list
1116+ self.assertThat(self.thread_list.count, Equals(2))
1117+ # verify our number
1118+ self.thread_list.select_many('Label', text='Aa')
1119+ self.thread_list.select_single('Label', text='message1')
1120+ self.thread_list.select_single('Label', text='message9')

Subscribers

People subscribed via source and target branches