Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21584 from viorelaioia/924835
Browse files Browse the repository at this point in the history
Bug 924835 - Create a test for receiving a call with a locked screen
  • Loading branch information
AndreiH committed Jul 10, 2014
2 parents 41ec15c + 18b7f73 commit 0767581
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
Expand Up @@ -2,8 +2,8 @@
# 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/.

import time
from marionette.by import By
from marionette.marionette import Actions
from gaiatest.apps.phone.app import Phone


Expand All @@ -16,6 +16,7 @@ class CallScreen(Phone):
_incoming_call_locator = (By.CSS_SELECTOR, '.handled-call.incoming')
_hangup_bar_locator = (By.ID, 'callbar-hang-up')
_answer_bar_locator = (By.ID, 'callbar-answer')
_lockscreen_handle_locator = (By.ID, 'lockscreen-area-slide')

def __init__(self, marionette):
Phone.__init__(self, marionette)
Expand Down Expand Up @@ -49,6 +50,10 @@ def wait_for_incoming_call(self):
self.wait_for_condition(lambda m: incoming_call.location['y'] == 0)
self.wait_for_condition(lambda m: self.incoming_calling_contact != u'')

def wait_for_incoming_call_with_locked_screen(self):
self.wait_for_condition(lambda m: self.is_element_displayed(*self._incoming_call_locator))
self.wait_for_condition(lambda m: self.incoming_calling_contact != u'')

def answer_call(self):
self.marionette.find_element(*self._answer_bar_locator).tap()

Expand All @@ -64,3 +69,23 @@ def a11y_hang_up(self):
self.a11y_click_hang_up()
self.marionette.switch_to_frame()
self.wait_for_element_not_displayed(*self._call_screen_locator)

def _handle_incoming_call(self, destination):

lockscreen_handle = self.marionette.find_element(*self._lockscreen_handle_locator)
lockscreen_handle_x_centre = int(lockscreen_handle.size['width'] / 2)
lockscreen_handle_y_centre = int(lockscreen_handle.size['height'] / 2)

handle_destination = lockscreen_handle.size['width']
if destination == 'reject':
handle_destination *= -1

# Flick lockscreen handle to the destination
Actions(self.marionette).flick(
lockscreen_handle, lockscreen_handle_x_centre, lockscreen_handle_y_centre, handle_destination, 0
).perform()

def reject_call(self):
self.wait_for_element_displayed(*self._lockscreen_handle_locator)
self._handle_incoming_call('reject')
self.marionette.switch_to_frame()
Expand Up @@ -25,3 +25,7 @@ skip-if = device == "desktop"
[test_dialer_receive_call.py]
smoketest = true
skip-if = device == "desktop"

[test_dialer_receive_call_with_locked_screen.py]
smoketest = true
skip-if = device == "desktop"
@@ -0,0 +1,60 @@
# 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 import SkipTest

from gaiatest import GaiaTestCase
from gaiatest.apps.phone.regions.call_screen import CallScreen
from gaiatest.utils.plivo.plivo_util import PlivoUtil


class TestReceiveCallScreenLocked(GaiaTestCase):

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

GaiaTestCase.setUp(self)

def test_receive_call_with_locked_screen(self):
"""Make a phone call from Plivo to the phone."""
PLIVO_TIMEOUT = 30
self.call_uuid = False

self.plivo = PlivoUtil(
self.testvars['plivo']['auth_id'],
self.testvars['plivo']['auth_token'],
self.testvars['plivo']['phone_number']
)

self.device.lock()
self.call_uuid = self.plivo.make_call(
to_number=self.testvars['carrier']['phone_number'].replace('+', ''),
timeout=PLIVO_TIMEOUT)

# Wait for the incoming call screen to show up
call_screen = CallScreen(self.marionette)
call_screen.wait_for_incoming_call_with_locked_screen()

# Reject the call
call_screen.reject_call()

# Check that the screen is still locked
self.assertTrue(self.device.is_locked)

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)

0 comments on commit 0767581

Please sign in to comment.