Merge lp:~canonical-platform-qa/messaging-app/new_helpers_tests into lp:messaging-app

Proposed by Brendan Donegan on 2014-07-15
Status: Work in progress
Proposed branch: lp:~canonical-platform-qa/messaging-app/new_helpers_tests
Merge into: lp:messaging-app
Diff against target: 110 lines (+67/-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 (+49/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/messaging-app/new_helpers_tests
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration 2014-07-15 Needs Fixing on 2014-07-15
Leo Arias (community) 2014-07-15 Needs Fixing on 2014-07-15
Gustavo Pichorim Boiko 2014-07-15 Pending
Review via email: mp+226825@code.launchpad.net

This proposal supersedes a proposal from 2014-07-11.

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.
Leo Arias (elopio) wrote : Posted in a previous version of this proposal

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)
Gustavo Pichorim Boiko (boiko) wrote : Posted in a previous version of this proposal

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

review: Needs Fixing
Leo Arias (elopio) wrote :

78 + self.main_view.click_add_button()
79 + self.main_view.click_add_to_contact_button()
80 + add_to_contact = self.main_view.get_add_phone_number_to_contact_page()

Please wrap this in a higher level helper called add_phone_number_to_existing_contact.

98 + self.main_view.click_add_button()
103 + self.main_view.click_create_new_contact_button()

And this into one called something like go_to_create_new_contact.

104 + address_book = get_proxy_object_for_existing_process(
105 + pid=helpers.get_pid_by_name('address-book-app'))

Please remove the dependency on address-book-app by copying the fake url dispatcher, or by waiting for url-dispatcher-testability to land.

review: Needs Fixing

Unmerged revisions

141. By Brendan Donegan on 2014-07-15

Add skipIf to test_add_phone_number_to_new_contact as the test is not supported on the desktop

140. By Brendan Donegan on 2014-07-11

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

139. By Brendan Donegan on 2014-07-11

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

138. By Brendan Donegan on 2014-07-11

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-15 13:29:36 +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-15 13:29:36 +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-15 13:29:36 +0000
41@@ -15,14 +15,17 @@
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 autopilot.platform import model
49 from testtools import skipIf, skip
50
51 from messaging_app import emulators
52 from messaging_app import helpers
53 from messaging_app.tests import MessagingAppTestCase
54-
55+from ubuntuuitoolkit import emulators as toolkit_emulators
56+from ubuntuuitoolkit import fixture_setup
57
58 @skipIf(os.uname()[2].endswith('maguro'),
59 'tests cause Unity crashes on maguro')
60@@ -452,6 +455,51 @@
61 self.main_view.delete_message(message)
62 self.assertThat(list_view.count, Eventually(Equals(0)))
63
64+ def test_add_phone_number_to_existing_contact(self):
65+ """
66+ Verify that if we click on the add number to contact from message
67+ button, then the add to existing contact button, that we get a
68+ list of contacts to choose from.
69+ """
70+ # receive an sms message to add the number from
71+ helpers.receive_sms('0815', 'hello to Ubuntu')
72+ # verify that we got the message
73+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
74+ main = self.main_view.get_main_page()
75+ main.open_thread('0815')
76+ # work around the notification getting in the way
77+ time.sleep(5)
78+ self.main_view.click_add_button()
79+ self.main_view.click_add_to_contact_button()
80+ add_to_contact = self.main_view.get_add_phone_number_to_contact_page()
81+ self.assertThat(add_to_contact.visible, Eventually(Equals(True)))
82+
83+ @skipIf(model() == 'Desktop', 'Not valid on the desktop')
84+ def test_add_phone_number_to_new_contact(self):
85+ """
86+ Verify that if we click on the add number to contact from message
87+ button, then the add to new contact button, that we get a call out
88+ to the address book application.
89+ """
90+ # receive an sms message to add the number from
91+ helpers.receive_sms('0815', 'hello to Ubuntu')
92+ # verify that we got the message
93+ self.assertThat(self.thread_list.count, Eventually(Equals(1)))
94+ main = self.main_view.get_main_page()
95+ main.open_thread('0815')
96+ # work around the notification getting in the way
97+ time.sleep(5)
98+ self.main_view.click_add_button()
99+ # Enable load testability before clicking the button
100+ # and launching the address book application
101+ self.useFixture(fixture_setup.InitctlEnvironmentVariable(
102+ QT_LOAD_TESTABILITY=1))
103+ self.main_view.click_create_new_contact_button()
104+ address_book = get_proxy_object_for_existing_process(
105+ pid=helpers.get_pid_by_name('address-book-app'))
106+ self.assertNotEqual(address_book, None)
107+ os.system('ubuntu-app-stop address-book-app')
108+
109
110 class MessagingTestCaseWithExistingThread(BaseMessagingTestCase):
111

Subscribers

People subscribed via source and target branches