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 #26841 from JohanLorenzo/bug-1109606-second-try
Browse files Browse the repository at this point in the history
Bug 1109606 - Add a test to check that a miss call notification is clear...
  • Loading branch information
phoenix1moz committed Dec 17, 2014
2 parents 063542f + a1f9bec commit a7cdad9
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/python/gaia-ui-tests/gaiatest/gaia_test.py
Expand Up @@ -420,6 +420,12 @@ def send_sms(self, number, message):
result = self.marionette.execute_async_script('return GaiaDataLayer.sendSMS(%s, %s)' % (number, message), special_powers=True)
assert result, 'Unable to send SMS to recipient %s with text %s' % (number, message)

def add_notification(self, title, options=None):
self.marionette.execute_script('new Notification("%s", %s);' % (title, json.dumps(options)))

def clear_notifications(self):
self.marionette.execute_script('window.wrappedJSObject.NotificationScreen.clearAll();')

@property
def current_audio_channel(self):
self.marionette.switch_to_frame()
Expand Down
Expand Up @@ -49,6 +49,9 @@ skip-if = device == "desktop"
[test_dialer_miss_call_from_known_contact_notification.py]
skip-if = device == "desktop"

[test_dialer_miss_call_notification_is_cleared_even_if_voicemail_notification_is_present.py]
skip-if = device == "desktop"

[test_dialer_receive_call_with_contact_photo.py]
skip-if = device == "desktop"

Expand Down
@@ -0,0 +1,104 @@
# 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 marionette.wait import Wait

from gaiatest import GaiaTestCase
from gaiatest.apps.phone.regions.call_screen import CallScreen
from gaiatest.apps.system.app import System
from gaiatest.apps.lockscreen.app import LockScreen
from gaiatest.mocks.mock_contact import MockContact


class TestDialerClearMissCallNotification(GaiaTestCase):

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

# We mock the voicemail notification as we have no way to clear a real voicemail after this test
self.data_layer.add_notification('Voicemail', {
"body": "Dial some number",
"icon": "app://system.gaiamobile.org/style/icons/voicemail.png",
"tag": "voicemailNotification:0"
})

def test_dialer_clear_miss_call_notification(self):
"""
Pre-requisites:
Have a voicemail in the notification bar and a missed call notification
Repro Steps:
1) Open the notification panel and tap the missed call notification.
2) After the call log appears, drop down the notification panel again.
3) The notification for the call that was just tapped is no longer present.
"""
PLIVO_TIMEOUT = 30
plivo_phone_number = self.testvars['plivo']['phone_number']

# Create a missed call notification
from gaiatest.utils.plivo.plivo_util import PlivoUtil
self.plivo = PlivoUtil(
self.testvars['plivo']['auth_id'],
self.testvars['plivo']['auth_token'],
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.plivo.hangup_call(self.call_uuid)

Wait(self.plivo, timeout=PLIVO_TIMEOUT).until(
lambda p: p.is_call_completed(self.call_uuid),
message="Plivo didn't report the call as completed")
self.call_uuid = None

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

# Open the notification panel
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
notifications = utility_tray.notifications
self.assertEqual(len(notifications), 2)
self.assertEqual(notifications[0].title, 'Missed call')
# Remove the first digit (country code) which is not displayed for AT&T/USA - Bug 1088756
self.assertTrue(plivo_phone_number[1:] in notifications[0].content)
self.assertEqual(notifications[1].title, 'Voicemail')

notifications[0].tap_notification()

self.marionette.switch_to_frame()
system.open_utility_tray()
notifications = utility_tray.notifications
self.assertEqual(len(notifications), 1)
self.assertEqual(notifications[0].title, 'Voicemail')

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)

self.data_layer.clear_notifications()

GaiaTestCase.tearDown(self)

0 comments on commit a7cdad9

Please sign in to comment.