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