1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""Test of basic calling with given digits 16 Steps include: 17 1) Precall state check on devices. (OK) 18 2) Enable the drive mode in IVI device 19 3) Send the sms to paired phone 20 4) Open the sms app 21 4) Asset the message in the sms app 22""" 23 24from utilities import constants 25from utilities.main_utils import common_main 26from utilities.common_utils import CommonUtils 27from bluetooth_sms_test import bluetooth_sms_base_test 28from mobly.controllers import android_device 29 30class UxRestrictionSMSDBTest(bluetooth_sms_base_test.BluetoothSMSBaseTest): 31 32 def setup_class(self): 33 super().setup_class() 34 self.common_utils = CommonUtils(self.target, self.discoverer) 35 36 37 def setup_test(self): 38 # pair the devices 39 self.bt_utils.pair_primary_to_secondary() 40 41 # wait for user permissions popup & give contacts and sms permissions 42 self.call_utils.wait_with_log(20) 43 self.common_utils.click_on_ui_element_with_text('Allow') 44 45 # # Clearing the sms from the phone 46 self.call_utils.clear_sms_app(self.target) 47 # Reboot Phone 48 self.target.unload_snippet('mbs') 49 self.call_utils.reboot_device(self.target) 50 self.call_utils.wait_with_log(30) 51 self.target.load_snippet('mbs', android_device.MBS_PACKAGE) 52 53 # send a new sms 54 target_phone_number = self.target.mbs.getPhoneNumber() 55 self.phone_notpaired.mbs.sendSms(target_phone_number,constants.SMS_TEXT) 56 self.call_utils.wait_with_log(10) 57 58 # set driving mode 59 self.call_utils.enable_driving_mode() 60 61 def test_call_from_dialer_during_drive_mode(self): 62 # to test that the unread sms appears on phone during drive mode 63 64 # Open the sms app 65 self.call_utils.open_sms_app() 66 67 # Perform the verifications 68 self.call_utils.verify_sms_app_unread_message(True) 69 self.call_utils.verify_sms_preview_timestamp(True) 70 self.call_utils.verify_sms_preview_text(True, constants.SMS_TEXT_DRIVE_MODE) 71 72 # Disable driving mode 73 self.call_utils.disable_driving_mode() 74 self.call_utils.wait_with_log(10) 75 self.call_utils.verify_sms_preview_text(True, constants.SMS_TEXT) 76 77 def teardown_test(self): 78 # Go to home screen 79 self.call_utils.press_home() 80 super().teardown_test() 81 82if __name__ == '__main__': 83 common_main()