示例#1
0
    def test_cleanup_gaia(self):
        self.check_initial_state()

        # change volume
        self.data_layer.set_volume(5)
        self.assertEqual(self.data_layer.get_setting(
            'audio.volume.content'), 5)

        # connect to wifi network
        if (self.testvars.get('wifi') and self.device.has_wifi):
            self.data_layer.connect_to_wifi()
            self.assertTrue(len(self.data_layer.known_networks) > 0)

        # insert contacts
        self.data_layer.insert_contact(MockContact())
        self.data_layer.insert_contact(MockContact())
        self.assertEqual(len(self.data_layer.all_contacts), 2)

        # move away from home screen
        self.marionette.switch_to_frame(
            self.marionette.find_element(*self.homescreen_frame_locator))
        self.marionette.execute_script(
            'window.wrappedJSObject.GridManager.goToPage(1);')
        self.assertEqual(self.marionette.execute_script("""
var manager = window.wrappedJSObject.GridManager;
return manager.pageHelper.getCurrentPageNumber();
"""), 1)
        self.marionette.switch_to_frame()

        # lock screen
        self.device.lock()
        self.assertTrue(self.device.is_locked)

        self.cleanup_gaia()
        self.check_initial_state()
    def test_state_after_reset(self):
        # push media files
        self.push_resource('IMG_0001.jpg', destination='DCIM/100MZLLA')
        self.push_resource('VID_0001.3gp', destination='DCIM/100MZLLA')
        self.push_resource('MUS_0001.mp3')

        # change volume
        self.data_layer.set_volume(5)

        # connect to wifi network
        if (self.testvars.get('wifi') and self.device.has_wifi):
            self.data_layer.connect_to_wifi()
            self.data_layer.disable_wifi()

        # insert contacts
        self.data_layer.insert_contact(MockContact())
        self.data_layer.insert_contact(MockContact())

        # move away from home screen
        self.marionette.switch_to_frame(
            self.marionette.find_element(*self.homescreen_frame_locator))
        self.marionette.execute_script(
            'window.wrappedJSObject.GridManager.goToPage(2);')
        self.marionette.switch_to_frame()

        # lock screen
        self.lockscreen.lock()

        self.cleanUp()
        self.check_initial_state()
 def setUp(self):
     GaiaTestCase.setUp(self)
     
     self.contact = MockContact(givenName='Test', tel=None)
     self.contact2 = MockContact(givenName=self.contact['givenName'], tel={
         'type': 'Mobile',
         'value': '123456789'})
     self.data_layer.insert_contact(self.contact)
     self.data_layer.insert_contact(self.contact2)
示例#4
0
    def test_create_mozcontact(self):
        # Initialize a MockContact with the default properties
        contact = MockContact()

        # Add a list of object properties - multiple telephone numbers
        contact['objects'] = [contact['tel'], contact['tel']]

        mozcontact = contact.create_mozcontact()
        for key in mozcontact.iterkeys():
            self.assertFalse(contact.is_mozcontact_api_format(contact[key]))
            self.assertTrue(contact.is_mozcontact_api_format(mozcontact[key]))
示例#5
0
文件: test_contacts.py 项目: 4gh/gaia
    def test_create_mozcontact(self):
        # Initialize a MockContact with the default properties
        contact = MockContact()

        # Add a list of object properties - multiple telephone numbers
        contact['objects'] = [contact['tel'], contact['tel']]

        mozcontact = contact.create_mozcontact()
        for key in mozcontact.iterkeys():
            self.assertFalse(contact.is_mozcontact_api_format(contact[key]))
            self.assertTrue(contact.is_mozcontact_api_format(mozcontact[key]))
示例#6
0
    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest(
                'Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.contact.update(tel={
            'type': 'Mobile',
            'value': self.testvars['plivo']['phone_number']
        })
        self.data_layer.insert_contact(self.contact)
示例#7
0
    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest('Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        with open(self.resource('IMG_0001.jpg'), 'rb') as f:
            encoded_string = base64.b64encode(f.read())

        self.contact = MockContact()
        self.contact.update(photo='%s' % encoded_string,
                            tel={'type': 'Mobile', 'value': self.testvars['plivo']['phone_number']})
        self.data_layer.insert_contact(self.contact)
示例#8
0
    def setUp(self):
        GaiaTestCase.setUp(self)
        self.contact = MockContact()

        # launch the Phone app
        self.phone = Phone(self.marionette)
        self.phone.launch()
示例#9
0
    def test_sms_add_contact(self):
        """ Add a contact to a message. """

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

        # insert contact
        self.contact = MockContact(
            tel=[{
                'type': ['Mobile'],
                'value': '555%s' % repr(time.time()).replace('.', '')[8:]
            }])
        self.data_layer.insert_contact(self.contact)

        self.messages = Messages(self.marionette)
        self.messages.launch()

        new_message = self.messages.tap_create_new_message()
        contacts_app = new_message.tap_add_recipient()
        contacts_app.wait_for_contacts()

        contacts_app.contact(
            self.contact['givenName'][0]).tap(return_details=False)
        contacts_app.wait_for_contacts_frame_to_close()

        # Now switch to the displayed frame which should be Messages app
        self.marionette.switch_to_frame(self.apps.displayed_app.frame)

        self.assertIn(self.contact['givenName'][0],
                      new_message.first_recipient_name)
        self.assertEquals(self.contact['tel'][0]['value'],
                          new_message.first_recipient_number_attribute)

        new_message.type_message(_text_message_content)
        self.assertTrue(new_message.is_send_button_enabled)
示例#10
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'])
        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'])
示例#11
0
    def add_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()

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

        # Save new contact
        new_contact_form.tap_done()

        # Ensure all contacts were added
        if self.iteration == self.iterations:
            self.assertEqual(len(self.contacts.contacts), self.iterations)

        # Sleep between reps
        time.sleep(3)
示例#12
0
    def add_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()

        # 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)

        # Ensure all contacts were added
        if self.iteration == self.iterations:
            self.assertEqual(len(self.contacts.contacts), self.iterations)

        # Sleep between reps
        time.sleep(3)
示例#13
0
    def test_sms_add_contact(self):
        """ Add a contact to a message. """

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

        # insert contact
        self.contact = MockContact(tel={
            'type':
            'Mobile',
            'value':
            '555%s' % repr(time.time()).replace('.', '')[8:]
        },
                                   email=None)
        self.data_layer.insert_contact(self.contact)

        self.messages = Messages(self.marionette)
        self.messages.launch()

        new_message = self.messages.tap_create_new_message()
        contacts_app = new_message.tap_add_recipient()
        contacts_app.wait_for_contacts()

        # After tap, don't return a class; fall back to the displayed frame which should be Messages app
        contacts_app.contact(self.contact['givenName']).tap(return_class=None)

        self.assertIn(self.contact['givenName'],
                      new_message.first_recipient_name)
        self.assertEquals(self.contact['tel']['value'],
                          new_message.first_recipient_number_attribute)

        new_message.type_message(_text_message_content)
        self.assertTrue(new_message.is_send_button_enabled)
    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])
示例#15
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'][0]['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', 8)

        # 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)
示例#16
0
    def test_sms_add_contact(self):
        """ Add a contact to a message. """

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

        # insert contact
        self.contact = MockContact(tel=[{
            'type': ['Mobile'],
            'value': "%s" % self.testvars['carrier']['phone_number']}])
        self.data_layer.insert_contact(self.contact)

        self.messages = Messages(self.marionette)
        self.messages.launch()

        new_message = self.messages.tap_create_new_message()
        contacts_app = new_message.tap_add_recipient()
        contacts_app.wait_for_contacts()
        contacts_app.contact(self.contact['givenName'][0]).tap(return_details=False)
        self.messages.switch_to_messages_frame()

        self.assertIn(self.contact['givenName'][0], new_message.first_recipient_name)

        new_message.type_message(_text_message_content)

        self.message_thread = new_message.tap_send()
        self.message_thread.wait_for_received_messages()

        last_received_message = self.message_thread.received_messages[-1]
        self.assertEqual(_text_message_content, last_received_message.text)
示例#17
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # launch the Contacts app
        self.app = self.apps.launch('Contacts')
        self.wait_for_element_not_displayed(*self._loading_overlay)

        self.contact = MockContact()
    def setUp(self):
        GaiaTestCase.setUp(self)
        self.helpers = Helpers(self)
        self.contacts_num = self.testvars['performance']['contacts_num']
        self.RUNS = self.testvars['performance']['runs']

        self.contacts = [MockContact() for i in range(self.contacts_num)]
        map(self.data_layer.insert_contact, self.contacts)
示例#19
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Seed the contact with the remote phone number so we don't call random people
        self.contact = MockContact(tel={
            'type': 'Mobile',
            'value': "%s" % self.testvars['remote_phone_number']})
        self.data_layer.insert_contact(self.contact)
示例#20
0
    def setUp(self):
        GaiaTestCase.setUp(self)
        curr_time = repr(time.time()).replace('.', '')

        self.contact = MockContact(givenName='Name%s' % curr_time[12:],
                                   name='Name%s' % curr_time[12:],
                                   familyName='')
        self.sim_contact = self.data_layer.insert_sim_contact(self.contact)
示例#21
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.data_layer.insert_contact(self.contact)

        # add photo to storage
        self.push_resource('IMG_0001.jpg', destination='DCIM/100MZLLA')
    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)
示例#23
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.contact = MockContact(
            tel={
                'type': 'Mobile',
                'value': "%s" % self.testvars['remote_phone_number']
            })
        self.data_layer.insert_contact(self.contact)
    def setUp(self):
        try:
            self.testvars["plivo"]
        except KeyError:
            raise SkipTest("Plivo account details not present in test variables")
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.contact.update(tel={"type": "Mobile", "value": self.testvars["plivo"]["phone_number"]})
        self.data_layer.insert_contact(self.contact)
示例#25
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # insert contacts by given names
        for contact_name in self._contacts_name_list:
            contact = MockContact(givenName=contact_name[0], familyName=contact_name[1])
            self.data_layer.insert_contact(contact)
        # prepare the sorted-by-first-name and sorted-by-last-name lists
        self.sorted_contacts_name_by_first = sorted(self._contacts_name_list, key=lambda name: name[0])
        self.sorted_contacts_name_by_last = sorted(self._contacts_name_list, key=lambda name: name[1])
示例#26
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        self.assertTrue(self.lockscreen.unlock())

        self.contact = MockContact()

        # launch the Contacts app
        self.app = self.apps.launch('Contacts')
        self.wait_for_element_not_displayed(*self._loading_overlay)
示例#27
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # launch the Contacts app
        self.app = self.apps.launch('Contacts')
        self.wait_for_element_not_displayed(*self._loading_overlay)

        self.contact = MockContact()
        self.data_layer.insert_contact(self.contact)
        self.marionette.refresh()
示例#28
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # insert contact
        self.contact = MockContact()
        self.data_layer.insert_contact(self.contact)

        # remove vcf files from sdcard
        for filename in self.data_layer.sdcard_files('.vcf'):
            self.device.manager.removeFile(filename)
示例#29
0
class TestReceiveCallWithContactPhoto(GaiaTestCase):
    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest(
                'Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        with open(self.resource('IMG_0001.jpg'), 'rb') as f:
            encoded_string = base64.b64encode(f.read())

        self.contact = MockContact()
        self.contact.update(photo='%s' % encoded_string,
                            tel={
                                'type': 'Mobile',
                                'value': self.testvars['plivo']['phone_number']
                            })
        self.data_layer.insert_contact(self.contact)

    def test_dialer_receive_call_with_contact_photo(self):
        """
        https://moztrap.mozilla.org/manage/case/1544/
        """
        PLIVO_TIMEOUT = 30

        from gaiatest.utils.plivo.plivo_util import PlivoUtil
        self.plivo = PlivoUtil(self.testvars['plivo']['auth_id'],
                               self.testvars['plivo']['auth_token'],
                               self.testvars['plivo']['phone_number'])
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['local_phone_numbers'][0].replace('+', ''),
            timeout=PLIVO_TIMEOUT)

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call()
        self.assertIn('background-image:',
                      call_screen.contact_background_style)

    def tearDown(self):
        self.plivo.hangup_call(self.call_uuid)
        GaiaTestCase.tearDown(self)
    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()
示例#31
0
    def setUp(self):
        GaiaTestCase.setUp(self)
        self.connect_to_local_area_network()

        try:
            self.testvars['facebook']
        except KeyError:
            raise SkipTest('Facebook account details not present in test variables')

        self.contact = MockContact()
        self.data_layer.insert_contact(self.contact)
示例#32
0
    def setUp(self):
        GaiaTestCase.setUp(self)

        # Seed the contact with the remote phone number so we don't call random people
        self.contact = MockContact(tel={
            'type': 'Mobile',
            'value': "%s" % self.testvars['remote_phone_number']})
        self.data_layer.insert_contact(self.contact)

        # launch the Contacts app
        self.app = self.apps.launch('Contacts')
        self.wait_for_element_not_displayed(*self._loading_overlay)
class TestReceiveCallWithContactPhoto(GaiaTestCase):

    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest('Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        with open(self.resource('IMG_0001.jpg'), 'rb') as f:
            encoded_string = base64.b64encode(f.read())

        self.contact = MockContact()
        self.contact.update(photo='%s' % encoded_string,
                            tel={'type': 'Mobile', 'value': self.testvars['plivo']['phone_number']})
        self.data_layer.insert_contact(self.contact)

    def test_dialer_receive_call_with_contact_photo(self):
        """
        https://moztrap.mozilla.org/manage/case/1544/
        """
        PLIVO_TIMEOUT = 30

        from gaiatest.utils.plivo.plivo_util import PlivoUtil
        self.plivo = PlivoUtil(
            self.testvars['plivo']['auth_id'],
            self.testvars['plivo']['auth_token'],
            self.testvars['plivo']['phone_number']
        )
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['local_phone_numbers'][0].replace('+', ''),
            timeout=PLIVO_TIMEOUT)

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call()
        self.assertIn('background-image:', call_screen.contact_background_style)

    def tearDown(self):
        self.plivo.hangup_call(self.call_uuid)
        GaiaTestCase.tearDown(self)
    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest('Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.contact.update(tel={
            'type': 'Mobile',
            'value': self.testvars['plivo']['phone_number']}
        )
        self.data_layer.insert_contact(self.contact)
    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest('Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        with open(self.resource('IMG_0001.jpg'), 'rb') as f:
            encoded_string = base64.b64encode(f.read())

        self.contact = MockContact()
        self.contact.update(photo='%s' % encoded_string,
                            tel={'type': 'Mobile', 'value': self.testvars['plivo']['phone_number']})
        self.data_layer.insert_contact(self.contact)
class TestReceiveCallFromKnownContactNotification(GaiaTestCase):
    def setUp(self):
        try:
            self.testvars["plivo"]
        except KeyError:
            raise SkipTest("Plivo account details not present in test variables")
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.contact.update(tel={"type": "Mobile", "value": self.testvars["plivo"]["phone_number"]})
        self.data_layer.insert_contact(self.contact)

    def test_dialer_miss_call_from_known_contact_notification(self):
        """
        https://moztrap.mozilla.org/manage/case/9294/
        """
        self.device.lock()

        from gaiatest.utils.plivo.plivo_util import PlivoUtil

        self.plivo = PlivoUtil(
            self.testvars["plivo"]["auth_id"],
            self.testvars["plivo"]["auth_token"],
            self.testvars["plivo"]["phone_number"],
        )
        self.call_uuid = self.plivo.make_call(to_number=self.environment.phone_numbers[0].replace("+", ""))

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call()

        self.plivo.hangup_call(self.call_uuid)
        self.plivo.wait_for_call_completed(self.call_uuid)
        self.call_uuid = None

        lock_screen = LockScreen(self.marionette)
        lock_screen.switch_to_frame()
        lock_screen.wait_for_notification()

        # Check if the screen is turned on
        self.assertTrue(self.device.is_screen_enabled)

        # Verify the user sees a missed call notification message
        # and the known contacts info is shown.
        self.assertTrue(lock_screen.notifications[0].is_visible)
        self.assertEqual(lock_screen.notifications[0].title, "Missed call")
        self.assertTrue(self.contact.givenName in lock_screen.notifications[0].content)

        self.device.unlock()

        system = System(self.marionette)
        system.wait_for_notification_toaster_not_displayed()

        # Expand the notification bar
        system.wait_for_status_bar_displayed()
        utility_tray = system.open_utility_tray()
        utility_tray.wait_for_notification_container_displayed()

        # Verify the user sees the missed call event in the notification center
        # and the known contacts info is shown.
        notifications = utility_tray.notifications
        self.assertEqual(notifications[0].title, "Missed call")
        self.assertTrue(self.contact.givenName in notifications[0].content)

    def tearDown(self):
        # Switch back to main frame before Marionette loses track bug #840931
        self.marionette.switch_to_frame()

        # In case an assertion fails this will still kill the call
        # An open call creates problems for future tests
        self.data_layer.kill_active_call()

        # Also ask Plivo to kill the call if needed
        if self.call_uuid:
            self.plivo.hangup_call(self.call_uuid)

        GaiaTestCase.tearDown(self)
class TestReceiveCallFromKnownContactNotification(GaiaTestCase):

    def setUp(self):
        try:
            self.testvars['plivo']
        except KeyError:
            raise SkipTest('Plivo account details not present in test variables')
        GaiaTestCase.setUp(self)

        self.contact = MockContact()
        self.contact.update(tel={
            'type': 'Mobile',
            'value': self.testvars['plivo']['phone_number']}
        )
        self.data_layer.insert_contact(self.contact)

    def test_dialer_miss_call_from_known_contact_notification(self):
        """
        https://moztrap.mozilla.org/manage/case/9294/
        """
        PLIVO_TIMEOUT = 30

        self.device.lock()

        from gaiatest.utils.plivo.plivo_util import PlivoUtil
        self.plivo = PlivoUtil(
            self.testvars['plivo']['auth_id'],
            self.testvars['plivo']['auth_token'],
            self.testvars['plivo']['phone_number']
        )
        self.call_uuid = self.plivo.make_call(
            to_number=self.testvars['carrier']['phone_number'].replace('+', ''),
            timeout=PLIVO_TIMEOUT)

        call_screen = CallScreen(self.marionette)
        call_screen.wait_for_incoming_call_with_locked_screen()
        self.plivo.hangup_call(self.call_uuid)
        self.call_uuid = None

        # Verify the user sees a missed call notification message
        # and the known contacts info is shown.
        system = System(self.marionette)
        self.marionette.switch_to_frame()
        system.wait_for_notification_toaster_displayed()
        lock_screen = LockScreen(self.marionette)
        notifications = lock_screen.notifications
        self.assertEqual(notifications[0].title, 'Missed call')
        self.assertTrue(self.contact.givenName in notifications[0].content)
        system.wait_for_notification_toaster_not_displayed()

        # Verify the user sees the missed call event in the notification center
        # and the known contacts info is shown.
        self.device.unlock()
        system.wait_for_status_bar_displayed()
        utility_tray = system.open_utility_tray()
        utility_tray.wait_for_notification_container_displayed()
        notifications = utility_tray.notifications
        self.assertEqual(notifications[0].title, 'Missed call')
        self.assertTrue(self.contact.givenName in notifications[0].content)

    def tearDown(self):
        # Switch back to main frame before Marionette loses track bug #840931
        self.marionette.switch_to_frame()

        # In case an assertion fails this will still kill the call
        # An open call creates problems for future tests
        self.data_layer.kill_active_call()

        # Also ask Plivo to kill the call if needed
        if self.call_uuid:
            self.plivo.hangup_call(self.call_uuid)

        GaiaTestCase.tearDown(self)