def tearDown(self): if d.orientation != self.initial_orientation: d.orientation = self.initial_orientation d.freeze_rotation(False) if self.is_call_active2: dut_manager.activate_phone(self.phone2) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active2 = False if self.is_call_active3: dut_manager.activate_phone(self.phone3) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active3 = False if self.is_call_active4: dut_manager.activate_phone(self.phone4) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active3 = False for phone in [self.phone1, self.phone2, self.phone3, self.phone4]: LOG.info('Cleaning up for %s.' % phone) dut_manager.activate_phone(phone) UiAutomatorUtils.close_all_tasks() StatusBar.open_notifications() StatusBar.clear_notifications() d.press.home()
def tearDown(self): if d.orientation != self.initial_orientation: d.orientation = self.initial_orientation d.freeze_rotation(False) if self.is_call_active: dut_manager.activate_phone(self.phone1) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active = False
def tearDown(self): if d.orientation != self.initial_orientation: d.orientation = self.initial_orientation d.freeze_rotation(False) if self.is_ussd_open: dut_manager.activate_phone(self.phone1) Dialer.close_ussd() self.is_ussd_open = False if self.is_call_active2: dut_manager.activate_phone(self.phone2) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active2 = False if self.is_call_active3: dut_manager.activate_phone(self.phone3) self.assertTrue(Dialer.end_call(), 'Failed to end call in cleanup.') self.is_call_active3 = False if self.is_call_waiting_disabled: dut_manager.activate_phone(self.phone1) Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') self.assertTrue( Dialer.dial_number(self.activate_call_waiting_nr), 'Failed to activate call waiting using code (%s) in cleanup.' % self.activate_call_waiting_nr) self.assertTrue(Dialer.is_ussd_open(), 'USSD popup not open.') self.assertTrue(Dialer.close_ussd(), 'Failed to close ussd popup.') self.is_call_waiting_disabled = False for phone in [self.phone1, self.phone2, self.phone3]: LOG.info('Cleaning up for %s.' % phone) dut_manager.activate_phone(phone) UiAutomatorUtils.close_all_tasks() StatusBar.open_notifications() StatusBar.clear_notifications() d.press.home()
def test_call_wait_third_call_management(self): """ ST_TELEPHONY_SS_CW_009 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Activate call waiting using menu.') self.assertTrue(Dialer.enable_call_waiting(), 'Failed to activate call waiting using menu.') LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number)) LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Accept incoming call from %s.' % self.phone3_number) self.assertTrue( Dialer.answer_incoming_call(self.phone3_number), 'Failed to accept incoming call from %s' % self.phone3_number) LOG.info('Check that call with %s is active.' % self.phone3_number) self.assertTrue(Dialer.is_call_active(self.phone3_number), 'Call with %s is inactive.' % self.phone3_number) LOG.info('Check that call with %s is on hold.' % self.phone2_number) self.assertTrue(Dialer.is_call_on_hold(self.phone2_number), 'Call with %s is not on hold.' % self.phone2_number) LOG.info('Activate %s' % self.phone4) dut_manager.activate_phone(self.phone4) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone4, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active4 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) # Dismissing will redirect to voice mail LOG.info('Dismiss incoming call from %s.' % self.phone4_number) self.assertTrue( Dialer.dismiss_incoming_call(self.phone4_number), 'Failed to dismiss incoming call from %s' % self.phone4_number) LOG.info('Check that call with %s is active.' % self.phone3_number) self.assertTrue(Dialer.is_call_active(self.phone3_number), 'Call with %s is inactive.' % self.phone3_number) LOG.info('Check that call with %s is on hold.' % self.phone2_number) self.assertTrue(Dialer.is_call_on_hold(self.phone2_number), 'Call with %s is not on hold.' % self.phone2_number) LOG.info('Activate %s' % self.phone4) dut_manager.activate_phone(self.phone4) # If voice mail is active, call is redirected to it # Otherwise line will be busy LOG.info( 'Check if call is active with %s (redirected to voice mail).' % self.phone1_number) if Dialer.is_call_active(self.phone1_number): LOG.info('Call was redirected to voice mail.') LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) else: LOG.info('Line was busy.') self.is_call_active4 = False LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info( 'A message is sent to PHONE1 (missed calls). Will close the notifications.' ) StatusBar.open_notifications() self.assertTrue(StatusBar.close_notifications(), 'Failed to close notification.') LOG.info('Activate %s' % self.phone4) dut_manager.activate_phone(self.phone4) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone4, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active4 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Accept incoming call from %s.' % self.phone4_number) # This will end call with PHONE2 and leave PHONE4 still dialing self.assertFalse( Dialer.answer_incoming_call(self.phone4_number), 'Answered incoming call from %s from the first try.' % self.phone4_number) self.is_call_active2 = False # This will actually answer incoming call from PHONE4 self.assertTrue( Dialer.answer_incoming_call(self.phone4_number), 'Failed to accept incoming call from %s' % self.phone4_number) LOG.info('Check that call with %s is active.' % self.phone4_number) self.assertTrue(Dialer.is_call_active(self.phone4_number), 'Call with %s is inactive.' % self.phone4_number) LOG.info('Check that call with %s is on hold.' % self.phone3_number) self.assertTrue(Dialer.is_call_on_hold(self.phone3_number), 'Call with %s is not on hold.' % self.phone3_number) LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active3 = False LOG.info('Activate %s' % self.phone4) dut_manager.activate_phone(self.phone4) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active4 = False
def test_call_wait_using_code_43(self): """ ST_TELEPHONY_SS_CW_001 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Activate call waiting using code (%s).' % self.activate_call_waiting_nr) self.assertTrue( Dialer.dial_number(self.activate_call_waiting_nr), 'Failed to activate call waiting using code (%s).' % self.activate_call_waiting_nr) LOG.info('Check that USSD popup is open.') self.assertTrue(Dialer.is_ussd_open(), 'USSD popup not open.') self.is_ussd_open = True LOG.info('Get USSD message.') msg = Dialer.get_ussd_message() LOG.info('Found msg: %s' % msg) LOG.info('Close USSD popup.') self.assertTrue(Dialer.close_ussd(), 'Failed to close ussd popup.') self.is_ussd_open = False service_enabled_msg = 'Call waiting\nService was enabled.' LOG.info( 'Check that USSD msg indicate that service has been activated.') self.assertEqual( msg, service_enabled_msg, 'Found "%s" instead of "%s"' % (msg, service_enabled_msg)) LOG.info('Interrogate call waiting using code (%s).' % self.interrogate_call_waiting_nr) self.assertTrue( Dialer.dial_number(self.interrogate_call_waiting_nr), 'Failed to interrogate call waiting using code (%s).' % self.interrogate_call_waiting_nr) LOG.info('Check that USSD popup is open.') self.assertTrue(Dialer.is_ussd_open(), 'USSD popup not open.') self.is_ussd_open = True LOG.info('Get USSD message.') msg = Dialer.get_ussd_message() LOG.info('Found msg: %s' % msg) LOG.info('Close USSD popup.') self.assertTrue(Dialer.close_ussd(), 'Failed to close ussd popup.') self.is_ussd_open = False service_interrogate_msg = 'Call waiting\nService was enabled for:\nVoice\nSync' LOG.info( 'Check that USSD msg indicate that service has been activated.') self.assertEqual( msg, service_interrogate_msg, 'Found "%s" instead of "%s"' % (msg, service_interrogate_msg)) LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number)) LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check that there is an incoming call from %s' % self.phone3_number) self.assertTrue(Dialer.check_incoming_call(self.phone3_number), 'No incoming call from %s.' % self.phone3_number) LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active3 = False LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active2 = False LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Deactivate call waiting using code (%s).' % self.deactivate_call_waiting_nr) self.assertTrue( Dialer.dial_number(self.deactivate_call_waiting_nr), 'Failed to deactivate call waiting using code (%s).' % self.deactivate_call_waiting_nr) self.is_call_waiting_disabled = True LOG.info('Check that USSD popup is open.') self.assertTrue(Dialer.is_ussd_open(), 'USSD popup not open.') self.is_ussd_open = True LOG.info('Get USSD message.') msg = Dialer.get_ussd_message() LOG.info('Found msg: %s' % msg) LOG.info('Close USSD popup.') self.assertTrue(Dialer.close_ussd(), 'Failed to close ussd popup.') self.is_ussd_open = False service_disabled_msg = 'Call waiting\nService has been disabled.' LOG.info( 'Check that USSD msg indicate that service has been disabled.') self.assertEqual( msg, service_disabled_msg, 'Found "%s" instead of "%s"' % (msg, service_disabled_msg)) LOG.info('Interrogate call waiting using code (%s).' % self.interrogate_call_waiting_nr) self.assertTrue( Dialer.dial_number(self.interrogate_call_waiting_nr), 'Failed to interrogate call waiting using code (%s).' % self.interrogate_call_waiting_nr) LOG.info('Check that USSD popup is open.') self.assertTrue(Dialer.is_ussd_open(), 'USSD popup not open.') self.is_ussd_open = True LOG.info('Get USSD message.') msg = Dialer.get_ussd_message() LOG.info('Found msg: %s' % msg) LOG.info('Close USSD popup.') self.assertTrue(Dialer.close_ussd(), 'Failed to close ussd popup.') self.is_ussd_open = False service_interrogate_msg = service_disabled_msg LOG.info( 'Check that USSD msg indicate that service has been disabled.') self.assertEqual( msg, service_interrogate_msg, 'Found "%s" instead of "%s"' % (msg, service_interrogate_msg)) LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number)) LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check that there is no incoming call from %s' % self.phone3_number) self.assertFalse(Dialer.check_incoming_call(self.phone3_number), 'Found incoming call from %s.' % self.phone3_number) LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) # If voice mail is active, call is redirected to it # Otherwise line will be busy LOG.info( 'Check if call is active with %s (redirected to voice mail).' % self.phone1_number) if Dialer.is_call_active(self.phone1_number): LOG.info('Call was redirected to voice mail.') LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) else: LOG.info('Line was busy.') self.is_call_active3 = False LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active2 = False
def test_call_wait_back_to_back_incoming_call_accepted(self): """ ST_TELEPHONY_SS_CW_008 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Activate call waiting using menu.') self.assertTrue(Dialer.enable_call_waiting(), 'Failed to activate call waiting using menu.') LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number)) LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) for i in range(5): LOG.info('Iteration: %s' % i) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Accept incoming call from %s.' % self.phone3_number) self.assertTrue( Dialer.answer_incoming_call(self.phone3_number), 'Failed to accept incoming call from %s' % self.phone3_number) LOG.info('Check that call with %s is active.' % self.phone3_number) self.assertTrue(Dialer.is_call_active(self.phone3_number), 'Call with %s is inactive.' % self.phone3_number) LOG.info('Check that call with %s is on hold.' % self.phone2_number) self.assertTrue( Dialer.is_call_on_hold(self.phone2_number), 'Call with %s is not on hold.' % self.phone2_number) LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active3 = False LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check that call with %s is still on hold.' % self.phone2_number) self.assertTrue( Dialer.is_call_on_hold(self.phone2_number), 'Call with %s is not on hold.' % self.phone2_number) LOG.info('Resume call with %s.' % self.phone2_number) self.assertTrue(Dialer.resume_call(), 'Failed to resume call.') LOG.info('End call with %s.' % self.phone2_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone2_number) self.is_call_active2 = False
def test_call_wait_incoming_call_ignored(self): """ ST_TELEPHONY_SS_CW_004 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Activate call waiting using menu.') self.assertTrue(Dialer.enable_call_waiting(), 'Failed to activate call waiting using menu.') LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number)) LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Dismiss incoming call from %s.' % self.phone3_number) self.assertTrue( Dialer.dismiss_incoming_call(self.phone3_number), 'Failed to dismiss incoming call from %s' % self.phone3_number) LOG.info('Check that there is no indication of incoming call from %s' % self.phone3_number) self.assertFalse( Dialer.check_incoming_call(self.phone3_number), 'Still found indication of incoming call from %s.' % self.phone3_number) LOG.info('Check if call is still active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) # If voice mail is active, call is redirected to it # Otherwise line will be busy LOG.info( 'Check if call is active with %s (redirected to voice mail).' % self.phone1_number) if Dialer.is_call_active(self.phone1_number): LOG.info('Call was redirected to voice mail.') LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) else: LOG.info('Line was busy.') self.is_call_active3 = False LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('End call with %s.' % self.phone1_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone1_number) self.is_call_active2 = False
def test_import_one_contact_from_sim(self): """ TestCaseID: ST_TELEPHONY_SIM_PB_001 TestDefinition: Phonebook - Import one contact from SIM to phonebook TestPurpose: To ensure that user can import a contact from the SIM phonebook to the device phonebook TestEnvironment: Cellular live simulator testing InitialState: DUT is in Idle mode, SIM inserted; SIM is filled with contacts. ExpectedResult: Contact is successfully imported from SIM phonebook. """ LOG.info('Open Contacts app.') ret = Contacts.launch() if not ret: # When opened for the first time the 'Add your account' window pops up if Contacts.is_add_your_account_open(): LOG.info("'Add your account' window popped up.") d.press.back() LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Failed to launch the Contacts app.') LOG.info('Get all contacts from Contacts app.') all_contacts = Contacts.get_all_contacts() if not all_contacts: LOG.info('No contacts found in PhoneBook.') LOG.info('Open Import from sim card (button).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (button).') else: LOG.info('Found some contacts in PhoneBook.') LOG.info('Open More Options menu.') ret = Contacts.open_more_options_menu() self.assertTrue(ret, 'Failed to open More Options menu.') LOG.info('Open Import/export contacts popup.') ret = Contacts.open_import_export_contacts_popup() self.assertTrue(ret, 'Failed to open Import/export contacts popup.') LOG.info('Open Import from sim card (menu).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (menu).') LOG.info( 'Check that the Phone app (Select contacts to import ..) is open.') ret = Dialer.is_import_from_sim_open() self.assertTrue( ret, 'Phone app (Select contacts to import ..) was not open.') LOG.info('Get all contacts from sim card.') sim_contacts = Dialer.get_all_contacts_from_sim() self.assertNotEqual(0, len(sim_contacts), 'No contacts found on the sim card.') contact = choice(sim_contacts) LOG.info('Get a random contact from sim card: %s' % contact) LOG.info( 'Verify contact %s is not already present in PhoneBook before importing.' % contact) # When importing contacts, the '.' is replaced with ' ' fixed_contact = contact.replace('.', ' ') self.assertNotIn(fixed_contact, all_contacts) LOG.info('Import contact %s from sim card.' % contact) ret = Dialer.import_contact_from_sim(contact) self.assertTrue(ret, 'Failed to import contact %s from sim.' % contact) LOG.info('Go back to Contacts app (by pressing back).') d.press.back() self.contacts_to_delete.append(fixed_contact) LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Contacts app is not open.') LOG.info('Verify if contact %s was successfully imported.' % contact) ret = Contacts.get_contact(fixed_contact) self.assertIsNotNone( ret, 'Failed to find contact %s in phonebook after import.' % contact)
def test_import_contacts_from_sim_flight_mode_on(self): """ TestCaseID: ST_TELEPHONY_REG_FlightMode_117 TestDefinition: Flight Mode ON - Import contacts stored on the SIM card not allowed TestPurpose: The purpose is to check that it is not possible to import contacts stored in the SIM card when the flight mode is activated. TestEnvironment: Configuration1 : Cellular live network testing InitialState: - Flight mode is set to on. - One (or more) contacts are stored into SIM card. ExpectedResult: Import contacts stored on the SIM card not allowed in Flight Mode """ LOG.info('Open Notifications.') StatusBar.open_notifications(2) LOG.info('Set Flight mode to ON') ret = StatusBar.toggle_airplane_mode('ON') self.assertTrue(ret, 'Failed to set Flight mode to ON.') self.flight_mode = True StatusBar.close_notifications() LOG.info('Open Contacts app.') ret = Contacts.launch() if not ret: # When opened for the first time the 'Add your account' window pops up if Contacts.is_add_your_account_open(): LOG.info("'Add your account' window popped up.") d.press.back() LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Failed to launch the Contacts app.') LOG.info('Get all contacts from Contacts app.') all_contacts = Contacts.get_all_contacts() if not all_contacts: LOG.info('No contacts found in PhoneBook.') LOG.info('Open Import from sim card (button).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (button).') else: LOG.info('Found some contacts in PhoneBook.') LOG.info('Open More Options menu.') ret = Contacts.open_more_options_menu() self.assertTrue(ret, 'Failed to open More Options menu.') LOG.info('Open Import/export contacts popup.') ret = Contacts.open_import_export_contacts_popup() self.assertTrue(ret, 'Failed to open Import/export contacts popup.') LOG.info('Open Import from sim card (menu).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (menu).') LOG.info( 'Check that the Phone app (Select contacts to import ..) is open.') ret = Dialer.is_import_from_sim_open() self.assertTrue( ret, 'Phone app (Select contacts to import ..) was not open.') LOG.info('Get all contacts from sim card.') sim_contacts = Dialer.get_all_contacts_from_sim() self.assertNotEqual(0, len(sim_contacts), 'No contacts found on the sim card.') contact = choice(sim_contacts) LOG.info('Get a random contact from sim card: %s' % contact) LOG.info( 'Verify contact %s is not already present in PhoneBook before importing.' % contact) # When importing contacts, the '.' is replaced with ' ' fixed_contact = contact.replace('.', ' ') self.assertNotIn(fixed_contact, all_contacts) # NOTE: I managed to import a contact from sim with FlightMode ON # I cannot reproduce the expected behaviour # This step should fail? LOG.info('Try to import contact %s from sim card.' % contact) ret = Dialer.import_contact_from_sim(contact) self.assertTrue(ret, 'Failed to import contact %s from sim.' % contact) LOG.info('Go back to Contacts app (by pressing back).') d.press.back() self.contacts_to_delete.append(fixed_contact) LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Contacts app is not open.') LOG.info('Verify contact %s was not imported.' % contact) ret = Contacts.get_contact(fixed_contact) self.contacts_to_delete = [] if not ret else self.contacts_to_delete self.assertIsNone( ret, 'Found contact %s in phonebook after import.' % contact) # The other steps are already covered in ST_TELEPHONY_SIM_PB_001 # 2. Disable Airplane mode and wait for the DUT register on its HPLMN # --> Check that the DUT is correctly registered to on its HPLMN # 3. From DUT menu, try to import contacts stored in the SIM card to DUT phone book # --> Check that we can import contacts from the SIM card. LOG.info('Open Notifications.') StatusBar.open_notifications(2) LOG.info('Set Flight mode to OFF') ret = StatusBar.toggle_airplane_mode('OFF') self.assertTrue(ret, 'Failed to set Flight mode to OFF.') self.flight_mode = False StatusBar.close_notifications() self.test_import_one_contact_from_sim()
def test_import_all_contacts_from_sim(self): """ TestCaseID: ST_TELEPHONY_SIM_PB_002 TestDefinition: Phonebook - Import all contacts from SIM to phonebook TestPurpose: To ensure that user can import all contacts from the SIM phonebook to the device phonebook TestEnvironment: Cellular live simulator testing InitialState: DUT is in Idle mode, SIM inserted; SIM is filled with at least 50 contacts. ExpectedResult: SIM phonebook is successfully imported. """ LOG.info('Open Contacts app.') ret = Contacts.launch() if not ret: # When opened for the first time the 'Add your account' window pops up if Contacts.is_add_your_account_open(): LOG.info("'Add your account' window popped up.") d.press.back() LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Failed to launch the Contacts app.') LOG.info('Get all contacts from Contacts app.') all_contacts = Contacts.get_all_contacts() if not all_contacts: LOG.info('No contacts found in PhoneBook.') LOG.info('Open Import from sim card (button).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (button).') else: LOG.info('Found some contacts in PhoneBook.') LOG.info('Open More Options menu.') ret = Contacts.open_more_options_menu() self.assertTrue(ret, 'Failed to open More Options menu.') LOG.info('Open Import/export contacts popup.') ret = Contacts.open_import_export_contacts_popup() self.assertTrue(ret, 'Failed to open Import/export contacts popup.') LOG.info('Open Import from sim card (menu).') ret = Contacts.open_import_from_sim_card() self.assertTrue(ret, 'Failed to open Import from sim card (menu).') LOG.info( 'Check that the Phone app (Select contacts to import ..) is open.') ret = Dialer.is_import_from_sim_open() self.assertTrue( ret, 'Phone app (Select contacts to import ..) was not open.') LOG.info('Get all contacts from sim card.') sim_contacts = Dialer.get_all_contacts_from_sim() self.assertNotEqual(0, len(sim_contacts), 'No contacts found on the sim card.') # When importing contacts, the '.' is replaced with ' ' fixed_sim_contacts = [c.replace('.', ' ') for c in sim_contacts] LOG.info( 'Verify none of the sim contacts are already in the PhoneBook.') self.assertEqual( 0, len(set(fixed_sim_contacts).intersection(set(all_contacts))), 'Found contacts from sim card already in the PhoneBook.') LOG.info('Import all contacts from sim card.') ret = Dialer.import_all_contacts_from_sim() self.assertTrue(ret, 'Failed to import all contacts from sim card.') LOG.info('Check that Contacts app is open.') ret = Contacts.is_contacts_open() self.assertTrue(ret, 'Contacts app is not open.') LOG.info('Get all contacts from Contacts app.') all_contacts = Contacts.get_all_contacts() self.contacts_to_delete.extend(fixed_sim_contacts) LOG.info('Verify if all sim contacts were successfully imported.') for c in fixed_sim_contacts: self.assertIn(c, all_contacts, 'Contact %s was not successfully imported.' % c)
def test_back_to_back_voice_call_hold_unhold(self): """ ST_TELEPHONY_SS_CH_005 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number), 'Failed to initiate call.') self.is_call_active = True LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active.') self.assertTrue(Dialer.is_call_active(), 'Call is inactive.') LOG.info('Put call hold/unhold 100 times.') for i in xrange(100): LOG.info('Iteration #%s' % i) LOG.info('Put call on hold.') self.assertTrue(Dialer.hold_call(), 'Failed to put call on hold.') LOG.info('Check that call is on hold.') self.assertTrue(Dialer.is_call_on_hold(), 'Call is not on hold.') LOG.info('Resume call.') self.assertTrue(Dialer.resume_call(), 'Failed to resume call.') LOG.info('Check that call is not on hold anymore.') self.assertFalse(Dialer.is_call_on_hold(), 'Call is still on hold.') LOG.info('End call.') self.assertTrue(Dialer.end_call(), 'Failed to end call.') self.is_call_active = False
def test_resume_call_in_hold_after_releasing_active_call(self): """ ST_TELEPHONY_SS_CH_002 """ LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone1, self.phone2)) self.assertTrue(Dialer.dial_number(self.phone2_number), 'Failed to initiate call.') LOG.info('Activate %s' % self.phone2) dut_manager.activate_phone(self.phone2) LOG.info('Answer incoming call.') Dialer.answer_call() # I wish I could do an assert here self.is_call_active2 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Check if call is active with %s.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number), 'Call is inactive.') LOG.info('Activate %s' % self.phone3) dut_manager.activate_phone(self.phone3) LOG.info('Launch Dialer.') Dialer.launch() self.assertTrue(Dialer.dialer_launched(), 'Dialer failed to launch.') LOG.info('Initiate a call from %s to %s.' % (self.phone3, self.phone1)) self.assertTrue(Dialer.dial_number(self.phone1_number), 'Failed to initiate call.') self.is_call_active3 = True LOG.info('Activate %s' % self.phone1) dut_manager.activate_phone(self.phone1) LOG.info('Answer incoming call from %s.' % self.phone3_number) self.assertTrue( Dialer.answer_incoming_call(self.phone3_number), 'Failed to answer incoming call from %s' % self.phone3_number) LOG.info('Check that call with %s is active.' % self.phone3_number) self.assertTrue(Dialer.is_call_active(self.phone3_number), 'Call with %s is inactive.' % self.phone3_number) LOG.info('Check that call with %s is on hold.' % self.phone2_number) self.assertTrue(Dialer.is_call_on_hold(self.phone2_number), 'Call with %s is not on hold.' % self.phone2_number) LOG.info('End call with %s.' % self.phone3_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone3_number) self.is_call_active3 = False LOG.info('Check that call with %s is unheld and turned active.' % self.phone2_number) self.assertTrue(Dialer.is_call_active(self.phone2_number)) LOG.info('End call with %s.' % self.phone2_number) self.assertTrue(Dialer.end_call(), 'Failed to end call with %s.' % self.phone2_number) self.is_call_active2 = False