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

Proposed by Brendan Donegan
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 Needs Fixing
Leo Arias (community) Needs Fixing
Gustavo Pichorim Boiko 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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
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)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
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
Revision history for this message
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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

141. By Brendan Donegan

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

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
=== modified file 'tests/autopilot/messaging_app/emulators.py'
--- tests/autopilot/messaging_app/emulators.py 2014-07-08 08:35:32 +0000
+++ tests/autopilot/messaging_app/emulators.py 2014-07-15 13:29:36 +0000
@@ -184,6 +184,10 @@
184 dialog_buttons = self.get_dialog_buttons()184 dialog_buttons = self.get_dialog_buttons()
185 return dialog_buttons.select_single('Button', text='Delete')185 return dialog_buttons.select_single('Button', text='Delete')
186186
187 def get_add_phone_number_to_contact_page(self):
188 """ Return page with list of contacts """
189 return self.wait_select_single('AddPhoneNumberToContactPage')
190
187 def click_cancel_dialog_button(self):191 def click_cancel_dialog_button(self):
188 """Click on dialog button cancel"""192 """Click on dialog button cancel"""
189193
190194
=== modified file 'tests/autopilot/messaging_app/helpers.py'
--- tests/autopilot/messaging_app/helpers.py 2014-07-08 23:12:48 +0000
+++ tests/autopilot/messaging_app/helpers.py 2014-07-15 13:29:36 +0000
@@ -104,3 +104,17 @@
104 ], stdout=subprocess.PIPE, universal_newlines=True)104 ], stdout=subprocess.PIPE, universal_newlines=True)
105 mc_accounts = mc_tool.communicate()[0]105 mc_accounts = mc_tool.communicate()[0]
106 return 'ofono/ofono/account' in mc_accounts106 return 'ofono/ofono/account' in mc_accounts
107
108def get_pid_by_name(proc_name):
109 for i in range(10):
110 try:
111 return int(
112 subprocess.check_output(['pidof', proc_name]).strip())
113 except subprocess.CalledProcessError:
114 # application not started yet, check in a second
115 time.sleep(1)
116 else:
117 raise RuntimeError(
118 'Could not find autopilot interface for {} after 10'
119 'seconds'.format(proc_name)
120 )
107121
=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
--- tests/autopilot/messaging_app/tests/test_messaging.py 2014-06-30 08:42:16 +0000
+++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-07-15 13:29:36 +0000
@@ -15,14 +15,17 @@
15import subprocess15import subprocess
16import time16import time
1717
18from autopilot.introspection import get_proxy_object_for_existing_process
18from autopilot.matchers import Eventually19from autopilot.matchers import Eventually
19from testtools.matchers import Equals, HasLength20from testtools.matchers import Equals, HasLength
21from autopilot.platform import model
20from testtools import skipIf, skip22from testtools import skipIf, skip
2123
22from messaging_app import emulators24from messaging_app import emulators
23from messaging_app import helpers25from messaging_app import helpers
24from messaging_app.tests import MessagingAppTestCase26from messaging_app.tests import MessagingAppTestCase
2527from ubuntuuitoolkit import emulators as toolkit_emulators
28from ubuntuuitoolkit import fixture_setup
2629
27@skipIf(os.uname()[2].endswith('maguro'),30@skipIf(os.uname()[2].endswith('maguro'),
28 'tests cause Unity crashes on maguro')31 'tests cause Unity crashes on maguro')
@@ -452,6 +455,51 @@
452 self.main_view.delete_message(message)455 self.main_view.delete_message(message)
453 self.assertThat(list_view.count, Eventually(Equals(0)))456 self.assertThat(list_view.count, Eventually(Equals(0)))
454457
458 def test_add_phone_number_to_existing_contact(self):
459 """
460 Verify that if we click on the add number to contact from message
461 button, then the add to existing contact button, that we get a
462 list of contacts to choose from.
463 """
464 # receive an sms message to add the number from
465 helpers.receive_sms('0815', 'hello to Ubuntu')
466 # verify that we got the message
467 self.assertThat(self.thread_list.count, Eventually(Equals(1)))
468 main = self.main_view.get_main_page()
469 main.open_thread('0815')
470 # work around the notification getting in the way
471 time.sleep(5)
472 self.main_view.click_add_button()
473 self.main_view.click_add_to_contact_button()
474 add_to_contact = self.main_view.get_add_phone_number_to_contact_page()
475 self.assertThat(add_to_contact.visible, Eventually(Equals(True)))
476
477 @skipIf(model() == 'Desktop', 'Not valid on the desktop')
478 def test_add_phone_number_to_new_contact(self):
479 """
480 Verify that if we click on the add number to contact from message
481 button, then the add to new contact button, that we get a call out
482 to the address book application.
483 """
484 # receive an sms message to add the number from
485 helpers.receive_sms('0815', 'hello to Ubuntu')
486 # verify that we got the message
487 self.assertThat(self.thread_list.count, Eventually(Equals(1)))
488 main = self.main_view.get_main_page()
489 main.open_thread('0815')
490 # work around the notification getting in the way
491 time.sleep(5)
492 self.main_view.click_add_button()
493 # Enable load testability before clicking the button
494 # and launching the address book application
495 self.useFixture(fixture_setup.InitctlEnvironmentVariable(
496 QT_LOAD_TESTABILITY=1))
497 self.main_view.click_create_new_contact_button()
498 address_book = get_proxy_object_for_existing_process(
499 pid=helpers.get_pid_by_name('address-book-app'))
500 self.assertNotEqual(address_book, None)
501 os.system('ubuntu-app-stop address-book-app')
502
455503
456class MessagingTestCaseWithExistingThread(BaseMessagingTestCase):504class MessagingTestCaseWithExistingThread(BaseMessagingTestCase):
457505

Subscribers

People subscribed via source and target branches