def test_add_contact_to_favorite(self):
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        contact_details = contacts_app.contact(self.contact['givenName'][0]).tap()
        contact_details.tap_add_favorite()
        self.assertEqual(contact_details.add_remove_text, 'Remove as Favorite')

        contacts_app = contact_details.tap_back()
        self.assertTrue(contacts_app.is_favorites_list_displayed)

        # Test that the contact is displayed twice: once under Favorites and once under Contacts.
        self.assertEqual(len(contacts_app.contacts), 2)
        self.assertEqual(contacts_app.contacts[0].full_name, contacts_app.contacts[1].full_name)

        contact_details = contacts_app.contact(self.contact['givenName'][0]).tap()
        contact_details.tap_remove_favorite()
        self.assertEqual(contact_details.add_remove_text, 'Add as Favorite')

        contacts_app = contact_details.tap_back()
        self.assertFalse(contacts_app.is_favorites_list_displayed)

        # Test that the contact is only displayed once now
        self.assertEqual(len(contacts_app.contacts), 1)
    def test_import_edit_export_contact(self):
        """
        https://moztrap.mozilla.org/manage/case/14115/
        """

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        sim_contacts_number_before_import = len(self.data_layer.sim_contacts)
        self.apps.switch_to_displayed_app()

        # import contacts from SIM
        contacts_settings = contacts_app.tap_settings()
        contacts_settings.tap_import_contacts()
        contacts_settings.tap_import_from_sim()
        contacts_settings.tap_back_from_import_contacts()
        contacts_settings.tap_done()

        contact_first_name = self.sim_contact['name'][0].split()[0]
        contact_details = contacts_app.contact(contact_first_name).tap()

        edit_contact = contact_details.tap_edit()

        contact_new_family_name = 'New'

        edit_contact.type_family_name(contact_new_family_name)

        contact_details = edit_contact.tap_update()

        contact_details.tap_back()

        contacts_settings = contacts_app.tap_settings()
        contacts_settings.tap_export_contacts()
        contacts_settings.tap_export_to_sim()

        contacts_app.contact(contact_first_name).tap(return_class='SelectContact')

        contacts_app.tap_export()

        self.assertIn('contacts exported', contacts_app.status_message)

        sim_contacts = self.data_layer.sim_contacts

        self.assertEqual(len(sim_contacts), sim_contacts_number_before_import)

        for contact in sim_contacts:
            if contact['tel'][0]['value'] == self.sim_contact['tel'][0]['value']:
                self.sim_contact = contact
                break

        self.assertEqual(self.sim_contact['name'][0], '%s %s' % (contact_first_name, contact_new_family_name))
        self.assertEqual(self.sim_contact['tel'][0]['value'], self.contact.tel['value'])
    def test_unlink_facebook_contact(self):
        """
        https://moztrap.mozilla.org/manage/case/5858/
        """

        username = self.testvars['facebook']['username']
        password = self.testvars['facebook']['password']
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        self.assertEqual(len(contacts_app.contacts), 1,
                         'Should insert one contact before running this test')

        # Go to contact item details
        contact_item = contacts_app.contact(self.contact['givenName'])
        contact_item_detail = contact_item.tap()

        facebook = contact_item_detail.tap_link_contact()
        contact_import_picker = facebook.login(username, password)
        contact_import_picker.tap_first_friend()

        contact_item_detail.tap_unlink_contact()
        contact_item_detail.tap_back()

        contacts_app.wait_for_contacts(2)
        self.assertEqual(
            len(contacts_app.contacts), 2,
            'After unlinking the facebook contact should have been added')
Example #4
0
    def test_sms_contact(self):
        """https://moztrap.mozilla.org/manage/case/1314/"""
        # Setup a text message from a contact.

        text_message_content = "Automated Test %s" % str(time.time())

        contacts = Contacts(self.marionette)
        contacts.launch()
        contacts.wait_for_contacts()

        # Tap on the created contact.
        contact_details = contacts.contact(self.contact['givenName']).tap()
        new_message = contact_details.tap_send_sms()
        new_message.wait_for_recipients_displayed()

        expected_name = self.contact['givenName'] + " " + self.contact[
            'familyName']
        expected_tel = self.contact['tel']['value']

        # Now check the first listed is from contacts app.
        # Name and phone number have been passed in correctly.
        self.assertEqual(new_message.first_recipient_name, expected_name)
        self.assertEqual(new_message.first_recipient_number_attribute,
                         expected_tel)

        new_message.type_message(text_message_content)
        message_thread = new_message.tap_send()

        message_thread.wait_for_received_messages()

        # Get the most recent received text message
        last_received_message = message_thread.received_messages[-1]

        # Check the most recent received message has the same text content
        self.assertEqual(text_message_content, last_received_message.text)
Example #5
0
    def test_sms_contact(self):
        """https://moztrap.mozilla.org/manage/case/1314/"""
        # Setup a text message from a contact.

        text_message_content = "Automated Test %s" % str(time.time())

        contacts = Contacts(self.marionette)
        contacts.launch()
        contacts.wait_for_contacts()

        # Tap on the created contact.
        contact_details = contacts.contact(self.contact['givenName']).tap()
        new_message = contact_details.tap_send_sms()
        new_message.wait_for_recipients_displayed()

        expected_name = self.contact['givenName'] + " " + self.contact['familyName']
        expected_tel = self.contact['tel']['value']

        # Now check the first listed is from contacts app.
        # Name and phone number have been passed in correctly.
        self.assertEqual(new_message.first_recipient_name, expected_name)
        self.assertEqual(new_message.first_recipient_number_attribute, expected_tel)

        new_message.type_message(text_message_content)
        message_thread = new_message.tap_send()

        message_thread.wait_for_received_messages()

        # Get the most recent received text message
        last_received_message = message_thread.received_messages[-1]

        # Check the most recent received message has the same text content
        self.assertEqual(text_message_content, last_received_message.text)
    def test_get_performance_measures(self):
        self._insert_contacts()
        if self.testvars["performance"]["verbose"]:
            print "Number of runs: {}".format(self.RUNS)

        for i in range(self.RUNS):
            if self.testvars["performance"]["verbose"]:
                print "Run #{}\n".format(i + 1)
            contacts_app = Contacts(self.marionette)
            contacts_app.launch()
            contacts_app.wait_for_contacts(number_to_wait_for=self.contacts_num)

            # Tap on the first contact, to see its details
            contact_details = contacts_app.contact(self.contacts[0]["givenName"]).tap()
            map(
                self.helpers.store_measures,
                [
                    "list_first_contact_rendered",
                    "list_chunk_contact_rendered",
                    "list_all_contacts_rendered",
                    "details_contact_rendered",
                ],
            )

            if i + 1 < self.RUNS:
                GaiaTestCase.setUp(self)
                self._insert_contacts()
Example #7
0
    def test_delete_contact(self):
        """ Test delete contact

        https://github.com/mozilla/gaia-ui-tests/issues/493

        """

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        pre_contacts_count = len(contacts_app.contacts)
        self.assertEqual(
            pre_contacts_count, 1,
            "Should insert one contact before running this test.")

        contact_item = contacts_app.contact(self.contact['givenName'][0])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()
        contact_item_edit.tap_delete()
        contact_item_edit.tap_confirm_delete()

        self.wait_for_condition(
            lambda m: len(self.data_layer.all_contacts) == 0,
            message="Should have no contact after run this test.")

        post_contacts_count = len(contacts_app.contacts)
        self.assertEqual(post_contacts_count, 0,
                         "Should have no contact after run this test.")
    def test_sms_contact(self):
        # https://moztrap.mozilla.org/manage/case/1314/
        # Setup a text message from a contact

        contacts = Contacts(self.marionette)
        contacts.launch()

        # tap on the created contact
        contact_details = contacts.contact(self.contact['givenName']).tap()

        contact_details.tap_send_sms()

        self.marionette.switch_to_frame()

        sms_iframe = self.marionette.find_element(*self._sms_app_iframe_locator)
        self.marionette.switch_to_frame(sms_iframe)

        self.wait_for_condition(
            lambda m: m.find_element(*self._contact_carrier_locator).text != "Carrier unknown")

        header_element = self.marionette.find_element(*self._sms_app_header_locator)
        expected_name = self.contact['givenName'] + " " + self.contact['familyName']
        expected_tel = self.contact['tel']['value']

        self.assertEqual(header_element.text, expected_name)
        self.assertEqual(header_element.get_attribute('data-phone-number'),
                         expected_tel)
    def test_call_contact(self):
        # NB This is not a listed smoke test
        # Call phone from a contact
        # https://moztrap.mozilla.org/manage/case/5679/

        contacts = Contacts(self.marionette)
        contacts.launch()

        # tap on the created contact
        contact_details = contacts.contact(self.contact['givenName']).tap()

        # tap the phone number and switch to call screen frame
        call_screen = contact_details.tap_phone_number()

        call_screen.wait_for_outgoing_call()

        # Check the number displayed is the one we dialed
        # TODO if this step fails bug 817291 may have been fixed
        self.assertIn(self.contact['tel']['value'],
                      call_screen.calling_contact_information)

        self.assertIn(self.contact['givenName'],
                      call_screen.outgoing_calling_contact[:-1])

        call_screen.hang_up()
        # Switch back to main frame before Marionette loses track bug #840931
        self.marionette.switch_to_frame()
Example #10
0
    def test_call_contact(self):
        """NB This is not a listed smoke test
        Call phone from a contact
        https://moztrap.mozilla.org/manage/case/5679/
        """
        contacts = Contacts(self.marionette)
        contacts.launch()
        contacts.wait_for_contacts()

        # tap on the created contact
        contact_details = contacts.contact(self.contact['givenName']).tap()

        # tap the phone number and switch to call screen frame
        call_screen = contact_details.tap_phone_number()

        call_screen.wait_for_outgoing_call()

        # Check the number displayed is the one we dialed
        self.assertIn(self.contact['tel']['value'],
                      call_screen.calling_contact_information)

        self.assertIn(self.contact['givenName'],
                      call_screen.outgoing_calling_contact)

        call_screen.hang_up()
        # Switch back to main frame before Marionette loses track bug #840931
        self.marionette.switch_to_frame()
Example #11
0
    def test_sms_contact(self):
        # https://moztrap.mozilla.org/manage/case/1314/
        # Setup a text message from a contact

        contacts = Contacts(self.marionette)
        contacts.launch()

        # tap on the created contact
        contact_details = contacts.contact(self.contact['givenName']).tap()

        contact_details.tap_send_sms()

        self.marionette.switch_to_frame()

        sms_iframe = self.marionette.find_element(*self._sms_app_iframe_locator)
        self.marionette.switch_to_frame(sms_iframe)

        expected_name = self.contact['givenName'] + " " + self.contact['familyName']
        expected_tel = self.contact['tel']['value']

        # Wait for two recipients listed - the last javascript performed on the page
        # One is from contacts app and one is the manual entry option
        self.wait_for_condition(lambda m: len(m.find_elements(*self._recipients_list_locator)) == 2)

        # Now check the first listed is from contacts app
        recipients_list = self.marionette.find_elements(*self._recipients_list_locator)
        first_recipient = recipients_list[0]

        # Name and phone number have been passed in correctly
        self.assertEqual(first_recipient.text, expected_name)
        self.assertEqual(first_recipient.get_attribute('data-number'),
                         expected_tel)
Example #12
0
    def test_delete_contact(self):
        """ Test delete contact

        https://github.com/mozilla/gaia-ui-tests/issues/493

        """

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        pre_contacts_count = len(contacts_app.contacts)
        self.assertEqual(pre_contacts_count, 1,
                         'Should insert one contact before running this test')

        contact_item = contacts_app.contact(self.contact['givenName'])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()
        contact_item_edit.tap_delete()
        contact_item_edit.tap_confirm_delete()

        self.wait_for_condition(
            lambda m: len(self.data_layer.all_contacts) == 0,
            message='Should have no contacts after running this test')

        post_contacts_count = len(contacts_app.contacts)
        self.assertEqual(post_contacts_count, 0,
                         'Should have no contacts after running this test')
Example #13
0
    def test_unlink_facebook_contact(self):
        """
        https://moztrap.mozilla.org/manage/case/5858/
        """

        username = self.testvars['facebook']['username']
        password = self.testvars['facebook']['password']
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        self.assertEqual(len(contacts_app.contacts), 1,
                         'Should insert one contact before running this test')

        # Go to contact item details
        contact_item = contacts_app.contact(self.contact['givenName'])
        contact_item_detail = contact_item.tap()

        facebook = contact_item_detail.tap_link_contact()
        contact_import_picker = facebook.login(username, password)
        contact_import_picker.tap_first_friend()

        contact_item_detail.tap_unlink_contact()
        contact_item_detail.tap_back()

        contacts_app.wait_for_contacts(2)
        self.assertEqual(len(contacts_app.contacts), 2,
                         'After unlinking the facebook contact should have been added')
Example #14
0
    def test_add_and_call_ice_contact(self):
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        contacts_settings = contacts_app.tap_settings()
        ice_contact_menu = contacts_settings.tap_set_ice_contact()
        ice_contact_select = ice_contact_menu.enable_set_ice_contact()

        contacts_app = ice_contact_select.select_ice_contact()
        contacts_app.wait_for_contacts(1)
        contact_selected = contacts_app.contacts[0].tap(
            return_class='SetIceContacts')
        settings = contact_selected.go_back()
        contact_list = settings.tap_done()

        self.assertTrue(contact_list.is_ice_list_icon_displayed)
        self.assertEqual(len(contact_list.contacts), 1)
        self.assertEqual(
            contact_list.contacts[0].full_name,
            (self.contact['givenName'] + ' ' + self.contact['familyName']))

        ice_contact = contact_list.open_ice_contact_list()
        ice_contact.wait_for_ice_contact_shown()

        ice_contact_details = contacts_app.contact(
            self.contact['givenName']).tap()
        call_screen = ice_contact_details.tap_phone_number()
        call_screen.wait_for_outgoing_call()
        call_screen.hang_up()
Example #15
0
    def test_edit_contact(self):
        # https://moztrap.mozilla.org/manage/case/1310/
        # First insert a new contact to edit

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        contact_details = contacts_app.contact(
            self.contact['givenName'][0]).tap()

        edit_contact = contact_details.tap_edit()

        # Now we'll update the mock contact and then insert the new values into the UI
        self.contact['givenName'] = [
            'gaia%s' % repr(time.time()).replace('.', '')[10:]
        ]
        self.contact['familyName'] = ["testedit"]
        self.contact['tel'][0]['value'] = "02011111111"

        # self.(*self._given_name_locator)

        edit_contact.type_given_name(self.contact['givenName'][0])
        edit_contact.type_family_name(self.contact['familyName'][0])
        edit_contact.type_phone(self.contact['tel'][0]['value'])

        contact_details = edit_contact.tap_update()

        contact_details.tap_back()

        self.assertEqual(len(contacts_app.contacts), 1)
        self.assertEqual(contacts_app.contacts[0].name,
                         self.contact['givenName'][0])

        contact_details = contacts_app.contact(
            self.contact['givenName'][0]).tap()

        # Now assert that the values have updated
        full_name = self.contact['givenName'][0] + " " + self.contact[
            'familyName'][0]

        self.assertEqual(contact_details.full_name, full_name)
        self.assertEqual(contact_details.phone_number,
                         self.contact['tel'][0]['value'])
    def test_add_photo_from_gallery_to_contact(self):
        # https://moztrap.mozilla.org/manage/case/5551/

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        contact_details = contacts_app.contact(self.contact['givenName']).tap()

        full_name = ' '.join(
            [self.contact['givenName'], self.contact['familyName']])

        self.assertEqual(full_name, contact_details.full_name)

        saved_contact_image_style = contact_details.image_style

        edit_contact = contact_details.tap_edit()

        self.assertEqual('Edit contact', edit_contact.title)

        saved_picture_style = edit_contact.picture_style

        actions_list = edit_contact.tap_picture()

        # choose the source as gallery app
        gallery = actions_list.tap_gallery()

        # switch to the gallery app
        gallery.switch_to_gallery_frame()
        gallery.wait_for_thumbnails_to_load()
        self.assertGreater(gallery.gallery_items_number, 0,
                           'No photos were found in the gallery.')

        image = gallery.tap_first_gallery_item()
        image.tap_crop_done()

        # switch back to the contacts app
        contacts_app.launch()

        self.assertEqual('Edit contact', edit_contact.title)

        edit_contact.wait_for_image_to_load()

        new_picture_style = edit_contact.picture_style
        self.assertNotEqual(
            new_picture_style, saved_picture_style,
            'The picture associated with the contact was not changed.')

        contact_details = edit_contact.tap_update()

        self.assertEqual(full_name, contact_details.full_name)

        self.assertNotEqual(
            contact_details.image_style, saved_contact_image_style,
            'The picture associated with the contact was not changed.')
    def test_import_edit_export_contact(self):
        """
        https://moztrap.mozilla.org/manage/case/14115/
        """

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        sim_contacts_number_before_import = len(self.data_layer.sim_contacts)
        self.apps.switch_to_displayed_app()

        # import contacts from SIM
        contacts_settings = contacts_app.tap_settings()
        contacts_settings.tap_import_contacts()
        contacts_settings.tap_import_from_sim()
        contacts_settings.tap_back_from_import_contacts()
        contacts_settings.tap_done()

        contact_first_name = self.sim_contact['name'][0].split()[0]
        contact_details = contacts_app.contact(contact_first_name).tap()

        edit_contact = contact_details.tap_edit()

        contact_new_family_name = 'New'

        edit_contact.type_family_name(contact_new_family_name)

        contact_details = edit_contact.tap_update()

        contact_details.tap_back()

        contacts_settings = contacts_app.tap_settings()
        contacts_settings.tap_export_contacts()
        contacts_settings.tap_export_to_sim()

        contacts_app.tap_select_all()
        contacts_app.tap_export()

        self.assertIn('contacts exported', contacts_app.status_message)

        sim_contacts = self.data_layer.sim_contacts

        self.assertEqual(len(sim_contacts), sim_contacts_number_before_import)

        for contact in sim_contacts:
            if contact['tel'][0]['value'] == self.sim_contact['tel'][0][
                    'value']:
                self.sim_contact = contact
                break

        self.assertEqual(
            self.sim_contact['name'][0],
            '%s %s' % (contact_first_name, contact_new_family_name))
        self.assertEqual(self.sim_contact['tel'][0]['value'],
                         self.contact.tel['value'])
Example #18
0
class TestEnduranceAddDeleteContact(GaiaEnduranceTestCase):
    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)
        self.contacts = Contacts(self.marionette)
        self.contacts.launch()

    def test_endurance_add_delete_contact(self):
        self.drive(test=self.add_delete_contact, app='contacts')

    def add_delete_contact(self):
        # Add a new contact, most of this code borrowed from existing gaia-ui tests
        # Uses data from mock contact, except adds iteration to first name

        # Add new contact
        new_contact_form = self.contacts.tap_new_contact()

        # Enter data into fields
        contact = MockContact()
        contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations)
        new_contact_form.type_given_name(contact['givenName'])
        new_contact_form.type_family_name(contact['familyName'])
        new_contact_form.type_phone(contact['tel'][0]['value'])
        new_contact_form.type_email(contact['email'][0]['value'])
        new_contact_form.type_street(contact['adr'][0]['streetAddress'])
        new_contact_form.type_zip_code(contact['adr'][0]['postalCode'])
        new_contact_form.type_city(contact['adr'][0]['locality'])
        new_contact_form.type_country(contact['adr'][0]['countryName'])
        new_contact_form.type_comment(contact['note'])

        # Save new contact
        new_contact_form.tap_done()
        time.sleep(2)

        # Verify a new contact was added
        self.wait_for_condition(lambda m: len(self.contacts.contacts) == 1)

        # Wait a couple of seconds before deleting
        time.sleep(2)

        # Delete the contact
        contact_item = self.contacts.contact(contact['givenName'])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()
        contact_item_edit.tap_delete()
        contact_item_edit.tap_confirm_delete()
        time.sleep(1)

        self.assertEqual(len(self.contacts.contacts), 0,
                         'Should have no contacts.')

        # Wait a couple of seconds before the next iteration
        time.sleep(2)
Example #19
0
    def test_add_contact_to_favorite(self):
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        contact_details = contacts_app.contact(self.contact['givenName']).tap()
        contact_details.tap_add_remove_favorite()
        self.assertEqual(contact_details.add_remove_text, 'Remove as Favorite')

        contacts_app = contact_details.tap_back()
        self.assertTrue(contacts_app.is_favorites_list_displayed)

        # Test that the contact is displayed twice: once under Favorites and once under Contacts.
        self.assertEqual(len(contacts_app.contacts), 2)
        self.assertEqual(contacts_app.contacts[0].full_name,
                         contacts_app.contacts[1].full_name)
Example #20
0
class TestEnduranceAddDeleteContact(GaiaEnduranceTestCase):
    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)
        self.contacts = Contacts(self.marionette)
        self.contacts.launch()

    def test_endurance_add_delete_contact(self):
        self.drive(test=self.add_delete_contact, app='contacts')

    def add_delete_contact(self):
        # Add a new contact, most of this code borrowed from existing gaia-ui tests
        # Uses data from mock contact, except adds iteration to first name

        # Add new contact
        new_contact_form = self.contacts.tap_new_contact()

        # Enter data into fields
        mock_contact = MockContact()
        extra_text = "-%dof%d" % (self.iteration, self.iterations)
        new_contact_form.type_given_name(mock_contact.givenName + extra_text)
        new_contact_form.type_family_name(mock_contact.familyName)
        new_contact_form.type_phone(mock_contact.tel['value'])
        new_contact_form.type_email(mock_contact.email)
        new_contact_form.type_street(mock_contact.street)
        new_contact_form.type_zip_code(mock_contact.zip)
        new_contact_form.type_city(mock_contact.city)
        new_contact_form.type_country(mock_contact.country)
        new_contact_form.type_comment(mock_contact.comment)

        # Save new contact
        new_contact_form.tap_done()

        # Verify a new contact was added
        self.wait_for_condition(lambda m: len(self.contacts.contacts) == 1)

        # Wait a couple of seconds before deleting
        time.sleep(2)

        contact = self.contacts.contact(mock_contact.givenName + extra_text)
        edit_contact = contact.tap().tap_edit()
        edit_contact.tap_delete()
        edit_contact.tap_confirm_delete()

        self.assertEqual(len(self.contacts.contacts), 0,
                         'Should have no contacts.')

        # Wait a couple of seconds before the next iteration
        time.sleep(2)
Example #21
0
    def test_sms_contact(self):
        """https://moztrap.mozilla.org/manage/case/1314/"""
        # Setup a text message from a contact.

        contacts = Contacts(self.marionette)
        contacts.launch()
        contacts.wait_for_contacts()

        # Tap on the created contact.
        contact_details = contacts.contact(self.contact['givenName']).tap()
        new_message = contact_details.tap_send_sms()
        new_message.wait_for_recipients_displayed()

        expected_name = self.contact['givenName'] + " " + self.contact['familyName']
        expected_tel = self.contact['tel']['value']

        # Now check the first listed is from contacts app.
        # Name and phone number have been passed in correctly.
        self.assertEqual(new_message.first_recipient_name, expected_name)
        self.assertEqual(new_message.first_recipient_number_attribute, expected_tel)
    def test_get_performance_measures(self):
        if self.testvars['performance']['verbose']:
            print "Number of runs: {}".format(self.RUNS)

        for i in range(self.RUNS):
            if self.testvars['performance']['verbose']:
                print "Run #{}\n".format(i + 1)
            contacts_app = Contacts(self.marionette)
            contacts_app.launch()
            contacts_app.wait_for_contacts(
                number_to_wait_for=self.contacts_num)

            # Tap on the first contact, to see its details
            contact_details = contacts_app.contact(
                self.contacts[0]['givenName']).tap()
            map(self.helpers.store_measures, [
                'list_first_contact_rendered', 'list_chunk_contact_rendered',
                'list_all_contacts_rendered', 'details_contact_rendered'
            ])
            self.apps.kill_all()
            time.sleep(2)
Example #23
0
    def test_delete_contact(self):
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        pre_contacts_count = len(contacts_app.contacts)
        self.assertEqual(pre_contacts_count, 1,
                         'Should insert one contact before running this test')

        contact_item = contacts_app.contact(self.contact['givenName'])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()
        contact_item_edit.tap_delete()
        contact_item_edit.tap_confirm_delete()

        self.wait_for_condition(
            lambda m: len(self.data_layer.all_contacts) == 0,
            message='Should have no contacts after running this test')

        post_contacts_count = len(contacts_app.contacts)
        self.assertEqual(post_contacts_count, 0,
                         'Should have no contacts after running this test')
Example #24
0
    def test_delete_contact(self):
        """ Test delete contact

        https://github.com/mozilla/gaia-ui-tests/issues/493

        """

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        pre_contacts_count = len(contacts_app.contacts)
        self.assertEqual(pre_contacts_count, 1,
                         "Should insert one contact befor run this test.")

        contact_item = contacts_app.contact(self.contact['givenName'])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()
        contact_item_edit.tap_delete()
        contact_item_edit.tap_confirm_delete()

        post_contacts_count = len(contacts_app.contacts)
        self.assertEqual(post_contacts_count, 0,
                         "Should have no contact after run this test.")
Example #25
0
class TestKeyboard(GaiaMtbfTestCase):

    _string = "aG1 2Ds3~!=@.#$^aśZîd".decode("UTF-8")

    def test_keyboard_basic(self):
        # Use the contacts app to enter some text
        self.contact = MockContact()
        self.contacts_app = Contacts(self.marionette)
        self.contacts_app.launch()
        new_contact_form = self.contacts_app.tap_new_contact()
        new_contact_form.type_phone(self.contact['tel']['value'])
        new_contact_form.type_comment('')

        # initialize the keyboard app
        keyboard = new_contact_form.keyboard

        # send first 15 characters, delete last character, send a space, and send all others
        keyboard.send(self._string[:15])
        keyboard.tap_backspace()
        keyboard.tap_space()
        keyboard.send(self._string[15:])

        # select special character using extended character selector
        keyboard.choose_extended_character('A', 9)

        # go back to app frame and finish this
        self.apps.switch_to_displayed_app()
        new_contact_form.tap_done()
        new_contact = self.contacts_app.contact(self.contact['tel']['value'])
        if new_contact:
            contact_details = new_contact.tap()
            output_text = contact_details.comments
            self.assertEqual(self._string[:14] + ' ' + self._string[15:] + 'Æ'.decode("UTF-8"), output_text)
            contact_details.tap_back()
        else:
            self.assertEqual(True, False)
    def test_add_photo_from_gallery_to_contact(self):
        # https://moztrap.mozilla.org/manage/case/5551/

        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        contacts_app.wait_for_contacts()

        contact_details = contacts_app.contact(self.contact['givenName']).tap()

        full_name = ' '.join(
            [self.contact['givenName'], self.contact['familyName']])

        self.assertEqual(full_name, contact_details.full_name)

        saved_contact_image_style = contact_details.image_style

        edit_contact = contact_details.tap_edit()

        self.assertEqual('Edit contact', edit_contact.title)

        saved_picture_style = edit_contact.picture_style

        edit_contact.tap_picture()

        # switch to the system app
        self.marionette.switch_to_frame()

        # choose the source as gallery app
        self.wait_for_element_displayed(*self._gallery_button_locator)
        self.marionette.find_element(*self._gallery_button_locator).tap()

        # switch to the gallery app
        self.wait_for_element_displayed(*self._gallery_frame_locator)
        self.marionette.switch_to_frame(
            self.marionette.find_element(*self._gallery_frame_locator))

        self.wait_for_element_displayed(*self._gallery_items_locator)
        gallery_items = self.marionette.find_elements(
            *self._gallery_items_locator)
        self.assertGreater(len(gallery_items), 0,
                           'No photos were found in the gallery.')
        gallery_items[0].tap()

        self.wait_for_element_displayed(
            *self._gallery_crop_done_button_locator)
        self.marionette.find_element(
            *self._gallery_crop_done_button_locator).tap()

        # switch back to the contacts app
        contacts_app.launch()

        self.assertEqual('Edit contact', edit_contact.title)

        edit_contact.wait_for_image_to_load()

        new_picture_style = edit_contact.picture_style
        self.assertNotEqual(
            new_picture_style, saved_picture_style,
            'The picture associated with the contact was not changed.')

        contact_details = edit_contact.tap_update()

        self.assertEqual(full_name, contact_details.full_name)

        self.assertNotEqual(
            contact_details.image_style, saved_contact_image_style,
            'The picture associated with the contact was not changed.')
class TestEnduranceAddEditContact(GaiaEnduranceTestCase):
    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)

        # Remove any existing contacts
        self.data_layer.remove_all_contacts(60000)

        # Launch the Contacts app
        self.contacts = Contacts(self.marionette)
        self.contacts.launch()

        self.contact = MockContact()

    def test_endurance_add_edit_contact(self):
        self.drive(test=self.add_edit_contact, app='contacts')

    def add_edit_contact(self):
        # Add a new contact, most of this code borrowed from test_add_new_contact
        # Uses data from mock contact, except adds iteration to first name

        # Add new contact
        new_contact_form = self.contacts.tap_new_contact()
        original_name = self.contact.givenName
        extra_text = "-%dof%d" % (self.iteration, self.iterations)
        self.contact.givenName = self.contact.givenName + extra_text

        # Enter data into fields
        new_contact_form.type_given_name(self.contact.givenName)
        new_contact_form.type_family_name(self.contact.familyName)
        new_contact_form.type_phone(self.contact.tel['value'])
        new_contact_form.type_email(self.contact.email)
        new_contact_form.type_street(self.contact.street)
        new_contact_form.type_zip_code(self.contact.zip)
        new_contact_form.type_city(self.contact.city)
        new_contact_form.type_country(self.contact.country)
        new_contact_form.type_comment(self.contact.comment)

        # Save new contact
        new_contact_form.tap_done()

        # Verify a new contact was added
        self.wait_for_condition(
            lambda m: len(self.contacts.contacts) == self.iteration)

        # Wait a couple of seconds before editing
        time.sleep(2)

        contact_details = self.contacts.contact(self.contact.givenName).tap()
        edit_contact = contact_details.tap_edit()

        # Now we'll update the mock contact and then insert the new values into the UI
        self.contact.givenName = self.contact.givenName + " - edit"
        edit_contact.type_given_name(self.contact.givenName)

        contact_details = edit_contact.tap_update()
        contact_details.tap_back()

        self.assertEqual(len(self.contacts.contacts), self.iteration)
        contact_details = self.contacts.contact(self.contact.givenName).tap()

        # Now assert that the values have updated
        full_name = self.contact.givenName + " " + self.contact.familyName
        self.assertEqual(contact_details.full_name, full_name)

        # Back to main contacts list
        contact_details.tap_back()

        # Set mock contact name back to original, for next rep
        self.contact.givenName = original_name

        # Sleep between reps
        time.sleep(3)
class TestEnduranceAddEditContact(GaiaEnduranceTestCase):
    def setUp(self):
        GaiaEnduranceTestCase.setUp(self)

        # Remove any existing contacts
        self.data_layer.remove_all_contacts(60000)

        # Launch the Contacts app
        self.contacts = Contacts(self.marionette)
        self.contacts.launch()

    def test_endurance_add_edit_contact(self):
        self.drive(test=self.add_edit_contact, app='contacts')

    def add_edit_contact(self):
        # Add a new contact, most of this code borrowed from test_add_new_contact
        # Uses data from mock contact, except adds iteration to first name
        contact = MockContact()

        # Add new contact
        new_contact_form = self.contacts.tap_new_contact()

        # Enter data into fields
        contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations)
        new_contact_form.type_given_name(contact['givenName'])
        new_contact_form.type_family_name(contact['familyName'])
        new_contact_form.type_phone(contact['tel'][0]['value'])
        new_contact_form.type_email(contact['email'][0]['value'])
        new_contact_form.type_street(contact['adr'][0]['streetAddress'])
        new_contact_form.type_zip_code(contact['adr'][0]['postalCode'])
        new_contact_form.type_city(contact['adr'][0]['locality'])
        new_contact_form.type_country(contact['adr'][0]['countryName'])
        new_contact_form.type_comment(contact['note'])

        # Save new contact
        new_contact_form.tap_done()
        time.sleep(2)

        # Verify a new contact was added
        self.wait_for_condition(
            lambda m: len(self.contacts.contacts) == self.iteration)

        # Wait a couple of seconds before editing
        time.sleep(2)

        # Edit the contact
        contact_item = self.contacts.contact(contact['givenName'])
        contact_item_detail = contact_item.tap()
        contact_item_edit = contact_item_detail.tap_edit()

        # Now we'll update the mock contact and then insert the new values into the UI
        contact['givenName'] = '%s EDITED' % contact['givenName']
        contact_item_edit.type_given_name(contact['givenName'])

        contact_details = contact_item_edit.tap_update()
        time.sleep(2)
        contact_details.tap_back()
        time.sleep(2)

        self.assertEqual(len(self.contacts.contacts), self.iteration)
        contact_details = self.contacts.contact(contact['givenName']).tap()

        # Now assert that the values have updated
        expected_name = contact['givenName'] + " " + contact['familyName'][0]
        self.assertEqual(expected_name, contact_details.full_name)

        # Back to main contacts list
        contact_details.tap_back()

        # Sleep between reps
        time.sleep(3)