def test_change_keyboard_language_settings(self):
        settings = Settings(self.marionette)
        settings.launch()
        keyboard_settings = settings.open_keyboard_settings()

        # Tap on active keyboard link
        select_keyboard = keyboard_settings.tap_active_keyboard()

        # Tap 'add more keyboards' button
        add_more_keyboards = select_keyboard.tap_add_more_keyboards()

        # Select keyboard language
        add_more_keyboards.select_language('Spanish')

        # launch the Contacts app to verify the keyboard layout
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        new_contact_form = contacts_app.tap_new_contact()
        new_contact_form.type_given_name('')

        # Switch to keyboard frame and switch language
        new_contact_form.keyboard.switch_to_keyboard()
        new_contact_form.keyboard.tap_keyboard_language_key()
        self.wait_for_element_displayed(*self._special_key_locator)
        special_key = self.marionette.find_element(*self._special_key_locator).text

        # Checking if exists the special key - "ñ"
        self.assertEqual(special_key, self._expected_key)
Esempio n. 2
0
    def test_add_new_contact(self):
        # https://moztrap.mozilla.org/manage/case/1309/
        self.contact = MockContact()

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

        new_contact_form = contacts_app.tap_new_contact()

        # 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']['value'])
        new_contact_form.type_street(self.contact['adr']['streetAddress'])
        new_contact_form.type_zip_code(self.contact['adr']['postalCode'])
        new_contact_form.type_city(self.contact['adr']['locality'])
        new_contact_form.type_country(self.contact['adr']['countryName'])
        new_contact_form.type_comment(self.contact['note'])

        new_contact_form.tap_done()
        self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1)

        self.assertEqual(contacts_app.contacts[0].name, self.contact['givenName'])
Esempio n. 3
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)

        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()
Esempio n. 5
0
    def test_add_new_contact(self):
        # https://moztrap.mozilla.org/manage/case/1309/
        self.contact = MockContact()

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

        new_contact_form = contacts_app.tap_new_contact()

        # 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'])
        # Bug 862053 is preventing us from typing in these fields
        # TODO: Re-enable these types once the bug has been fixed
        # 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'])

        new_contact_form.tap_done()
        self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1)

        self.assertEqual(contacts_app.contacts[0].name, self.contact['givenName'])
    def test_sms_create_new_contact(self):
        self.contact = MockContact()
        self.message_thread = self.messages.tap_first_received_message()
        self.message_thread.wait_for_received_messages()

        # Check that we received the correct message
        self.assertEqual(self.message_thread.header_text, self.environment.phone_numbers[0])

        activities = self.message_thread.tap_header()

        # Create a new contact
        new_contact = activities.tap_create_new_contact()

        # Populate new contact fields
        new_contact.type_given_name(self.contact['givenName'])
        new_contact.type_family_name(self.contact['familyName'])
        new_contact.type_email(self.contact['email']['value'])
        new_contact.type_street(self.contact['adr']['streetAddress'])
        new_contact.type_zip_code(self.contact['adr']['postalCode'])
        new_contact.type_city(self.contact['adr']['locality'])
        new_contact.type_country(self.contact['adr']['countryName'])
        new_contact.type_comment(self.contact['note'])
        new_contact.tap_done(return_contacts=False)

        self.wait_for_condition(lambda m: self.message_thread.header_text == self.contact['name'])

        contacts = Contacts(self.marionette)
        contacts.launch()
        contact_details = contacts.contacts[0].tap()
        self.assertEqual(contact_details.phone_numbers[0], self.environment.phone_numbers[0])
    def test_import_gmail_no_network(self):
        '''
        https://moztrap.mozilla.org/manage/case/8986/
        '''
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        contacts_settings = contacts_app.tap_settings()

        contacts_settings.tap_import_contacts()

        self.assertEqual(contacts_settings.gmail_imported_contacts, u'Not imported')
        gmail = contacts_settings.tap_import_from_gmail()

        # Login to gmail account
        gmail.switch_to_gmail_login_frame()

        email = self.environment.email['gmail']['email']
        password = self.environment.email['gmail']['password']

        gmail.gmail_login(email, password)
        contact_import_picker = gmail.tap_grant_access()

        # Import all contacts
        contact_import_picker.tap_select_all()
        contact_import_picker.tap_import_button(wait_for_import=False)

        self.disable_all_network_connections()
        self.apps.switch_to_displayed_app()

        confirmation_view = ConfirmationView(self.marionette)
        self.assertEqual(confirmation_view.error_message,
                         u'Friends\u2019 photos will not be added to your contacts. Continue anyway?')
Esempio n. 8
0
    def test_keyboard_basic(self):
        # Use the contacts app to enter some text
        contact = MockContact()
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        new_contact_form = contacts_app.tap_new_contact()
        new_contact_form.type_phone(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
        # Now the menu would include the original char, so the index should +1
        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()
        self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1)

        contact_details = contacts_app.contacts[0].tap()
        output_text = contact_details.comments

        self.assertEqual(self._string[:14] + ' ' + self._string[15:] + 'Æ'.decode("UTF-8"), output_text)
Esempio n. 9
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)
    def test_import_contacts_menu_no_network(self):
        '''
        https://moztrap.mozilla.org/manage/case/15183/
        '''
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        contacts_settings = contacts_app.tap_settings()

        contacts_settings.tap_import_contacts()

        self.assertFalse(contacts_settings.is_gmail_import_service_in_error)
        self.assertTrue(contacts_settings.is_gmail_import_enabled)

        self.assertFalse(contacts_settings.is_outlook_import_service_in_error)
        self.assertTrue(contacts_settings.is_outlook_import_enabled)

        self.assertFalse(contacts_settings.is_error_message_displayed)

        self.disable_all_network_connections()
        self.apps.switch_to_displayed_app()

        self.assertTrue(contacts_settings.is_gmail_import_service_in_error)
        self.assertFalse(contacts_settings.is_gmail_import_enabled)

        self.assertTrue(contacts_settings.is_outlook_import_service_in_error)
        self.assertFalse(contacts_settings.is_outlook_import_enabled)

        self.assertTrue(contacts_settings.is_error_message_displayed)
Esempio n. 11
0
    def test_import_contacts_from_gmail(self):

        email = self.testvars['email']['gmail']['email']
        password = self.testvars['email']['gmail']['password']
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        # Go on Contacts Settings page
        contacts_settings = contacts_app.tap_settings()

        # Tap Import Contacts
        contacts_settings.tap_import_contacts()

        # Check there are no gmail contacts imported
        self.assertEqual(contacts_settings.gmail_imported_contacts, u'Not imported')
        gmail = contacts_settings.tap_import_from_gmail()

        # Login to gmail account
        gmail.switch_to_gmail_login_frame()
        gmail.gmail_login(email, password)
        contact_import_picker = gmail.tap_grant_access()

        # Import all contacts
        contact_import_picker.tap_select_all()
        contacts_settings = contact_import_picker.tap_import_button()
        contacts_settings.tap_back_from_import_contacts()
        contacts_settings.tap_done()

        # Check there is one gmail contact imported
        self.assertEqual(len(contacts_app.contacts), 1)
    def test_sms_add_number_to_existing_contact(self):

        # open the message thread screen
        self.message_thread = self.messages.tap_first_received_message()
        self.message_thread.wait_for_received_messages()

        # Check that we received the correct message
        self.assertEqual(self.message_thread.header_text, self.environment.phone_numbers[0])

        activities = self.message_thread.tap_header()

        contacts = activities.tap_add_to_contact()
        contacts.wait_for_contacts(1)
        edit_contact = contacts.contacts[0].tap(return_class='EditContact')

        edit_contact.tap_update(return_class=None)

        self.wait_for_condition(lambda m: self.message_thread.header_text == self.contact['name'])

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

        contact_details = contacts.contacts[0].tap()
        self.assertEqual(contact_details.phone_numbers[1], self.environment.phone_numbers[0])
    def test_change_keyboard_language_settings(self):
        settings = Settings(self.marionette)
        settings.launch()
        keyboard_settings = settings.open_keyboard_settings()

        # Tap 'add more keyboards' button
        add_more_keyboards = keyboard_settings.tap_add_more_keyboards()

        # Select keyboard language, then click back to make it "stick"
        add_more_keyboards.select_language(u'Espa\u00F1ol')
        add_more_keyboards.go_back()

        keyboard_settings.wait_for_built_in_keyboard(u'Espa\u00F1ol')

        # launch the Contacts app to verify the keyboard layout
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()
        new_contact_form = contacts_app.tap_new_contact()
        new_contact_form.type_given_name('')

        # Switch to keyboard frame and switch language
        new_contact_form.keyboard.switch_to_keyboard()
        new_contact_form.keyboard.tap_keyboard_language_key()
        new_contact_form.keyboard.switch_to_keyboard()
        special_key = self.marionette.find_element(*self._special_key_locator).text

        # Checking if exists the special key - "ñ"
        self.assertEqual(special_key, self._expected_key)
Esempio n. 14
0
    def test_add_new_contact(self):
        # https://moztrap.mozilla.org/manage/case/1309/
        self.contact = MockContact()

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

        new_contact_form = contacts_app.tap_new_contact()

        # 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"][0]["value"])
        new_contact_form.type_email(self.contact["email"][0]["value"])
        new_contact_form.type_street(self.contact["adr"][0]["streetAddress"])
        new_contact_form.type_zip_code(self.contact["adr"][0]["postalCode"])
        new_contact_form.type_city(self.contact["adr"][0]["locality"])
        new_contact_form.type_country(self.contact["adr"][0]["countryName"])
        new_contact_form.type_comment(self.contact["note"])

        new_contact_form.tap_done()
        self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1)

        self.assertEqual(contacts_app.contacts[0].name, self.contact["givenName"][0])
Esempio n. 15
0
    def tap_add_to_contact(self):
        self.marionette.find_element(*self._add_to_contact_button_locator).tap()

        from gaiatest.apps.contacts.app import Contacts
        contacts = Contacts(self.marionette)
        contacts.switch_to_contacts_frame()
        return contacts
Esempio n. 16
0
    def tap_add_to_existing_contact(self):
        element = self.marionette.find_element(*self._add_to_existing_contact_locator)
        Wait(self.marionette).until(expected.element_displayed(element))
        element.tap()

        contact = Contacts(self.marionette)
        contact.switch_to_contacts_frame()
        return contact
Esempio n. 17
0
    def launch_app(self):

        self.log("Launching app and waiting for it to be ready!")

        # launch the contacts app and wait for the contacts to be displayed,
        # the first launch after populating the data takes a long time.
        contacts = Contacts(self.device.marionette)
        contacts.launch()
        Wait(self.device.marionette, 120, ignored_exceptions=(NoSuchElementException, ElementNotVisibleException)).until(lambda m: m.find_element(*contacts._contact_locator).is_displayed())
Esempio n. 18
0
    def launch_app(self):

        self.log("Launching app and waiting for it to be ready!")

        # launch the contacts app and wait for the contacts to be displayed,
        # the first launch after populating the data takes a long time.
        contacts = Contacts(self.device.marionette)
        contacts.launch()
        self.wait_for_content_ready()
Esempio n. 19
0
    def test_sort_contacts(self):
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

        contacts_app.wait_for_contacts(number_to_wait_for=len(self._contacts_name_list))

        # sort by first name, compare with sorted-by-first-name list
        contact_items = contacts_app.contacts
        for idx in range(len(self._contacts_name_list)):
            name_tuple = self.sorted_contacts_name_by_first[idx]
            self.assertEqual(contact_items[idx].full_name, name_tuple[0] + " " + name_tuple[1], "Should order by first name.")

        contacts_settings = contacts_app.tap_settings()
        contacts_settings.enable_order_by_last_name()
        contacts_settings.tap_done()
        contacts_app.wait_for_contacts(number_to_wait_for=len(self._contacts_name_list))

        contact_items = contacts_app.contacts
        for idx in range(len(self._contacts_name_list)):
            name_tuple = self.sorted_contacts_name_by_last[idx]
            self.assertEqual(contact_items[idx].full_name, name_tuple[0] + " " + name_tuple[1], "Should order by last name.")

        contacts_settings = contacts_app.tap_settings()
        contacts_settings.disable_order_by_last_name()
        contacts_settings.tap_done()
Esempio n. 20
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()
    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'])
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)
Esempio n. 23
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.")

        contacts_app.switch_to_contacts_frame()
        post_contacts_count = len(contacts_app.contacts)
        self.assertEqual(post_contacts_count, 0, "Should have no contact after run this test.")
    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)
Esempio n. 25
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')
    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.')
    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)
            map(self.helpers.store_measures,
                ['list_first_contact_rendered', 'list_chunk_contact_rendered',
                 'list_all_contacts_rendered'])
            self.apps.kill_all()
            time.sleep(2)
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)
Esempio n. 29
0
    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_import_contacts_from_SIM(self):
        """ Insert a new prepaid SIM card (some contacts) in device and import the contacts

        https://moztrap.mozilla.org/manage/case/5880/

        """

        self.assertGreater(len(self.data_layer.sim_contacts), 0, "There is no SIM contacts on SIM card.")
        contacts_app = Contacts(self.marionette)
        contacts_app.launch()

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

        # all the contacts in the SIM should be imported
        self.assertEqual(len(contacts_app.contacts), len(self.data_layer.sim_contacts))
Esempio n. 31
0
    def test_export_contacts_to_sdcard(self):
        """ Export contacts to an SD card """

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

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

        contacts_app.tap_select_all()
        contacts_app.tap_export()

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

        vcf_files = self.data_layer.sdcard_files('.vcf')

        self.assertEqual(1, len(vcf_files))
    def test_add_photo_from_gallery_to_contact(self):
        # https://moztrap.mozilla.org/manage/case/5551/

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

        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.tap(
            self.marionette.find_element(*self._gallery_button_locator))

        # 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.')
        self.marionette.tap(gallery_items[0])

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

        # 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.')
Esempio n. 33
0
    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'])
Esempio n. 34
0
 def tap_confirm_delete(self):
     self.wait_for_element_displayed(*self._delete_form_locator)
     self.marionette.find_element(*self._confirm_delete_locator).tap()
     from gaiatest.apps.contacts.app import Contacts
     return Contacts(self.marionette)
Esempio n. 35
0
 def tap_add_recipient(self):
     self.marionette.find_element(*self._add_recipient_button_locator).tap()
     contacts_app = Contacts(self.marionette)
     contacts_app.switch_to_contacts_frame()
     return contacts_app
Esempio n. 36
0
 def tap_back(self):
     self.marionette.tap(
         self.marionette.find_element(*self._back_button_locator))
     from gaiatest.apps.contacts.app import Contacts
     return Contacts(self.marionette)
Esempio n. 37
0
 def setUp(self):
     GaiaEnduranceTestCase.setUp(self)
     self.contacts = Contacts(self.marionette)
     self.contacts.launch()