1#/usr/bin/env python3.4 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 20import time 21 22from queue import Empty 23from acts.test_decorators import test_tracker_info 24from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 25from acts.test_utils.bt.BtEnum import BluetoothScanModeType 26from acts.test_utils.bt.bt_test_utils import check_device_supported_profiles 27from acts.test_utils.bt.bt_test_utils import log_energy_info 28from acts.test_utils.bt.bt_test_utils import reset_bluetooth 29from acts.test_utils.bt.bt_test_utils import set_device_name 30from acts.test_utils.bt.bt_test_utils import set_bt_scan_mode 31from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test 32from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs 33 34 35class BtCarBasicFunctionalityTest(BluetoothBaseTest): 36 default_timeout = 10 37 scan_discovery_time = 5 38 39 def __init__(self, controllers): 40 BluetoothBaseTest.__init__(self, controllers) 41 self.car_ad = self.android_devices[0] 42 43 def setup_class(self): 44 return setup_multiple_devices_for_bt_test(self.android_devices) 45 46 @test_tracker_info(uuid='b52a032a-3438-4b84-863f-c46a969882a4') 47 @BluetoothBaseTest.bt_test_wrap 48 def test_if_support_a2dp_sink_profile(self): 49 """ Test that a single device can support A2DP SNK profile. 50 Steps 51 1. Initialize one android devices 52 2. Check devices support profiles and return a dictionary 53 3. Check the value of key 'a2dp_sink' 54 :return: test_result: bool 55 """ 56 profiles = check_device_supported_profiles(self.car_ad.droid) 57 if not profiles['a2dp_sink']: 58 self.car_ad.log.debug( 59 "Android device do not support A2DP SNK profile.") 60 return False 61 return True 62 63 @test_tracker_info(uuid='3c2cb613-6c8a-4ed7-8783-37fb47bff5f2') 64 @BluetoothBaseTest.bt_test_wrap 65 def test_if_support_hfp_client_profile(self): 66 """ Test that a single device can support HFP HF profile. 67 Steps 68 1. Initialize one android devices 69 2. Check devices support profiles and return a dictionary 70 3. Check the value of key 'hfp_client' 71 :return: test_result: bool 72 """ 73 profiles = check_device_supported_profiles(self.car_ad.droid) 74 if not profiles['hfp_client']: 75 self.car_ad.log.debug( 76 "Android device do not support HFP Client profile.") 77 return False 78 return True 79 80 @test_tracker_info(uuid='c3854e74-33da-4e4d-a9cb-4f5170ef7d10') 81 @BluetoothBaseTest.bt_test_wrap 82 def test_if_support_pbap_client_profile(self): 83 """ Test that a single device can support PBAP PCE profile. 84 Steps 85 1. Initialize one android devices 86 2. Check devices support profiles and return a dictionary 87 3. Check the value of key 'pbap_client' 88 :return: test_result: bool 89 """ 90 profiles = check_device_supported_profiles(self.car_ad.droid) 91 if not profiles['pbap_client']: 92 self.car_ad.log.debug( 93 "Android device do not support PBAP Client profile.") 94 return False 95 return True 96