1#!/usr/bin/env python3 2# 3# Copyright (C) 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16""" 17Test script to execute Bluetooth basic functionality test cases relevant to car. 18""" 19 20from acts.test_decorators import test_tracker_info 21from acts_contrib.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 22from acts_contrib.test_utils.bt.BtEnum import BluetoothScanModeType 23from acts_contrib.test_utils.bt.bt_test_utils import check_device_supported_profiles 24from acts_contrib.test_utils.bt.bt_test_utils import log_energy_info 25from acts_contrib.test_utils.bt.bt_test_utils import reset_bluetooth 26from acts_contrib.test_utils.bt.bt_test_utils import set_device_name 27from acts_contrib.test_utils.bt.bt_test_utils import set_bt_scan_mode 28from acts_contrib.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test 29from acts_contrib.test_utils.bt.bt_test_utils import take_btsnoop_logs 30 31 32class BtCarBasicFunctionalityTest(BluetoothBaseTest): 33 default_timeout = 10 34 scan_discovery_time = 5 35 36 def setup_class(self): 37 super().setup_class() 38 self.car_ad = self.android_devices[0] 39 40 return setup_multiple_devices_for_bt_test(self.android_devices) 41 42 @test_tracker_info(uuid='b52a032a-3438-4b84-863f-c46a969882a4') 43 @BluetoothBaseTest.bt_test_wrap 44 def test_if_support_a2dp_sink_profile(self): 45 """ Test that a single device can support A2DP SNK profile. 46 Steps 47 1. Initialize one android devices 48 2. Check devices support profiles and return a dictionary 49 3. Check the value of key 'a2dp_sink' 50 :return: test_result: bool 51 """ 52 profiles = check_device_supported_profiles(self.car_ad.droid) 53 if not profiles['a2dp_sink']: 54 self.car_ad.log.debug( 55 "Android device do not support A2DP SNK profile.") 56 return False 57 return True 58 59 @test_tracker_info(uuid='3c2cb613-6c8a-4ed7-8783-37fb47bff5f2') 60 @BluetoothBaseTest.bt_test_wrap 61 def test_if_support_hfp_client_profile(self): 62 """ Test that a single device can support HFP HF profile. 63 Steps 64 1. Initialize one android devices 65 2. Check devices support profiles and return a dictionary 66 3. Check the value of key 'hfp_client' 67 :return: test_result: bool 68 """ 69 profiles = check_device_supported_profiles(self.car_ad.droid) 70 if not profiles['hfp_client']: 71 self.car_ad.log.debug( 72 "Android device do not support HFP Client profile.") 73 return False 74 return True 75 76 @test_tracker_info(uuid='c3854e74-33da-4e4d-a9cb-4f5170ef7d10') 77 @BluetoothBaseTest.bt_test_wrap 78 def test_if_support_pbap_client_profile(self): 79 """ Test that a single device can support PBAP PCE profile. 80 Steps 81 1. Initialize one android devices 82 2. Check devices support profiles and return a dictionary 83 3. Check the value of key 'pbap_client' 84 :return: test_result: bool 85 """ 86 profiles = check_device_supported_profiles(self.car_ad.droid) 87 if not profiles['pbap_client']: 88 self.car_ad.log.debug( 89 "Android device do not support PBAP Client profile.") 90 return False 91 return True 92