1""" 2 Copyright (C) 2023 The Android Open Source Project 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 16 17 18 Test Steps: 191. Call to Paired Mobile Device from remote phone call 202. Verify that HUN appears to 'Accept' or 'Decline' the call 213. Tap 'Decline' to end the call 22 23""" 24 25from bluetooth_sms_test import bluetooth_sms_base_test 26import logging 27from utilities import constants 28from utilities import phone_device_utils 29from utilities.main_utils import common_main 30 31from mobly import asserts 32 33class BTDialerDeclineCall(bluetooth_sms_base_test.BluetoothSMSBaseTest): 34 35 def setup_class(self): 36 super().setup_class() 37 self.phone_utils = (phone_device_utils.PhoneDeviceUtils(self.phone_notpaired)) 38 39 def setup_test(self): 40 # Pair the devices 41 self.bt_utils.pair_primary_to_secondary() 42 super().enable_recording() 43 44 45 def test_reject_incoming_call(self): 46 # setup phones 47 # call from the unpaired phone to the paired phone 48 callee_number = self.target.mbs.getPhoneNumber() 49 self.phone_utils.call_number_from_home_screen(callee_number) 50 self.call_utils.wait_with_log(constants.DEFAULT_WAIT_TIME_FIFTEEN_SECS) 51 52 # Confirm the 'Decline' call button is onscreen 53 asserts.assert_true( 54 self.discoverer.mbs.hasUIElementWithText(constants.DECLINE_CALL_TEXT), 55 "Expected \'Decline\' button to be in HU while call was incoming, but found none.") 56 57 # reject the call 58 self.discoverer.mbs.clickUIElementWithText(constants.DECLINE_CALL_TEXT) 59 self.call_utils.wait_with_log(constants.WAIT_FOR_LOAD) 60 61 # Confirm that no call is ongoing 62 asserts.assert_false( 63 self.discoverer.mbs.isOngoingCallDisplayedOnHome(), 64 "Expected no ongoing call to be displayed on home after Declining call, but found one." 65 ) 66 67 def teardown_test(self): 68 # End call if test failed 69 self.call_utils.end_call_using_adb_command(self.phone_notpaired) 70 super().teardown_test() 71 72if __name__ == '__main__': 73 common_main()