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 #25026 from chirarobert/call_log
Browse files Browse the repository at this point in the history
Bug 1075547 - Update test_call_log_all_calls to verify missed calls menu
  • Loading branch information
Florin Strugariu committed Oct 20, 2014
2 parents 6a8c2e5 + 7d13d55 commit ffc65d5
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 17 deletions.
29 changes: 21 additions & 8 deletions tests/python/gaia-ui-tests/gaiatest/apps/phone/regions/call_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from marionette.by import By
from gaiatest.apps.phone.app import Phone
from gaiatest.apps.base import PageRegion


class CallLog(Phone):
Expand All @@ -18,7 +19,8 @@ class CallLog(Phone):
_call_log_edit_select_all_button_locator = (By.ID, 'select-all-threads')

_all_calls_tab_link_locator = (By.CSS_SELECTOR, '#all-filter a')
_all_calls_list_item_locator = (By.CSS_SELECTOR, 'li.log-item')
_missed_calls_tab_link_locator = (By.CSS_SELECTOR, '#missed-filter a')
_calls_list_item_locator = (By.CSS_SELECTOR, 'li.log-item')
_all_calls_list_item_button_locator = (By.CSS_SELECTOR, 'li.log-item a')
_all_calls_list_item_checkbox_locator = (By.CSS_SELECTOR, 'li.log-item input[type="checkbox"]')

Expand All @@ -30,6 +32,9 @@ def __init__(self, marionette):
def tap_all_calls_tab(self):
self.marionette.find_element(*self._all_calls_tab_link_locator).tap()

def tap_missed_calls_tab(self):
self.marionette.find_element(*self._missed_calls_tab_link_locator).tap()

def a11y_click_all_calls_tab(self):
self.accessibility.click(self.marionette.find_element(*self._all_calls_tab_link_locator))

Expand All @@ -38,14 +43,22 @@ def is_all_calls_tab_selected(self):
return self.marionette.find_element(*self._all_calls_tab_link_locator).get_attribute('aria-selected') == 'true'

@property
def all_calls_count(self):
return len(self._all_calls)
def is_missed_calls_tab_selected(self):
return self.marionette.find_element(*self._missed_calls_tab_link_locator).get_attribute('aria-selected') == 'true'

@property
def call_list(self):
return [LogEntries(self.marionette, element)
for element in self.marionette.find_elements(*self._calls_list_item_locator)
if element.is_displayed()]


class LogEntries(PageRegion):

@property
def first_all_call_text(self):
return self._all_calls[0].text
def phone_number(self):
return self.root_element.text

# TODO: Add a subregion for each call in the call log, when we have tests that need to work with more than 1 call
@property
def _all_calls(self):
return self.marionette.find_elements(*self._all_calls_list_item_locator)
def call_type(self):
return self.root_element.get_attribute('data-type')
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def test_phone_call_log(self):
self.assertFalse(self.accessibility.is_disabled(self.marionette.find_element(
*call_log._call_log_edit_button_locator)))

call_list = call_log.call_list
# Now check that one call appears in the call log
self.assertEqual(call_log.all_calls_count, 1)
self.assertEqual(len(call_list), 1)
# Check that the call displayed is for the call we made
self.assertIn(test_phone_number, call_log.first_all_call_text)
self.assertIn(test_phone_number, call_list[0].phone_number)

call_log_first_item = self.marionette.find_elements(
*call_log._all_calls_list_item_button_locator)[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

from gaiatest import GaiaTestCase
from gaiatest.apps.phone.app import Phone
from gaiatest.apps.phone.regions.call_screen import CallScreen

from marionette import SkipTest


class TestCallLogAllCalls(GaiaTestCase):

def setUp(self):

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

GaiaTestCase.setUp(self)

# delete any existing call log entries - call log needs to be loaded
Expand All @@ -19,6 +28,7 @@ def test_call_log_all_calls(self):
"""https://moztrap.mozilla.org/manage/case/1306/"""

test_phone_number = self.testvars['remote_phone_number']
plivo_phone_number = self.testvars['plivo']['phone_number']

# Make a call so it will appear in the call log
self.phone.make_call_and_hang_up(test_phone_number)
Expand All @@ -27,23 +37,54 @@ def test_call_log_all_calls(self):
self.wait_for_condition(lambda m: self.apps.displayed_app.name == self.phone.name)
self.apps.switch_to_displayed_app()

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=30)

call_screen = CallScreen(self.marionette)
call_screen.wait_for_incoming_call()
self.plivo.hangup_call(self.call_uuid)

self.apps.switch_to_displayed_app()
call_log = self.phone.tap_call_log_toolbar_button()

# Check all calls tab
call_log.tap_all_calls_tab()

# Check that 'All calls' tab is selected
self.assertTrue(call_log.is_all_calls_tab_selected)

# Now check that one call appears in the call log
self.assertEqual(call_log.all_calls_count, 1)
call_list = call_log.call_list
self.assertEqual(len(call_list), 2)

# Check that the call displayed is for the call we made
self.assertIn(test_phone_number, call_log.first_all_call_text)
# Check that the calls displayed are for the calls we made/received
self.assertIn(plivo_phone_number, call_list[0].phone_number)
self.assertEqual('incoming', call_list[0].call_type)
self.assertIn(test_phone_number, call_list[1].phone_number)
self.assertEqual('dialing', call_list[1].call_type)

def tearDown(self):
# Check missed calls tab
call_log.tap_missed_calls_tab()
self.assertTrue(call_log.is_missed_calls_tab_selected)

call_list = call_log.call_list
self.assertEqual(len(call_list), 1)

# Check that the calls displayed are for the calls we received
self.assertIn(plivo_phone_number, call_list[0].phone_number)
self.assertEqual('incoming', call_list[0].call_type)

def tearDown(self):
# In case the 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 ffc65d5

Please sign in to comment.