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

Proposed by Chris Gagnon
Status: Superseded
Proposed branch: lp:~chris.gagnon/messaging-app/autopilot-tests-with-contacts
Merge into: lp:messaging-app
Diff against target: 1568 lines (+1182/-222)
7 files modified
debian/control (+3/-0)
tests/autopilot/messaging_app/__init__.py (+2/-2)
tests/autopilot/messaging_app/data/contacts.sync (+99/-0)
tests/autopilot/messaging_app/emulators.py (+395/-9)
tests/autopilot/messaging_app/tests/__init__.py (+46/-14)
tests/autopilot/messaging_app/tests/test_messaging.py (+637/-148)
tests/autopilot/messaging_app/tests/test_ui.py (+0/-49)
To merge this branch: bzr merge lp:~chris.gagnon/messaging-app/autopilot-tests-with-contacts
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+206552@code.launchpad.net

This proposal has been superseded by a proposal from 2014-02-14.

To post a comment you must log in.
78. By Chris Gagnon

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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

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
Tiago Salem Herrmann (tiagosh) wrote :

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

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-14 19:29:11 +0000
4@@ -42,6 +42,9 @@
5 python-autopilot,
6 ubuntu-ui-toolkit-autopilot,
7 ofono-phonesim-autostart,
8+ evolution-data-service,
9+ address-boot-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=== modified file 'tests/autopilot/messaging_app/__init__.py'
16--- tests/autopilot/messaging_app/__init__.py 2013-07-15 20:33:33 +0000
17+++ tests/autopilot/messaging_app/__init__.py 2014-02-14 19:29:11 +0000
18@@ -1,5 +1,5 @@
19 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
20-# Copyright 2012 Canonical
21+# Copyright 2012 - 2014 Canonical
22 #
23 # This file is part of messaging-app.
24 #
25@@ -7,4 +7,4 @@
26 # under the terms of the GNU General Public License version 3, as published
27 # by the Free Software Foundation.
28
29-"""Marumbi autopilot tests and emulators - top level package."""
30+"""messaging-app autopilot tests and emulators - top level package."""
31
32=== added directory 'tests/autopilot/messaging_app/data'
33=== added file 'tests/autopilot/messaging_app/data/contacts.sync'
34--- tests/autopilot/messaging_app/data/contacts.sync 1970-01-01 00:00:00 +0000
35+++ tests/autopilot/messaging_app/data/contacts.sync 2014-02-14 19:29:11 +0000
36@@ -0,0 +1,99 @@
37+BEGIN:VCARD
38+VERSION:3.0
39+UID:pas-id-52FD502C000000BE
40+N:;Aa;;;
41+X-EVOLUTION-FILE-AS:Aa
42+ADR;TYPE=home:;;;;;;
43+REV:2014-02-13T23:08:07Z(390)
44+FN:Aa
45+TEL;TYPE=mobile,home:1
46+TEL;TYPE=work,landline:9
47+END:VCARD
48+
49+BEGIN:VCARD
50+VERSION:3.0
51+UID:pas-id-52FD502D000000BF
52+N:;Aaa;;;
53+X-EVOLUTION-FILE-AS:Aaa
54+TEL;TYPE=mobile,home:11
55+ADR;TYPE=home:;;;;;;
56+REV:2014-02-12T01:56:20Z(92)
57+FN:Aaa
58+END:VCARD
59+
60+BEGIN:VCARD
61+VERSION:3.0
62+UID:pas-id-52FD502D000000C0
63+N:;Aaaa;;;
64+X-EVOLUTION-FILE-AS:Aaaa
65+TEL;TYPE=mobile,home:111
66+ADR;TYPE=home:;;;;;;
67+REV:2014-02-12T01:56:32Z(94)
68+FN:Aaaa
69+END:VCARD
70+
71+BEGIN:VCARD
72+VERSION:3.0
73+UID:pas-id-52FD502D000000C1
74+N:;Bbbb;;;
75+X-EVOLUTION-FILE-AS:Bbbb
76+TEL;TYPE=mobile,home:222
77+ADR;TYPE=home:;;;;;;
78+REV:2014-02-12T01:56:49Z(96)
79+FN:Bbbb
80+END:VCARD
81+
82+BEGIN:VCARD
83+VERSION:3.0
84+UID:pas-id-52FD502D000000C2
85+N:;Bb;;;
86+X-EVOLUTION-FILE-AS:Bb
87+TEL;TYPE=mobile,home:2
88+ADR;TYPE=home:;;;;;;
89+REV:2014-02-12T01:56:59Z(98)
90+FN:Bb
91+END:VCARD
92+
93+BEGIN:VCARD
94+VERSION:3.0
95+UID:pas-id-52FD502E000000C3
96+N:;Bbb;;;
97+X-EVOLUTION-FILE-AS:Bbb
98+ADR;TYPE=home:;;;;;;
99+FN:Bbb
100+TEL;TYPE=mobile,home:22
101+REV:2014-02-12T01:57:18Z(102)
102+END:VCARD
103+
104+BEGIN:VCARD
105+VERSION:3.0
106+UID:pas-id-52FD502E000000C4
107+N:;Cccc;;;
108+X-EVOLUTION-FILE-AS:Cccc
109+TEL;TYPE=mobile,home:333
110+ADR;TYPE=home:;;;;;;
111+REV:2014-02-12T14:22:48Z(104)
112+FN:Cccc
113+END:VCARD
114+
115+BEGIN:VCARD
116+VERSION:3.0
117+UID:pas-id-52FD502E000000C5
118+N:;Cc;;;
119+X-EVOLUTION-FILE-AS:Cc
120+TEL;TYPE=mobile,home:3
121+ADR;TYPE=home:;;;;;;
122+REV:2014-02-12T14:23:02Z(106)
123+FN:Cc
124+END:VCARD
125+
126+BEGIN:VCARD
127+VERSION:3.0
128+UID:pas-id-52FD502E000000C6
129+N:;Ccc;;;
130+X-EVOLUTION-FILE-AS:Ccc
131+TEL;TYPE=mobile,home:33
132+ADR;TYPE=home:;;;;;;
133+REV:2014-02-12T14:23:18Z(108)
134+FN:Ccc
135+END:VCARD
136\ No newline at end of file
137
138=== modified file 'tests/autopilot/messaging_app/emulators.py'
139--- tests/autopilot/messaging_app/emulators.py 2013-09-25 20:24:30 +0000
140+++ tests/autopilot/messaging_app/emulators.py 2014-02-14 19:29:11 +0000
141@@ -10,30 +10,416 @@
142
143 """Messaging app autopilot emulators."""
144
145+import dbus
146+import logging
147+import os
148+import shutil
149+import subprocess
150+import tempfile
151+import time
152+
153+from autopilot.input import Keyboard
154+from autopilot.platform import model
155 from ubuntuuitoolkit import emulators as toolkit_emulators
156
157+
158+class EmulatorException(Exception):
159+ """Exception raised when there is an error with the emulator."""
160+
161+
162 class MainView(toolkit_emulators.MainView):
163 def __init__(self, *args):
164 super(MainView, self).__init__(*args)
165+ self.pointing_device = toolkit_emulators.get_pointing_device()
166+ self.keyboard = Keyboard.create()
167+ self.logger = logging.getLogger(__name__)
168
169 def get_pagestack(self):
170+ """Returns PageStack with objectName mainStack"""
171 return self.select_single("PageStack", objectName="mainStack")
172
173+ def click_new_message_button(self):
174+ """Click "Compose/ new message" button from toolbar on main page"""
175+
176+ toolbar = self.open_toolbar()
177+ toolbar.click_button("newMessageButton")
178+ toolbar.animating.wait_for(False)
179+
180+ def click_select_button(self):
181+ """Click select button from toolbar on main page"""
182+
183+ toolbar = self.open_toolbar()
184+ toolbar.click_button("selectButton")
185+ toolbar.animating.wait_for(False)
186+
187+ def get_thread_from_number(self, phone_number):
188+ """Returns thread from number
189+
190+ :parameter phone_number: the phone_number of message thread
191+
192+ """
193+
194+ time.sleep(2) # message is not always found on slow emulator
195+ for thread in self.select_many('ThreadDelegate'):
196+ for item in self.select_many('QQuickItem'):
197+ if "phoneNumber" in item.get_properties():
198+ if item.get_properties()['phoneNumber'] == phone_number:
199+ return thread
200+ raise EmulatorException('Could not find thread with the phone number '
201+ '{}'.format(phone_number))
202+
203+ def get_label(self, text):
204+ """Returns label from text
205+
206+ :parameter text: the text of the label to return
207+ """
208+
209+ return self.wait_select_single('Label', visible=True, text=text)
210+
211+ def get_main_page(self):
212+ """Returns messages with objectName messagesPage"""
213+
214+ return self.wait_select_single("MainPage", objectName="")
215+
216+ def get_header(self):
217+ """Returns header object"""
218+
219+ return self.select_single('Header', objectName='MainView_Header')
220+
221+ def get_dialog_buttons(self, visible=True):
222+ """Returns DialogButtons
223+
224+ :parameter visible: the visible state of the dialog button
225+ """
226+
227+ if visible:
228+ return self.wait_select_single('DialogButtons', visible=True)
229+ else:
230+ return self.select_many('DialogButtons', visible=False)
231+
232+ def get_visible_cancel_dialog_button(self):
233+ """Returns dialog Button with text Cancel"""
234+
235+ dialog_buttons = self.get_dialog_buttons()
236+ return dialog_buttons.select_single('Button', text='Cancel')
237+
238+ def get_visible_delete_dialog_button(self):
239+ """Returns dialog Button with text Delete"""
240+
241+ dialog_buttons = self.get_dialog_buttons()
242+ return dialog_buttons.select_single('Button', text='Delete')
243+
244+ def click_cancel_dialog_button(self):
245+ """Returns button, after clicking on dialog button cancel"""
246+
247+ button = self.get_visible_cancel_dialog_button()
248+ self.pointing_device.click_object(button)
249+ button.visible.wait_for(False)
250+ return button
251+
252+ def click_delete_dialog_button(self):
253+ """Returns button after clicking on dialog button delete"""
254+
255+ button = self.get_visible_delete_dialog_button()
256+ self.pointing_device.click_object(button)
257+ button.visible.wait_for(False)
258+ return button
259+
260+ def long_press(self, obj):
261+ """long press on object because press_duration is not honored on touch
262+ see bug #1268782
263+
264+ :parameter obj: the object to long press on
265+ """
266+
267+ self.pointing_device.move_to_object(obj)
268+ self.pointing_device.press()
269+ time.sleep(3)
270+ self.pointing_device.release()
271+
272+ def close_osk(self):
273+ """Swipe down to close on-screen keyboard"""
274+
275+ # killing the maliit-server closes the OSK
276+ if model() is not 'Desktop':
277+ subprocess.call(["pkill", "maliit-server"])
278+ #wait for server to respawn
279+ time.sleep(2)
280+
281+ def click_visible_label(self, text):
282+ """Returns and clicks visible label with matching text
283+
284+ :parameter text: the text of the label you want to click
285+ """
286+
287+ label = self.get_label(text)
288+ self.pointing_device.click_object(label)
289+ return label
290+
291+ def click_close_contact_button(self):
292+ """Returns and clicks the close contact button"""
293+
294+ button = self.select_single('Button', text='close', visible=True)
295+ self.pointing_device.click_object(button)
296+ return button
297+
298+ def get_contact_list_view(self):
299+ """Returns the contact list view"""
300+
301+ return self.select_single('ContactListView', text='')
302+
303+ def delete_thread(self, phone_number, direction='right'):
304+ """Delete thread containing specified phone number
305+
306+ :parameter phone_number: phone number of thread to delete
307+ :parameter direction: right or left, the direction to swipe to delete
308+ """
309+
310+ thread = self.get_thread_from_number(phone_number)
311+ delete = self.swipe_to_delete(thread, direction=direction)
312+ delete_button = delete.wait_select_single('QQuickImage', visible=True)
313+ self.pointing_device.click_object(delete_button)
314+ thread.wait_until_destroyed()
315+
316+ def click_select_messages_button(self):
317+ """Click select messages button from toolbar on messages page"""
318+
319+ toolbar = self.open_toolbar()
320+ toolbar.click_button("selectMessagesButton")
321+ toolbar.animating.wait_for(False)
322+
323+ def click_add_button(self):
324+ """Returns and click add button from toolbar on messages page"""
325+
326+ toolbar = self.open_toolbar()
327+ button = toolbar.wait_select_single("ActionItem", text=u"Add")
328+ self.pointing_device.click_object(button)
329+ toolbar.animating.wait_for(False)
330+ return button
331+
332+ def click_call_button(self):
333+ """Returns and click call button from toolbar on messages page"""
334+
335+ toolbar = self.open_toolbar()
336+ button = toolbar.wait_select_single("ActionItem", text=u"Call")
337+ self.pointing_device.click_object(button)
338+ toolbar.animating.wait_for(False)
339+ return button
340+
341+ def click_back_button(self):
342+ """Returns and click back button from toolbar on messages page"""
343+
344+ toolbar = self.open_toolbar()
345+ button = toolbar.wait_select_single("ActionItem", text=u"Back")
346+ self.pointing_device.click_object(button)
347+ toolbar.animating.wait_for(False)
348+ return button
349+
350+ def delete_message(self, text, direction='right'):
351+ """Deletes message with specified text
352+
353+ :parameter text: the text of the message you want to delete
354+ :parameter direction: right or left, the direction to swipe to delete
355+ """
356+
357+ message = self.get_message(text)
358+ delete = self.swipe_to_delete(message, direction=direction)
359+ delete_button = delete.wait_select_single('QQuickImage', visible=True)
360+ self.pointing_device.click_object(delete_button)
361+ message.wait_until_destroyed()
362+
363 def get_messages_page(self):
364- return self.select_single("Messages", objectName="messagesPage")
365+ """Returns messages with objectName messagesPage"""
366+
367+ return self.wait_select_single("Messages", objectName="messagesPage")
368+
369+ def swipe_to_delete(self, obj, direction='right', offset=.1):
370+ """Swipe and objet left or right
371+
372+ :parameter direction: right or left, the direction to swipe
373+ :parameter offset: the ammount of space to offset at start of swipe
374+ """
375+
376+ x, y, w, h = obj.globalRect
377+
378+ s_rx = x + (w * offset)
379+ e_rx = w
380+
381+ s_lx = w - (w * offset)
382+ e_lx = w * offset
383+
384+ sy = y + (h / 2)
385+
386+ if (direction == 'right'):
387+ self.pointing_device.drag(s_rx, sy, e_rx, sy)
388+ # wait for animation
389+ time.sleep(.5)
390+ return self.wait_select_single('QQuickItem',
391+ objectName='confirmRemovalDialog',
392+ visible=True)
393+ elif (direction == 'left'):
394+ self.pointing_device.drag(s_lx, sy, e_lx, sy)
395+ # wait for animation
396+ time.sleep(.5)
397+ return self.wait_select_single('QQuickItem',
398+ objectName='confirmRemovalDialog',
399+ visible=True)
400+ else:
401+ raise EmulatorException(
402+ 'Invalid direction "{0}" used on swipe to delete function '
403+ 'direction can be right or left'.format(direction)
404+ )
405+
406+ def receive_sms(self, sender, text):
407+ """Receive an SMS based on sender number and text
408+
409+ :parameter sender: phone number the message is from
410+ :parameter text: text you want to send in the message
411+ """
412+
413+ # prepare and send a Qt GUI script to phonesim, over its private D-BUS
414+ # set up by ofono-phonesim-autostart
415+ script_dir = tempfile.mkdtemp(prefix="phonesim_script")
416+ os.chmod(script_dir, 0o755)
417+ with open(os.path.join(script_dir, "sms.js"), "w") as f:
418+ f.write("""tabSMS.gbMessage1.leMessageSender.text = "%s";
419+tabSMS.gbMessage1.leSMSClass.text = "1";
420+tabSMS.gbMessage1.teSMSText.setPlainText("%s");
421+tabSMS.gbMessage1.pbSendSMSMessage.click();
422+""" % (sender, text))
423+
424+ with open("/run/lock/ofono-phonesim-dbus.address") as f:
425+ phonesim_bus = f.read().strip()
426+ bus = dbus.bus.BusConnection(phonesim_bus)
427+ script_proxy = bus.get_object("org.ofono.phonesim", "/")
428+ script_proxy.SetPath(script_dir)
429+ script_proxy.Run("sms.js")
430+ shutil.rmtree(script_dir)
431+
432+
433+class Messages(MainView):
434+ def __init__(self, *args):
435+ super(Messages, self).__init__(*args)
436+
437+ def get_message(self, text):
438+ """Returns message from text
439+
440+ :parameter text: the text or date of the label in the message
441+
442+ """
443+
444+ time.sleep(2) # message is not always found on slow emulator
445+ for message in self.select_many('MessageDelegate'):
446+ for item in self.select_many('Label'):
447+ if "text" in item.get_properties():
448+ if item.get_properties()['text'] == text:
449+ return message
450+ raise EmulatorException('Could not find message with the text '
451+ '{}'.format(text))
452
453 def get_newmessage_textfield(self):
454- return self.select_single("TextField", objectName="newPhoneNumberField")
455+ """Returns TextField with objectName newPhoneNumberField"""
456+
457+ return self.select_single(
458+ "TextField",
459+ objectName="newPhoneNumberField",
460+ )
461+
462+ def get_multiple_selection_list_view(self):
463+ """Returns MultipleSelectionListView from the messages page"""
464+
465+ return self.select_single('MultipleSelectionListView')
466
467 def get_newmessage_textarea(self):
468- return self.select_single("TextArea", objectName="")
469+ """Returns TextArea with blank objectName"""
470+
471+ return self.select_single('TextArea', objectName='')
472
473 def get_send_button(self):
474+ """Returns Button with text Send"""
475+
476 return self.select_single('Button', text='Send')
477
478- def get_thread_from_number(self, number):
479- for item in self.select_many("QQuickItem"):
480- if "phoneNumber" in item.get_properties():
481- if item.get_properties()['phoneNumber'] == number:
482- return item
483- return None
484+ def get_toolbar_back_button(self):
485+ """Returns toolbar button with objectName back_toolbar_button"""
486+
487+ return self.select_single(
488+ 'ActionItem',
489+ objectName='back_toolbar_button',
490+ )
491+
492+ def get_toolbar_select_messages_button(self):
493+ """Returns toolbar button with objectName selectMessagesButton"""
494+
495+ return self.select_single(
496+ 'ActionItem',
497+ objectName='selectMessagesButton',
498+ )
499+
500+ def get_toolbar_add_contact_button(self):
501+ """Returns toolbar button with objectName addContactButton"""
502+
503+ return self.select_single(
504+ 'ActionItem',
505+ objectName='addContactButton',
506+ )
507+
508+ def get_toolbar_contact_profile_button(self):
509+ """Returns toolbar button with objectName contactProfileButton"""
510+
511+ return self.select_single(
512+ 'ActionItem',
513+ objectName='contactProfileButton',
514+ )
515+
516+ def get_toolbar_contact_call_button(self):
517+ """Returns toolbar button with objectName contactCallButton"""
518+
519+ return self.select_single(
520+ 'ActionItem',
521+ objectName='contactCallButton',
522+ )
523+
524+ def type_message(self, message):
525+ """Select and type message in new message text area in messages page
526+
527+ :parameter message: the message to type
528+ """
529+
530+ text_entry = self.get_newmessage_textarea()
531+ self.pointing_device.click_object(text_entry)
532+ text_entry.focus.wait_for(True)
533+ time.sleep(.3)
534+ self.keyboard.type(str(message), delay=0.2)
535+ self.logger.info(
536+ 'typed: "{}" expected: "{}"'.format(text_entry.text, message))
537+
538+ def type_contact_phone_num(self, num_or_contact):
539+ """Select and type phone number or contact
540+
541+ :parameter num_or_contact: number or contact to type
542+ """
543+
544+ text_entry = self.get_newmessage_textfield()
545+ self.pointing_device.click_object(text_entry)
546+ text_entry.focus.wait_for(True)
547+ time.sleep(.3)
548+ self.keyboard.type(str(num_or_contact), delay=0.2)
549+ self.logger.info(
550+ 'typed "{}" expected "{}"'.format(text_entry.text, num_or_contact))
551+
552+ def click_send_button(self):
553+ """Returns and click the send button on the message page"""
554+
555+ button = self.get_send_button()
556+ button.enabled.wait_for(True)
557+ self.pointing_device.click_object(button)
558+ button.enabled.wait_for(False)
559+ return button
560+
561+ def click_add_new_contact_button(self):
562+ """Returns and clicks the add contact button on the message page"""
563+
564+ icon = self.select_single("Icon", name="new-contact")
565+ self.pointing_device.click_object(icon)
566+ return icon
567
568=== modified file 'tests/autopilot/messaging_app/tests/__init__.py'
569--- tests/autopilot/messaging_app/tests/__init__.py 2013-10-17 11:14:18 +0000
570+++ tests/autopilot/messaging_app/tests/__init__.py 2014-02-14 19:29:11 +0000
571@@ -1,5 +1,5 @@
572 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
573-# Copyright 2012 Canonical
574+# Copyright 2012-2014 Canonical
575 #
576 # This file is part of messaging-app.
577 #
578@@ -13,19 +13,23 @@
579 from autopilot.matchers import Eventually
580 from autopilot.platform import model
581 from autopilot.testcase import AutopilotTestCase
582-from testtools.matchers import Equals, GreaterThan
583-
584+from testtools.matchers import Equals
585+
586+from address_book_app.helpers import (backup_evolution_contacts_db,
587+ restore_evolution_contacts_db,
588+ wipe_evolution_contacts_db)
589+
590+from messaging_app import emulators
591 from ubuntuuitoolkit import emulators as toolkit_emulators
592-from messaging_app import emulators
593
594 import os
595 import sys
596-from time import sleep
597 import logging
598 import subprocess
599
600 logger = logging.getLogger(__name__)
601
602+
603 # ensure we have an ofono account; we assume that we have these tools,
604 # otherwise we consider this a test failure (missing dependencies)
605 def tp_has_ofono():
606@@ -47,6 +51,10 @@
607
608 """
609
610+ #Don't use keyboard on desktop
611+ if model() == 'Desktop':
612+ subprocess.call(['/sbin/initctl', 'stop', 'maliit-server'])
613+
614 if model() == 'Desktop':
615 scenarios = [
616 ('with mouse', dict(input_device_class=Mouse)),
617@@ -56,12 +64,24 @@
618 ('with touch', dict(input_device_class=Touch)),
619 ]
620
621- local_location = "../../src/messaging-app"
622+ local_location = '../../src/messaging-app'
623
624 def setUp(self):
625 self.pointing_device = Pointer(self.input_device_class.create())
626 super(MessagingAppTestCase, self).setUp()
627
628+ subprocess.call(['pkill', 'messaging-app'])
629+
630+ # backup and add contacts
631+ current_dir = os.path.abspath(os.path.dirname(__file__))
632+ self.test_contacts_db = os.path.abspath(
633+ current_dir + "../../data/contacts.sync"
634+ )
635+
636+ self.tmp_contacts_backup = backup_evolution_contacts_db()
637+ wipe_evolution_contacts_db()
638+ restore_evolution_contacts_db(self.test_contacts_db)
639+
640 if os.path.exists(self.local_location):
641 self.launch_test_local()
642 else:
643@@ -69,27 +89,39 @@
644
645 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
646
647+ def tearDown(self):
648+ super(MessagingAppTestCase, self).tearDown()
649+ # restore contacts
650+ wipe_evolution_contacts_db()
651+ restore_evolution_contacts_db(self.tmp_contacts_backup)
652+ os.remove(self.tmp_contacts_backup)
653+
654 def launch_test_local(self):
655 self.app = self.launch_test_application(
656 self.local_location,
657- "--test-contacts",
658+ '--test-contacts',
659 app_type='qt',
660 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
661
662 def launch_test_installed(self):
663 if model() == 'Desktop':
664 self.app = self.launch_test_application(
665- "messaging-app",
666- "--test-contacts",
667+ 'messaging-app',
668+ '--test-contacts',
669 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
670 else:
671 self.app = self.launch_test_application(
672- "messaging-app",
673- "--test-contacts",
674- "--desktop_file_hint=/usr/share/applications/messaging-app.desktop",
675- app_type='qt',
676- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
677+ 'messaging-app',
678+ '--test-contacts',
679+ '--desktop_file_hint='
680+ '/usr/share/applications/messaging-app.desktop',
681+ app_type='qt',
682+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
683
684 @property
685 def main_view(self):
686 return self.app.select_single(emulators.MainView)
687+
688+ @property
689+ def message_page(self):
690+ return self.app.select_single(emulators.Messages)
691
692=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
693--- tests/autopilot/messaging_app/tests/test_messaging.py 2013-12-12 00:25:27 +0000
694+++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-02-14 19:29:11 +0000
695@@ -11,49 +11,46 @@
696
697 from __future__ import absolute_import
698
699+import os
700 import subprocess
701-import os
702-import tempfile
703-import shutil
704 import time
705
706-import dbus
707-
708+from autopilot.introspection import dbus
709 from autopilot.matchers import Eventually
710 from testtools.matchers import Equals
711-from testtools import skipIf, skipUnless
712
713 from messaging_app.tests import MessagingAppTestCase
714
715-# determine whether we are running with phonesim
716-try:
717- out = subprocess.check_output(["/usr/share/ofono/scripts/list-modems"],
718- stderr=subprocess.PIPE)
719- have_phonesim = out.startswith("[ /phonesim ]")
720-except subprocess.CalledProcessError:
721- have_phonesim = False
722-
723-
724-@skipUnless(have_phonesim,
725- "this test needs to run under with-ofono-phonesim")
726-@skipIf(os.uname()[2].endswith("maguro"),
727- "tests cause Unity crashes on maguro")
728+
729 class TestMessaging(MessagingAppTestCase):
730 """Tests for the communication panel."""
731
732 def setUp(self):
733+
734+ # determine whether we are running with phonesim
735+ try:
736+ out = subprocess.check_output(
737+ ['/usr/share/ofono/scripts/list-modems'],
738+ stderr=subprocess.PIPE
739+ )
740+ have_phonesim = out.startswith('[ /phonesim ]')
741+ except subprocess.CalledProcessError:
742+ have_phonesim = False
743+
744+ self.assertTrue(have_phonesim)
745+
746 # provide clean history
747 self.history = os.path.expanduser(
748- "~/.local/share/history-service/history.sqlite")
749+ '~/.local/share/history-service/history.sqlite')
750 if os.path.exists(self.history):
751- os.rename(self.history, self.history + ".orig")
752- subprocess.call(["pkill", "history-daemon"])
753- subprocess.call(["pkill", "-f", "telephony-service-handler"])
754+ os.rename(self.history, self.history + '.orig')
755+ subprocess.call(['pkill', 'history-daemon'])
756+ subprocess.call(['pkill', '-f', 'telephony-service-handler'])
757
758 super(TestMessaging, self).setUp()
759
760 # no initial messages
761- self.thread_list = self.app.select_single(objectName="threadList")
762+ self.thread_list = self.app.select_single(objectName='threadList')
763 self.assertThat(self.thread_list.visible, Equals(True))
764 self.assertThat(self.thread_list.count, Equals(0))
765
766@@ -65,132 +62,624 @@
767 os.unlink(self.history)
768 except OSError:
769 pass
770- if os.path.exists(self.history + ".orig"):
771- os.rename(self.history + ".orig", self.history)
772- subprocess.call(["pkill", "history-daemon"])
773- subprocess.call(["pkill", "-f", "telephony-service-handler"])
774+ if os.path.exists(self.history + '.orig'):
775+ os.rename(self.history + '.orig', self.history)
776+ subprocess.call(['pkill', 'history-daemon'])
777+ subprocess.call(['pkill', '-f', 'telephony-service-handler'])
778
779 # on desktop, notify-osd may generate persistent popups (like for "SMS
780 # received"), don't make that stay around for the tests
781- subprocess.call(["pkill", "-f", "notify-osd"])
782+ subprocess.call(['pkill', '-f', 'notify-osd'])
783+
784+ def test_receive_message(self):
785+ """Verify that we can receive a text message"""
786+ # receive an sms message
787+ self.main_view.receive_sms('0815', 'hello to Ubuntu')
788+
789+ # verify that we got the message
790+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
791+
792+ # verify number
793+ self.thread_list.select_single('Label', text='0815')
794+ time.sleep(1) # make it visible to human users for a sec
795+ # verify text
796+ self.thread_list.select_single('Label', text='hello to Ubuntu')
797
798 def test_write_new_message(self):
799- self.click_new_message_button()
800-
801- # type address number
802- text_entry = self.main_view.get_newmessage_textfield()
803- text_entry.activeFocus.wait_for(True)
804- self.keyboard.type("123")
805- self.assertThat(text_entry.text, Eventually(Equals("123")))
806-
807- # type message
808- text_entry = self.main_view.get_newmessage_textarea()
809- self.pointing_device.click_object(text_entry)
810- # need to click twice, first time to hide the toolbar (LP#1207369)
811- self.pointing_device.click_object(text_entry)
812- text_entry.activeFocus.wait_for(True)
813- message = "hello from Ubuntu"
814- self.keyboard.type(message)
815- self.assertThat(text_entry.text, Eventually(Equals(message)))
816-
817- # send
818- button = self.main_view.get_send_button()
819- self.assertThat(button.enabled, Eventually(Equals(True)))
820- self.pointing_device.click_object(button)
821- self.assertThat(button.enabled, Eventually(Equals(False)))
822-
823- # verify that we get a bubble with our message
824- messages_page = self.main_view.select_single(objectName="messagesPage")
825- list_view = messages_page.select_single("MultipleSelectionListView")
826- self.assertThat(list_view.count, Eventually(Equals(1)))
827- l = list_view.select_single("Label", text="hello from Ubuntu")
828- self.assertNotEqual(l, None)
829-
830- # switch back to main page with thread list
831- self.close_osk()
832-
833- # TODO: this is a workaround to force the keyboard to close, as close_osk()
834- # doesn't seem to work on mako
835- self.pointing_device.click_object(button)
836- self.go_back()
837- self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
838-
839- # should show our message in the thread list
840- self.assertThat(self.thread_list.count, Equals(1))
841- # should show address number
842- l = self.thread_list.select_single("Label", text="123")
843- self.assertNotEqual(l, None)
844- # should show text
845- l = self.thread_list.select_single("Label", text="hello from Ubuntu")
846- self.assertNotEqual(l, None)
847-
848- def test_receive_message(self):
849- self.receive_sms("0815", "hello to Ubuntu")
850-
851- self.assertThat(self.thread_list.count, Eventually(Equals(1)))
852- l = self.thread_list.select_single("Label", text="0815")
853- self.assertNotEqual(l, None)
854- time.sleep(1) # make it visible to human users for a sec
855- # should show text
856- l = self.thread_list.select_single("Label", text="hello to Ubuntu")
857- self.assertNotEqual(l, None)
858-
859- #
860- # Helper methods
861- #
862-
863- def click_new_message_button(self):
864- """Click "New message" menu button and wait for "New message" page"""
865-
866- self.main_view.open_toolbar()
867- toolbar = self.main_view.get_toolbar()
868- toolbar.click_button("newMessageButton")
869- self.assertThat(self.main_view.get_pagestack().depth,
870- Eventually(Equals(2)))
871- self.assertThat(self.main_view.get_messages_page().visible,
872- Eventually(Equals(True)))
873- self.assertThat(self.thread_list.visible, Equals(False))
874-
875- def close_osk(self):
876- """Swipe down to close on-screen keyboard"""
877-
878- # TODO: hack! this belongs into the Ubuntu UI toolkit emulator,
879- # LP#1239753
880- x1, y1, x2, y2 = self.main_view.globalRect
881- mid_x = (x2 - x1) // 2
882- mid_y = (y2 - y1) * 7 // 10
883- self.pointing_device.drag(mid_x, mid_y, mid_x, y2)
884- time.sleep(1)
885-
886- def go_back(self):
887- """Click back button from toolbar"""
888-
889- # will fail with i18n; this belongs into the Ubuntu UI toolkit
890- # emulator, LP#1239751
891- self.main_view.open_toolbar()
892- toolbar = self.main_view.get_toolbar()
893- back_button = toolbar.select_single("ActionItem", text=u"Back")
894- self.assertNotEqual(back_button, None)
895- self.pointing_device.click_object(back_button)
896-
897- def receive_sms(self, sender, text):
898- """Receive an SMS"""
899-
900- # prepare and send a Qt GUI script to phonesim, over its private D-BUS
901- # set up by ofono-phonesim-autostart
902- script_dir = tempfile.mkdtemp(prefix="phonesim_script")
903- os.chmod(script_dir, 0o755)
904- self.addCleanup(shutil.rmtree, script_dir)
905- with open(os.path.join(script_dir, "sms.js"), "w") as f:
906- f.write("""tabSMS.gbMessage1.leMessageSender.text = "%s";
907-tabSMS.gbMessage1.leSMSClass.text = "1";
908-tabSMS.gbMessage1.teSMSText.setPlainText("%s");
909-tabSMS.gbMessage1.pbSendSMSMessage.click();
910-""" % (sender, text))
911-
912- with open("/run/lock/ofono-phonesim-dbus.address") as f:
913- phonesim_bus = f.read().strip()
914- bus = dbus.bus.BusConnection(phonesim_bus)
915- script_proxy = bus.get_object("org.ofono.phonesim", "/")
916- script_proxy.SetPath(script_dir)
917- script_proxy.Run("sms.js")
918+ """Verify we can write and send a new text message"""
919+ self.main_view.click_new_message_button()
920+ #verify the thread list page is not visible
921+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
922+
923+ # type contact/number
924+ phone_num = 123
925+ self.message_page.type_contact_phone_num(phone_num)
926+
927+ # type message
928+ message = 'hello from Ubuntu'
929+ self.message_page.type_message(message)
930+
931+ # send
932+ self.message_page.click_send_button()
933+
934+ # verify that we get a bubble with our message
935+ list_view = self.message_page.get_multiple_selection_list_view()
936+ self.assertThat(list_view.count, Eventually(Equals(1)))
937+ # verify label text
938+ self.message_page.get_message('hello from Ubuntu')
939+
940+ # switch back to main page with thread list
941+ self.main_view.close_osk()
942+ self.main_view.go_back()
943+
944+ # verify the main page with the contacts that have sent messages is
945+ # visible
946+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
947+
948+ # verify a message in the thread list
949+ self.assertThat(self.thread_list.count, Equals(1))
950+ # verify our number
951+ self.thread_list.select_single('Label', text='123')
952+ # verify our text
953+ self.thread_list.select_single('Label', text='hello from Ubuntu')
954+
955+ def test_deleting_message_long_press(self):
956+ """Verify we can delete a message with a long press on the message"""
957+ self.main_view.click_new_message_button()
958+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
959+
960+ # type address number
961+ phone_num = '555-555-4321'
962+ self.message_page.type_contact_phone_num(phone_num)
963+ # type message
964+ message = 'delete me'
965+ self.message_page.type_message(message)
966+
967+ # send
968+ self.message_page.click_send_button()
969+
970+ # verify that we get a bubble with our message
971+ list_view = self.message_page.get_multiple_selection_list_view()
972+ self.assertThat(list_view.count, Eventually(Equals(1)))
973+ bubble = self.message_page.get_message(message)
974+
975+ self.main_view.close_osk()
976+
977+ # long press on bubble
978+ self.main_view.long_press(bubble)
979+
980+ # select delete button
981+ self.main_view.click_delete_dialog_button()
982+
983+ # verify message is deleted
984+ bubble.wait_until_destroyed()
985+
986+ def test_cancel_deleting_message_long_press(self):
987+ """Verify we can cancel deleting a message with a long press"""
988+ self.main_view.click_new_message_button()
989+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
990+
991+ # type address number
992+ phone_num = '5555551234'
993+ self.message_page.type_contact_phone_num(phone_num)
994+
995+ # type message
996+ message = 'do not delete'
997+ self.message_page.type_message(message)
998+
999+ # send
1000+ self.message_page.click_send_button()
1001+
1002+ # verify that we get a bubble with our message
1003+ list_view = self.message_page.get_multiple_selection_list_view()
1004+ self.assertThat(list_view.count, Eventually(Equals(1)))
1005+ bubble = self.message_page.get_message(message)
1006+
1007+ self.main_view.close_osk()
1008+
1009+ # long press on bubble and verify cancel button does not delete message
1010+ self.main_view.long_press(bubble)
1011+ self.main_view.click_cancel_dialog_button()
1012+ time.sleep(5) # on a slow machine it might return a false positive
1013+ #the bubble must exist
1014+ bubble = self.message_page.get_message(message)
1015+
1016+ def test_open_received_message(self):
1017+ """Verify we can open a txt message we have received"""
1018+ number = '5555555678'
1019+ message = 'open me'
1020+ # receive message
1021+ self.main_view.receive_sms(number, message)
1022+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1023+ # click message thread
1024+ mess_thread = self.thread_list.wait_select_single('Label', text=number)
1025+ self.pointing_device.click_object(mess_thread)
1026+ self.message_page.get_message(message)
1027+ # send new message
1028+ self.message_page.type_message('{} 2'.format(message))
1029+ self.message_page.click_send_button()
1030+ # verify both messages are seen in list
1031+ self.message_page.get_message('{} 2'.format(message))
1032+ self.message_page.get_message(message)
1033+
1034+ def test_delete_multiple_messages(self):
1035+ """Verify we can delete multiple messages"""
1036+ number = '5555559876'
1037+ message = 'delete me'
1038+ # send 5 messages
1039+ for num in range(1, 6):
1040+ self.main_view.receive_sms(number, '{} {}'.format(message, num))
1041+ time.sleep(1)
1042+ # verify messages show up in thread
1043+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1044+
1045+ mess_thread = self.thread_list.wait_select_single('Label', text=number)
1046+ self.pointing_device.click_object(mess_thread)
1047+
1048+ # long press on message 5
1049+ bubble5 = self.main_view.get_label('delete me 5')
1050+ self.main_view.long_press(bubble5)
1051+
1052+ # tap message 2 - 4
1053+ for num in range(2, 5):
1054+ bubble = self.main_view.get_label(
1055+ '{} {}'.format(message, num)
1056+ )
1057+ self.pointing_device.click_object(bubble)
1058+
1059+ # delete messages 2 - 5
1060+ self.main_view.click_delete_dialog_button()
1061+
1062+ #verify message 2 - 5 are destroyed
1063+ for num in range(2, 6):
1064+ try:
1065+ bubble = self.main_view.get_label(
1066+ '{} {}'.format(message, num)
1067+ )
1068+ bubble.wait_until_destroyed()
1069+ ## if the message is not there it was already destroyed
1070+ except dbus.StateNotFoundError:
1071+ pass
1072+ #verify message bubble 1 exists
1073+ self.main_view.get_label('delete me 1')
1074+
1075+ def test_toolbar_delete_message(self):
1076+ """Verify we can use the toolbar to delete a message"""
1077+ self.main_view.click_new_message_button()
1078+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1079+
1080+ # type address number
1081+ phone_num = '555-555-4321'
1082+ self.message_page.type_contact_phone_num(phone_num)
1083+ # type message
1084+ message = 'delete me'
1085+ self.message_page.type_message(message)
1086+
1087+ # send
1088+ self.message_page.click_send_button()
1089+
1090+ # verify that we get a bubble with our message
1091+ list_view = self.message_page.get_multiple_selection_list_view()
1092+ self.assertThat(list_view.count, Eventually(Equals(1)))
1093+ bubble = self.message_page.get_message(message)
1094+
1095+ self.main_view.close_osk()
1096+
1097+ # press on select button and message then delete
1098+ self.main_view.click_select_messages_button()
1099+ self.pointing_device.click_object(bubble)
1100+ self.main_view.click_delete_dialog_button()
1101+ #verify messsage is gone
1102+ bubble.wait_until_destroyed()
1103+
1104+ def test_toolbar_delete_message_without_selecting_a_message(self):
1105+ """Verify we only delete messages that have been selected"""
1106+ self.main_view.click_new_message_button()
1107+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1108+
1109+ # type address number
1110+ phone_num = '555-555-4321'
1111+ self.message_page.type_contact_phone_num(phone_num)
1112+ # type message
1113+ message = 'dont delete me'
1114+ self.message_page.type_message(message)
1115+
1116+ # send
1117+ self.message_page.click_send_button()
1118+
1119+ # verify that we get a bubble with our message
1120+ list_view = self.message_page.get_multiple_selection_list_view()
1121+ self.assertThat(list_view.count, Eventually(Equals(1)))
1122+ self.message_page.get_message(message)
1123+
1124+ self.main_view.close_osk()
1125+
1126+ # press on select button then delete
1127+ self.main_view.click_select_messages_button()
1128+ self.main_view.click_delete_dialog_button()
1129+
1130+ #verify messsage is not gone
1131+ time.sleep(5) # wait 5 seconds, the emulator is slow
1132+ list_view.select_single("Label", text=message)
1133+
1134+ def test_receive_text_with_letters_in_phone_number(self):
1135+ """verify we can receive a text message with letters for a phone #"""
1136+ number = 'letters'
1137+ message = 'open me'
1138+ # receive message
1139+ self.main_view.receive_sms(number, message)
1140+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1141+ # click message thread
1142+ mess_thread = self.thread_list.wait_select_single(
1143+ 'Label',
1144+ text='letters@' # phonesim sends text with number as letters@
1145+ )
1146+ self.pointing_device.click_object(mess_thread)
1147+ self.message_page.get_message(message)
1148+ # send new message
1149+ self.message_page.type_message('{} 2'.format(message))
1150+ self.message_page.click_send_button()
1151+ # verify both messages are seen in list
1152+ self.message_page.get_message('{} 2'.format(message))
1153+ self.message_page.get_message(message)
1154+
1155+ def test_cancel_delete_thread_from_main_view(self):
1156+ """Verify we can cancel deleting a message thread"""
1157+ self.main_view.click_new_message_button()
1158+ #verify the thread list page is not visible
1159+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1160+
1161+ # type contact/number
1162+ phone_num = 123
1163+ self.message_page.type_contact_phone_num(phone_num)
1164+
1165+ # type message
1166+ message = 'hello from Ubuntu'
1167+ self.message_page.type_message(message)
1168+
1169+ # send
1170+ self.message_page.click_send_button()
1171+
1172+ # verify that we get a bubble with our message
1173+ list_view = self.message_page.get_multiple_selection_list_view()
1174+ self.assertThat(list_view.count, Eventually(Equals(1)))
1175+ # verify label text
1176+ self.message_page.get_message('hello from Ubuntu')
1177+
1178+ # switch back to main page with thread list
1179+ self.main_view.close_osk()
1180+ self.main_view.go_back()
1181+
1182+ # verify the main page with the contacts that have sent messages is
1183+ # visible
1184+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1185+
1186+ # verify a message in the thread list
1187+ self.assertThat(self.thread_list.count, Equals(1))
1188+ # verify our number
1189+ self.thread_list.select_single('Label', text='123')
1190+ # verify our text
1191+ self.thread_list.select_single('Label', text='hello from Ubuntu')
1192+ # use select button in toolbar
1193+ self.main_view.click_select_button()
1194+ # click cancel button
1195+ self.main_view.click_cancel_dialog_button()
1196+ # wait for slow emulator
1197+ time.sleep(5)
1198+ # verify our number was not deleted
1199+ self.thread_list.select_single('Label', text='123')
1200+ # verify our text was not deleted
1201+ self.thread_list.select_single('Label', text='hello from Ubuntu')
1202+
1203+ def test_delete_thread_from_main_view(self):
1204+ """Verify we can delete a message thread"""
1205+ self.main_view.click_new_message_button()
1206+ #verify the thread list page is not visible
1207+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1208+
1209+ # type contact/number
1210+ phone_num = 123
1211+ self.message_page.type_contact_phone_num(phone_num)
1212+
1213+ # type message
1214+ message = 'hello from Ubuntu'
1215+ self.message_page.type_message(message)
1216+
1217+ # send
1218+ self.message_page.click_send_button()
1219+
1220+ # verify that we get a bubble with our message
1221+ list_view = self.message_page.get_multiple_selection_list_view()
1222+ self.assertThat(list_view.count, Eventually(Equals(1)))
1223+ # verify label text
1224+ self.message_page.get_message('hello from Ubuntu')
1225+
1226+ # switch back to main page with thread list
1227+ self.main_view.close_osk()
1228+ self.main_view.go_back()
1229+
1230+ # verify the main page with the contacts that have sent messages is
1231+ # visible
1232+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1233+
1234+ # verify a message in the thread list
1235+ self.assertThat(self.thread_list.count, Equals(1))
1236+ # verify our number
1237+ mess_thread = self.thread_list.select_single('Label', text='123')
1238+ # verify our text
1239+ self.thread_list.select_single('Label', text='hello from Ubuntu')
1240+ # use select button in toolbar
1241+ self.main_view.click_select_button()
1242+ # click thread we want to delete
1243+ self.pointing_device.click_object(mess_thread)
1244+ # click cancel button
1245+ self.main_view.click_delete_dialog_button()
1246+ # verify our text was deleted
1247+ mess_thread.wait_until_destroyed()
1248+
1249+ def test_delete_message_thread_swipe_right(self):
1250+ """Verify we can delete a message thread by swiping right"""
1251+ # receive an sms message
1252+ self.main_view.receive_sms('0815', 'hello to Ubuntu')
1253+
1254+ # verify that we got the message
1255+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1256+
1257+ # delete thread by swiping
1258+ self.main_view.delete_thread('0815')
1259+ self.assertThat(self.thread_list.count, Eventually(Equals(0)))
1260+
1261+ def test_delete_message_swipe_right(self):
1262+ """Verify we can delete a message by swiping right"""
1263+ self.main_view.click_new_message_button()
1264+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1265+
1266+ # type address number
1267+ phone_num = '555-555-4321'
1268+ self.message_page.type_contact_phone_num(phone_num)
1269+ # type message
1270+ message = 'delete me okay'
1271+ self.message_page.type_message(message)
1272+
1273+ # send
1274+ self.message_page.click_send_button()
1275+
1276+ # verify that we get a bubble with our message
1277+ list_view = self.message_page.get_multiple_selection_list_view()
1278+ self.assertThat(list_view.count, Eventually(Equals(1)))
1279+ self.message_page.get_message(message)
1280+
1281+ #delete message
1282+ self.message_page.delete_message(message)
1283+ self.assertThat(list_view.count, Eventually(Equals(0)))
1284+
1285+ def test_delete_message_thread_swipe_left(self):
1286+ """Verify we can delete a message thread by swiping left"""
1287+ # receive an sms message
1288+ self.main_view.receive_sms('0815', 'hello to Ubuntu')
1289+
1290+ # verify that we got the message
1291+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1292+
1293+ # delete thread by swiping
1294+ self.main_view.delete_thread('0815', direction='left')
1295+ self.assertThat(self.thread_list.count, Eventually(Equals(0)))
1296+
1297+ def test_delete_message_swipe_left(self):
1298+ """Verify we can delete a message by swiping left"""
1299+ self.main_view.click_new_message_button()
1300+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1301+
1302+ # type address number
1303+ phone_num = '555-555-4321'
1304+ self.message_page.type_contact_phone_num(phone_num)
1305+ # type message
1306+ message = 'delete me okay'
1307+ self.message_page.type_message(message)
1308+
1309+ # send
1310+ self.message_page.click_send_button()
1311+
1312+ # verify that we get a bubble with our message
1313+ list_view = self.message_page.get_multiple_selection_list_view()
1314+ self.assertThat(list_view.count, Eventually(Equals(1)))
1315+ self.message_page.get_message(message)
1316+
1317+ #delete message
1318+ self.message_page.delete_message(message, direction='left')
1319+ self.assertThat(list_view.count, Eventually(Equals(0)))
1320+
1321+ def test_receive_long_message(self):
1322+ """Verify that we dont crash after receiving a realy long text message
1323+ """
1324+ # receive an sms message
1325+ message = str('loong' * 4000)
1326+ self.main_view.receive_sms('0815', message)
1327+
1328+ # verify that we got the message
1329+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1330+
1331+ # verify number
1332+ self.thread_list.select_single('Label', text='0815')
1333+ time.sleep(1) # make it visible to human users for a sec
1334+ # verify text
1335+ self.thread_list.select_single('Label', text=message)
1336+
1337+ def test_receiving_text_to_existing_contact(self):
1338+ """Verify contact name is used when receiving message from existing
1339+ contact
1340+ """
1341+ # receive an sms message
1342+ message = 'message from Bb'
1343+ self.main_view.receive_sms('2', message)
1344+
1345+ # verify that we got the message
1346+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
1347+
1348+ # verify number
1349+ self.thread_list.select_single('Label', text="Bb")
1350+ time.sleep(1) # make it visible to human users for a sec
1351+ # verify text
1352+ self.thread_list.select_single('Label', text=message)
1353+
1354+ def test_send_message_using_new_contacts_button(self):
1355+ """Verify new contacts name lets you send a message to existing contact
1356+ """
1357+ self.main_view.click_new_message_button()
1358+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1359+
1360+ # type address number
1361+ phone_num = '111'
1362+ contact_name = 'Aaaa'
1363+
1364+ # use new contacts to select contact
1365+ self.message_page.click_add_new_contact_button()
1366+
1367+ contact_label = self.main_view.click_visible_label(contact_name)
1368+ self.main_view.click_visible_label(phone_num)
1369+
1370+ contact_label.wait_until_destroyed()
1371+
1372+ # type message
1373+ message = 'test message'
1374+ self.message_page.type_message(message)
1375+
1376+ # send
1377+ self.message_page.click_send_button()
1378+
1379+ # verify that we get a bubble with our message
1380+ list_view = self.message_page.get_multiple_selection_list_view()
1381+ self.assertThat(list_view.count, Eventually(Equals(1)))
1382+ self.message_page.get_message(message)
1383+
1384+ # verify the header has the selected contact name
1385+ self.assertThat(self.main_view.get_header().title,
1386+ Eventually(Equals(contact_name)))
1387+
1388+ def test_receive_text_from_contact_with_more_than_one_phone_number(self):
1389+ """Verify that a text can be received from a contact with more than one
1390+ phone number
1391+ """
1392+ message1 = '1 from Aa'
1393+ message2 = '2 from Aa'
1394+
1395+ # send messages
1396+ self.main_view.receive_sms('1', message1)
1397+ time.sleep(1) # The last message needs to be displayed as the thread
1398+ self.main_view.receive_sms('9', message2)
1399+
1400+ # we should have 2 threads
1401+ self.assertThat(self.thread_list.count, Eventually(Equals(2)))
1402+
1403+ # verify contact name and both numbers are displayed
1404+ self.thread_list.select_many('Label', text='Aa')
1405+ time.sleep(2) # make it human readable
1406+ self.thread_list.select_single('Label', text='Work')
1407+ self.thread_list.select_single('Label', text='Mobile')
1408+ # verify text
1409+ self.thread_list.select_single('Label', text=message2)
1410+ self.thread_list.select_single('Label', text=message1)
1411+
1412+ def test_contact_predictive_text(self):
1413+ """test predictive text when selecting contact"""
1414+ self.main_view.click_new_message_button()
1415+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1416+
1417+ # select contact via predictive text
1418+ self.message_page.type_contact_phone_num('a')
1419+ self.main_view.click_visible_label('Aaa')
1420+
1421+ self.assertThat(self.main_view.get_header().title,
1422+ Eventually(Equals('Aaa')))
1423+
1424+ def test_send_text_to_contact_with_more_than_one_number(self):
1425+ """Send a text to a contact with more than one number"""
1426+ message = 'Aa get this'
1427+
1428+ self.main_view.click_new_message_button()
1429+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1430+
1431+ self.message_page.type_contact_phone_num('1')
1432+
1433+ self.message_page.type_message(message)
1434+
1435+ self.message_page.click_send_button()
1436+
1437+ # verify that we get a bubble with our message
1438+ list_view = self.message_page.get_multiple_selection_list_view()
1439+ self.assertThat(list_view.count, Eventually(Equals(1)))
1440+ # verify label text
1441+ self.message_page.get_message(message)
1442+
1443+ self.assertThat(self.main_view.get_header().title,
1444+ Eventually(Equals('Aa')))
1445+
1446+ # switch back to main page with thread list
1447+ self.main_view.close_osk()
1448+ self.main_view.go_back()
1449+
1450+ # verify the main page with the contacts that have sent messages is
1451+ # visible
1452+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1453+
1454+ # verify a message in the thread list
1455+ self.assertThat(self.thread_list.count, Equals(1))
1456+ # verify our phone type and number
1457+ self.thread_list.select_single('Label', text='Aa')
1458+ self.thread_list.select_single('Label', text='Mobile')
1459+ # verify our text
1460+ self.thread_list.select_single('Label', text=message)
1461+
1462+ def test_more_than_one_message_to_contact_with_more_than_one_number(self):
1463+ """Send more than one message to a contact with more than one number"""
1464+ self.main_view.click_new_message_button()
1465+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1466+
1467+ self.message_page.type_contact_phone_num('1')
1468+ self.message_page.type_message('message1')
1469+
1470+ self.message_page.click_send_button()
1471+
1472+ self.assertThat(self.main_view.get_header().title,
1473+ Eventually(Equals('Aa')))
1474+
1475+ # switch back to main page with thread list
1476+ self.main_view.close_osk()
1477+ self.main_view.go_back()
1478+
1479+ # verify the main page with the contacts that have sent messages is
1480+ # visible
1481+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1482+
1483+ # verify a message in the thread list
1484+ self.assertThat(self.thread_list.count, Equals(1))
1485+ # verify our number
1486+ self.thread_list.select_single('Label', text='Aa')
1487+ self.thread_list.select_single('Label', text='message1')
1488+
1489+ # make second message
1490+ self.main_view.click_new_message_button()
1491+ self.assertThat(self.thread_list.visible, Eventually(Equals(False)))
1492+
1493+ self.message_page.type_contact_phone_num('9')
1494+ self.message_page.type_message('message9')
1495+
1496+ self.message_page.click_send_button()
1497+
1498+ self.assertThat(self.main_view.get_header().title,
1499+ Eventually(Equals('Aa')))
1500+
1501+ # switch back to main page with thread list
1502+ self.main_view.close_osk()
1503+ self.main_view.go_back()
1504+
1505+ # verify the main page with the contacts that have sent messages is
1506+ # visible
1507+ self.assertThat(self.thread_list.visible, Eventually(Equals(True)))
1508+
1509+ # verify a message in the thread list
1510+ self.assertThat(self.thread_list.count, Equals(2))
1511+ # verify our number
1512+ self.thread_list.select_many('Label', text='Aa')
1513+ self.thread_list.select_single('Label', text='message1')
1514+ self.thread_list.select_single('Label', text='message9')
1515
1516=== removed file 'tests/autopilot/messaging_app/tests/test_ui.py'
1517--- tests/autopilot/messaging_app/tests/test_ui.py 2013-11-04 13:13:15 +0000
1518+++ tests/autopilot/messaging_app/tests/test_ui.py 1970-01-01 00:00:00 +0000
1519@@ -1,49 +0,0 @@
1520-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1521-# Copyright 2013 Canonical
1522-#
1523-# This file is part of messaging-app.
1524-#
1525-# messaging-app is free software: you can redistribute it and/or modify it
1526-# under the terms of the GNU General Public License version 3, as published
1527-# by the Free Software Foundation.
1528-
1529-"""Pure UI tests for Messaging App"""
1530-
1531-from __future__ import absolute_import
1532-
1533-from autopilot.matchers import Eventually
1534-from testtools.matchers import Equals
1535-
1536-from messaging_app.tests import MessagingAppTestCase
1537-
1538-
1539-class TestUI(MessagingAppTestCase):
1540- def test_new_message_panel(self):
1541- """New message panel comes up with the toolbar button"""
1542-
1543- # Click "New message" menu button
1544- self.main_view.open_toolbar()
1545- toolbar = self.main_view.get_toolbar()
1546- toolbar.click_button("newMessageButton")
1547-
1548- # wait for "New message" page
1549- self.assertThat(self.main_view.get_pagestack().depth,
1550- Eventually(Equals(2)))
1551- self.assertThat(self.main_view.get_messages_page().visible,
1552- Eventually(Equals(True)))
1553-
1554- # type address number
1555- text_entry = self.main_view.get_newmessage_textfield()
1556- text_entry.activeFocus.wait_for(True)
1557- self.keyboard.type("123")
1558- self.assertThat(text_entry.text, Eventually(Equals("123")))
1559-
1560- # type message
1561- text_entry = self.main_view.get_newmessage_textarea()
1562- self.pointing_device.click_object(text_entry)
1563- # need to click twice, first time to hide the toolbar (LP#1207369)
1564- self.pointing_device.click_object(text_entry)
1565- text_entry.activeFocus.wait_for(True)
1566- message = "hello from Ubuntu"
1567- self.keyboard.type(message)
1568- self.assertThat(text_entry.text, Eventually(Equals(message)))

Subscribers

People subscribed via source and target branches