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

Gustavo Pichorim Boiko gustavo.boiko at canonical.com
Tue Jul 15 01:16:29 UTC 2014


Review: Needs Fixing

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

Diff comments:

> === 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-11 11:49:26 +0000
> @@ -184,6 +184,10 @@
>          dialog_buttons = self.get_dialog_buttons()
>          return dialog_buttons.select_single('Button', text='Delete')
>  
> +    def get_add_phone_number_to_contact_page(self):
> +        """ Return page with list of contacts """
> +        return self.wait_select_single('AddPhoneNumberToContactPage')
> +
>      def click_cancel_dialog_button(self):
>          """Click on dialog button cancel"""
>  
> 
> === 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-11 11:49:26 +0000
> @@ -104,3 +104,17 @@
>          ], stdout=subprocess.PIPE, universal_newlines=True)
>      mc_accounts = mc_tool.communicate()[0]
>      return 'ofono/ofono/account' in mc_accounts
> +
> +def get_pid_by_name(proc_name):
> +    for i in range(10):
> +        try:
> +            return int(
> +                subprocess.check_output(['pidof', proc_name]).strip())
> +        except subprocess.CalledProcessError:
> +            # application not started yet, check in a second
> +            time.sleep(1)
> +    else:
> +        raise RuntimeError(
> +            'Could not find autopilot interface for {} after 10'
> +            'seconds'.format(proc_name)
> +        )
> 
> === 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-11 11:49:26 +0000
> @@ -15,6 +15,7 @@
>  import subprocess
>  import time
>  
> +from autopilot.introspection import get_proxy_object_for_existing_process
>  from autopilot.matchers import Eventually
>  from testtools.matchers import Equals, HasLength
>  from testtools import skipIf, skip
> @@ -22,7 +23,8 @@
>  from messaging_app import emulators
>  from messaging_app import helpers
>  from messaging_app.tests import MessagingAppTestCase
> -
> +from ubuntuuitoolkit import emulators as toolkit_emulators
> +from ubuntuuitoolkit import fixture_setup
>  
>  @skipIf(os.uname()[2].endswith('maguro'),
>          'tests cause Unity crashes on maguro')
> @@ -452,6 +454,50 @@
>          self.main_view.delete_message(message)
>          self.assertThat(list_view.count, Eventually(Equals(0)))
>  
> +    def test_add_phone_number_to_existing_contact(self):
> +        """
> +        Verify that if we click on the add number to contact from message
> +        button, then the add to existing contact button, that we get a
> +        list of contacts to choose from.
> +        """
> +        # receive an sms message to add the number from
> +        helpers.receive_sms('0815', 'hello to Ubuntu')
> +        # verify that we got the message
> +        self.assertThat(self.thread_list.count, Eventually(Equals(1)))
> +        main = self.main_view.get_main_page()
> +        main.open_thread('0815')
> +        # work around the notification getting in the way
> +        time.sleep(5)
> +        self.main_view.click_add_button()
> +        self.main_view.click_add_to_contact_button()
> +        add_to_contact = self.main_view.get_add_phone_number_to_contact_page()
> +        self.assertThat(add_to_contact.visible, Eventually(Equals(True)))
> +
> +    def test_add_phone_number_to_new_contact(self):

This test only works on the device. Please change it so that it gets disabled on desktop.

> +        """
> +        Verify that if we click on the add number to contact from message
> +        button, then the add to new contact button, that we get a call out
> +        to the address book application.
> +        """
> +        # receive an sms message to add the number from
> +        helpers.receive_sms('0815', 'hello to Ubuntu')
> +        # verify that we got the message
> +        self.assertThat(self.thread_list.count, Eventually(Equals(1)))
> +        main = self.main_view.get_main_page()
> +        main.open_thread('0815')
> +        # work around the notification getting in the way
> +        time.sleep(5)
> +        self.main_view.click_add_button()
> +        # Enable load testability before clicking the button
> +        # and launching the address book application
> +        self.useFixture(fixture_setup.InitctlEnvironmentVariable(
> +            QT_LOAD_TESTABILITY=1))
> +        self.main_view.click_create_new_contact_button()
> +        address_book = get_proxy_object_for_existing_process(
> +            pid=helpers.get_pid_by_name('address-book-app'))
> +        self.assertNotEqual(address_book, None)
> +        os.system('ubuntu-app-stop address-book-app')
> +
>  
>  class MessagingTestCaseWithExistingThread(BaseMessagingTestCase):
>  
> 


-- 
https://code.launchpad.net/~brendan-donegan/messaging-app/new_helpers_tests/+merge/226439
Your team Ubuntu Phablet Team is subscribed to branch lp:messaging-app.



More information about the Ubuntu-reviews mailing list