|
| 1 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +import time |
| 6 | +try: |
| 7 | + from marionette.wait import Wait |
| 8 | +except: |
| 9 | + from marionette_driver import Wait |
| 10 | +from gaiatest import GaiaTestCase |
| 11 | +from gaiatest.apps.messages.app import Messages |
| 12 | +from gaiatest.apps.system.app import System |
| 13 | + |
| 14 | + |
| 15 | +class TestSmsNotificationRemovedWhenSMSDeleted(GaiaTestCase): |
| 16 | + |
| 17 | + def test_sms_notification_removed_when_sms_deleted(self): |
| 18 | + """ |
| 19 | + https://moztrap.mozilla.org/manage/case/8778/ |
| 20 | + """ |
| 21 | + |
| 22 | + _text_message_content = "Automated Test %s" % str(time.time()) |
| 23 | + |
| 24 | + # launch messages app |
| 25 | + messages = Messages(self.marionette) |
| 26 | + messages.launch() |
| 27 | + |
| 28 | + # Send a SMS to the device |
| 29 | + self.data_layer.send_sms(self.testvars['local_phone_numbers'][0], _text_message_content) |
| 30 | + |
| 31 | + system = System(self.marionette) |
| 32 | + |
| 33 | + # We will wait upto 300 seconds for the SMS to arrive due to network latency |
| 34 | + system.wait_for_notification_toaster_displayed(timeout=300, |
| 35 | + message="Notification did not appear. SMS database dump: %s " % self.data_layer.get_all_sms()) |
| 36 | + system.wait_for_notification_toaster_not_displayed() |
| 37 | + |
| 38 | + self.apps.switch_to_displayed_app() |
| 39 | + |
| 40 | + # Tap on the latest received SMS |
| 41 | + message_thread = messages.tap_first_received_message() |
| 42 | + Wait(self.marionette).until(lambda m: len(message_thread.received_messages) > 0) |
| 43 | + messages_number = len(message_thread.all_messages) |
| 44 | + last_received_message = message_thread.received_messages[-1] |
| 45 | + |
| 46 | + # Delete latest received SMS |
| 47 | + activities = last_received_message.long_press_message() |
| 48 | + activities.tap_delete_message() |
| 49 | + activities.confirm_delete_message() |
| 50 | + |
| 51 | + Wait(self.marionette).until(lambda m: len(message_thread.all_messages) == messages_number - 1) |
| 52 | + |
| 53 | + self.marionette.switch_to_frame() |
| 54 | + |
| 55 | + # Check that SMS notification no longer appears in utility tray |
| 56 | + utility_tray = system.open_utility_tray() |
| 57 | + self.assertEqual(0, len(utility_tray.notifications)) |
0 commit comments