From a1f9becb614f5f10218bcdbbb8c003e7a8725dec Mon Sep 17 00:00:00 2001 From: Johan Lorenzo Date: Mon, 15 Dec 2014 16:03:33 +0100 Subject: [PATCH] Bug 1109606 - Add a test to check that a miss call notification is cleared even if a voicemail notification is present --- .../gaia-ui-tests/gaiatest/gaia_test.py | 6 + .../tests/functional/dialer/manifest.ini | 3 + ...est_dialer_clear_miss_call_notification.py | 104 ++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/test_dialer_clear_miss_call_notification.py diff --git a/tests/python/gaia-ui-tests/gaiatest/gaia_test.py b/tests/python/gaia-ui-tests/gaiatest/gaia_test.py index a75a47d97f01..0598742550a2 100644 --- a/tests/python/gaia-ui-tests/gaiatest/gaia_test.py +++ b/tests/python/gaia-ui-tests/gaiatest/gaia_test.py @@ -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() diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/manifest.ini b/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/manifest.ini index 57efdd037bf7..2c92517c6057 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/manifest.ini +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/manifest.ini @@ -47,6 +47,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" diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/test_dialer_clear_miss_call_notification.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/test_dialer_clear_miss_call_notification.py new file mode 100644 index 000000000000..33a5af51eecd --- /dev/null +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/dialer/test_dialer_clear_miss_call_notification.py @@ -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)