Merge lp:~brendan-donegan/messaging-app/new_helpers_tests into lp:messaging-app

Proposed by Brendan Donegan
Status: Superseded
Proposed branch: lp:~brendan-donegan/messaging-app/new_helpers_tests
Merge into: lp:messaging-app
Diff against target: 108 lines (+65/-1)
3 files modified
tests/autopilot/messaging_app/emulators.py (+4/-0)
tests/autopilot/messaging_app/helpers.py (+14/-0)
tests/autopilot/messaging_app/tests/test_messaging.py (+47/-1)
To merge this branch: bzr merge lp:~brendan-donegan/messaging-app/new_helpers_tests
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Leo Arias (community) code review Needs Fixing
Review via email: mp+226439@code.launchpad.net

This proposal has been superseded by a proposal from 2014-07-15.

Commit message

Add some tests for helpers for the 'Add number to contact' dialog

Description of the change

This branch contains some new tests which exercise the helpers that I created to aid in the automation of the 'Add number to contact from message' user experience. To some extent they replicate the intent of that test, but do not actually concern themselves with the integration of the messaging-app and address-book-app - they just check that address-book-app does the right thing in the case of each function.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

102 + address_book = get_proxy_object_for_existing_process(
103 + pid=helpers.get_pid_by_name('address-book-app'))
104 + self.assertNotEqual(address_book, None)

we shouldn't add address book as a dependency to those tests.
what we should do is to check that url-dispatcher has received the right message.

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

The test_add_phone_number_to_new_contact needs to be disabled on desktop as it only works on the device.

review: Needs Fixing

Unmerged revisions

140. By Brendan Donegan

Make sure that address-book-app is launched when we try to add a number to a new contact

139. By Brendan Donegan

Remove proxy for AddPhoneNumberToContactPage because it isn't ready to be tested.

138. By Brendan Donegan

Add tests for toolbar button helpers

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/messaging_app/emulators.py'
2--- tests/autopilot/messaging_app/emulators.py 2014-07-08 08:35:32 +0000
3+++ tests/autopilot/messaging_app/emulators.py 2014-07-11 11:49:26 +0000
4@@ -184,6 +184,10 @@
5 dialog_buttons = self.get_dialog_buttons()
6 return dialog_buttons.select_single('Button', text='Delete')
7
8+ def get_add_phone_number_to_contact_page(self):
9+ """ Return page with list of contacts """
10+ return self.wait_select_single('AddPhoneNumberToContactPage')
11+
12 def click_cancel_dialog_button(self):
13 """Click on dialog button cancel"""
14
15
16=== modified file 'tests/autopilot/messaging_app/helpers.py'
17--- tests/autopilot/messaging_app/helpers.py 2014-07-08 23:12:48 +0000
18+++ tests/autopilot/messaging_app/helpers.py 2014-07-11 11:49:26 +0000
19@@ -104,3 +104,17 @@
20 ], stdout=subprocess.PIPE, universal_newlines=True)
21 mc_accounts = mc_tool.communicate()[0]
22 return 'ofono/ofono/account' in mc_accounts
23+
24+def get_pid_by_name(proc_name):
25+ for i in range(10):
26+ try:
27+ return int(
28+ subprocess.check_output(['pidof', proc_name]).strip())
29+ except subprocess.CalledProcessError:
30+ # application not started yet, check in a second
31+ time.sleep(1)
32+ else:
33+ raise RuntimeError(
34+ 'Could not find autopilot interface for {} after 10'
35+ 'seconds'.format(proc_name)
36+ )
37
38=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
39--- tests/autopilot/messaging_app/tests/test_messaging.py 2014-06-30 08:42:16 +0000
40+++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-07-11 11:49:26 +0000
41@@ -15,6 +15,7 @@
42 import subprocess
43 import time
44
45+from autopilot.introspection import get_proxy_object_for_existing_process
46 from autopilot.matchers import Eventually
47 from testtools.matchers import Equals, HasLength
48 from testtools import skipIf, skip
49@@ -22,7 +23,8 @@
50 from messaging_app import emulators
51 from messaging_app import helpers
52 from messaging_app.tests import MessagingAppTestCase
53-
54+from ubuntuuitoolkit import emulators as toolkit_emulators
55+from ubuntuuitoolkit import fixture_setup
56
57 @skipIf(os.uname()[2].endswith('maguro'),
58 'tests cause Unity crashes on maguro')
59@@ -452,6 +454,50 @@
60 self.main_view.delete_message(message)
61 self.assertThat(list_view.count, Eventually(Equals(0)))
62
63+ def test_add_phone_number_to_existing_contact(self):
64+ """
65+ Verify that if we click on the add number to contact from message
66+ button, then the add to existing contact button, that we get a
67+ list of contacts to choose from.
68+ """
69+ # receive an sms message to add the number from
70+ helpers.receive_sms('0815', 'hello to Ubuntu')
71+ # verify that we got the message
72+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
73+ main = self.main_view.get_main_page()
74+ main.open_thread('0815')
75+ # work around the notification getting in the way
76+ time.sleep(5)
77+ self.main_view.click_add_button()
78+ self.main_view.click_add_to_contact_button()
79+ add_to_contact = self.main_view.get_add_phone_number_to_contact_page()
80+ self.assertThat(add_to_contact.visible, Eventually(Equals(True)))
81+
82+ def test_add_phone_number_to_new_contact(self):
83+ """
84+ Verify that if we click on the add number to contact from message
85+ button, then the add to new contact button, that we get a call out
86+ to the address book application.
87+ """
88+ # receive an sms message to add the number from
89+ helpers.receive_sms('0815', 'hello to Ubuntu')
90+ # verify that we got the message
91+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
92+ main = self.main_view.get_main_page()
93+ main.open_thread('0815')
94+ # work around the notification getting in the way
95+ time.sleep(5)
96+ self.main_view.click_add_button()
97+ # Enable load testability before clicking the button
98+ # and launching the address book application
99+ self.useFixture(fixture_setup.InitctlEnvironmentVariable(
100+ QT_LOAD_TESTABILITY=1))
101+ self.main_view.click_create_new_contact_button()
102+ address_book = get_proxy_object_for_existing_process(
103+ pid=helpers.get_pid_by_name('address-book-app'))
104+ self.assertNotEqual(address_book, None)
105+ os.system('ubuntu-app-stop address-book-app')
106+
107
108 class MessagingTestCaseWithExistingThread(BaseMessagingTestCase):
109

Subscribers

People subscribed via source and target branches