# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette_driver import expected, By, Wait
from gaiatest.apps.base import Base
[docs]class Phone(Base):
name = "Phone"
entry_point = "dialer"
manifest_url = '{}communications{}/manifest.webapp'.format(Base.DEFAULT_PROTOCOL,Base.DEFAULT_APP_HOSTNAME)
_dialog_locator = (By.ID, 'confirmation-message')
_dialog_title_locator = (By.XPATH, "//*[@id='confirmation-message']/section/h1")
_call_log_toolbar_button_locator = (By.ID, 'option-recents')
_call_log_toolbar_locator = (By.ID, 'recents-panel')
_contacts_view_locator = (By.ID, 'option-contacts')
_keypad_toolbar_button_locator = (By.ID, 'option-keypad')
_keypad_toolbar_locator = (By.ID, 'keypad-panel')
_call_group_menu_locator = (By.CLASS_NAME, 'call-group-menu')
_cancel_action_menu_locator = (By.ID, 'cancel-action-menu')
_contacts_toolbar_locator = (By.ID, 'iframe-contacts-container')
_contacts_frame_locator = (By.ID, 'iframe-contacts')
[docs] def launch(self):
Base.launch(self)
Wait(self.marionette).until(
expected.element_displayed(*self._keypad_toolbar_button_locator))
@property
def keypad(self):
from gaiatest.apps.phone.regions.keypad import Keypad
return Keypad(self.marionette)
def _switch_to_contacts_frame(self):
# This is a nested frame and we cannot locate it with AppWindowManager
frame = Wait(self.marionette).until(
expected.element_present(*self._contacts_frame_locator))
self.marionette.switch_to_frame(frame)
from gaiatest.apps.contacts.app import Contacts
return Contacts(self.marionette)
@property
def call_screen(self):
from gaiatest.apps.phone.regions.call_screen import CallScreen
return CallScreen(self.marionette)
@property
def call_log(self):
from gaiatest.apps.phone.regions.call_log import CallLog
return CallLog(self.marionette)
@property
def confirmation_dialog_text(self):
return self.marionette.find_element(*self._dialog_title_locator).text
[docs] def wait_for_confirmation_dialog(self):
Wait(self.marionette).until(
expected.element_displayed(*self._dialog_locator))
[docs] def make_call_and_hang_up(self, phone_number):
"""Just makes a call and hangs up. Does not do any assertions."""
call_screen = self.keypad.call_number(phone_number)
call_screen.wait_for_outgoing_call()
call_screen.hang_up()
[docs] def a11y_make_call(self, phone_number):
call_screen = self.keypad.a11y_call_number(phone_number)
call_screen.wait_for_outgoing_call()
[docs] def a11y_hang_up(self):
self.call_screen.a11y_hang_up()
[docs] def a11y_make_call_and_hang_up(self, phone_number):
"""Just makes a call and hangs up using the screen reader. Does not do any assertions."""
self.a11y_make_call(phone_number)
self.a11y_hang_up()