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: 19 (0. Flash device) 20 1. Navigate to the Bluetooth settings page 21 2. Disconnect - Connect Mobile Device via Layer1 - via Bluetooth Button 22 3. Tap Device to see DisconnectedStatus in Layer2 23 4. Reconnect - Via layer 1 24 5. Tap device to see Connected status in Layer2 25 26 "Layer Two" represents the device-specific screen (the screen you see when clicking the device in the bluetooth settings page. 27 28""" 29 30import sys 31import logging 32import pprint 33 34from bluetooth_test import bluetooth_base_test 35 36from mobly import asserts 37from mobly import base_test 38from mobly import test_runner 39from mobly.controllers import android_device 40 41from mbs_utils import constants 42from mbs_utils import spectatio_utils 43from mbs_utils import bt_utils 44 45MOBILE_DEVICE_NAME = 'target' 46AUTOMOTIVE_DEVICE_NAME = 'discoverer' 47 48class BluetoothConnectionStatusOnLevelTwo(bluetooth_base_test.BluetoothBaseTest): 49 50 def setup_test(self): 51 # Enables BT on both devices. 52 super().setup_test() 53 # Set Bluetooth name on target device. 54 self.target.mbs.btSetName(MOBILE_DEVICE_NAME) 55 56 self.bt_utils.pair_primary_to_secondary() 57 self.call_utils.wait_with_log(constants.DEVICE_CONNECT_WAIT_TIME) 58 59 def test_connection_status_displayed_on_device_screen(self): 60 # Open bluetooth settings. 61 self.call_utils.open_bluetooth_settings() 62 self.call_utils.wait_with_log(constants.WAIT_TWO_SECONDS) 63 64 # Find the target device and disconnect it on the Level One page 65 self.call_utils.press_bluetooth_toggle_on_device(MOBILE_DEVICE_NAME) 66 self.call_utils.wait_with_log(constants.WAIT_TWO_SECONDS) 67 68 # Click on the target device. 69 self.call_utils.press_device_entry_on_list_of_paired_devices(MOBILE_DEVICE_NAME) 70 self.call_utils.wait_with_log(constants.WAIT_TWO_SECONDS) 71 72 # Confirm that target device displays "disconnected" 73 summary = self.call_utils.get_device_summary() 74 logging.info("Summary received reads: %s" % summary) 75 asserts.assert_true((constants.DISCONNECTED_SUMMARY_STATUS in summary), 76 "Expected summary to contain %s, but instead summary reads: %s" 77 % (constants.DISCONNECTED_SUMMARY_STATUS, summary)) 78 79 80if __name__ == '__main__': 81 # Take test args 82 test_runner.main()