1#!/usr/bin/env python3 2# 3# Copyright (C) 2019 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""" 17A2DP PTS Tests. 18""" 19from acts_contrib.test_utils.abstract_devices.bluetooth_device import AndroidBluetoothDevice 20from acts_contrib.test_utils.abstract_devices.bluetooth_device import FuchsiaBluetoothDevice 21from acts_contrib.test_utils.bt.pts.pts_base_class import PtsBaseClass 22 23import acts_contrib.test_utils.bt.pts.fuchsia_pts_ics_lib as f_ics_lib 24import acts_contrib.test_utils.bt.pts.fuchsia_pts_ixit_lib as f_ixit_lib 25 26 27class A2dpPtsTest(PtsBaseClass): 28 ble_advertise_interval = 100 29 pts_action_mapping = None 30 31 def setup_class(self): 32 super().setup_class() 33 self.dut.initialize_bluetooth_controller() 34 # self.dut.set_bluetooth_local_name(self.dut_bluetooth_local_name) 35 local_dut_mac_address = self.dut.get_local_bluetooth_address() 36 37 ics = None 38 ixit = None 39 if isinstance(self.dut, FuchsiaBluetoothDevice): 40 fuchsia_ixit = f_ixit_lib.A2DP_IXIT 41 fuchsia_ixit[b'TSPX_bd_addr_iut'] = (b'OCTETSTRING', 42 local_dut_mac_address.replace( 43 ':', '').encode()) 44 ics = f_ics_lib.A2DP_ICS 45 ixit = fuchsia_ixit 46 elif isinstance(self.dut, AndroidBluetoothDevice): 47 # TODO: Add ICS and IXIT values for Android 48 self.log.warn( 49 "ICS/IXIT values not set for Android, using Fuchsia as default." 50 ) 51 fuchsia_ixit = f_ixit_lib.A2DP_IXIT 52 fuchsia_ixit[b'TSPX_bd_addr_iut'] = (b'OCTETSTRING', 53 local_dut_mac_address.replace( 54 ':', '').encode()) 55 ics = f_ics_lib.A2DP_ICS 56 ixit = fuchsia_ixit 57 58 ### PTS SETUP: Required after ICS, IXIT, and profile is setup ### 59 self.pts.set_profile_under_test("A2DP") 60 self.pts.set_ics_and_ixit(ics, ixit) 61 self.pts.setup_pts() 62 ### End PTS Setup ### 63 64 self.dut.unbond_all_known_devices() 65 self.dut.start_pairing_helper() 66 67 def setup_test(self): 68 super(A2dpPtsTest, self).setup_test() 69 # Make sure there were no lingering answers due to a failed test. 70 self.pts.extra_answers = [] 71 72 def teardown_test(self): 73 super(A2dpPtsTest, self).teardown_test() 74 75 def teardown_class(self): 76 super(A2dpPtsTest, self).teardown_class() 77 self.dut.stop_profile_a2dp_sink() 78 79 # BEGIN A2DP SINK TESTCASES # 80 @PtsBaseClass.pts_test_wrap 81 def test_a2dp_snk_as_bv_01_i(self): 82 return self.pts.execute_test("A2DP/SNK/AS/BV-01-I") 83 84 @PtsBaseClass.pts_test_wrap 85 def test_a2dp_snk_as_bv_02_i(self): 86 return self.pts.execute_test("A2DP/SNK/AS/BV-02-I") 87 88 @PtsBaseClass.pts_test_wrap 89 def test_a2dp_snk_cc_bv_01_i(self): 90 return self.pts.execute_test("A2DP/SNK/CC/BV-01-I") 91 92 @PtsBaseClass.pts_test_wrap 93 def test_a2dp_snk_cc_bv_02_i(self): 94 return self.pts.execute_test("A2DP/SNK/CC/BV-02-I") 95 96 @PtsBaseClass.pts_test_wrap 97 def test_a2dp_snk_cc_bv_05_i(self): 98 return self.pts.execute_test("A2DP/SNK/CC/BV-05-I") 99 100 @PtsBaseClass.pts_test_wrap 101 def test_a2dp_snk_cc_bv_06_i(self): 102 return self.pts.execute_test("A2DP/SNK/CC/BV-06-I") 103 104 @PtsBaseClass.pts_test_wrap 105 def test_a2dp_snk_cc_bv_07_i(self): 106 return self.pts.execute_test("A2DP/SNK/CC/BV-07-I") 107 108 @PtsBaseClass.pts_test_wrap 109 def test_a2dp_snk_cc_bv_08_i(self): 110 return self.pts.execute_test("A2DP/SNK/CC/BV-08-I") 111 112 @PtsBaseClass.pts_test_wrap 113 def test_a2dp_snk_rel_bv_01_i(self): 114 return self.pts.execute_test("A2DP/SNK/REL/BV-01-I") 115 116 @PtsBaseClass.pts_test_wrap 117 def test_a2dp_snk_set_bv_01_i(self): 118 return self.pts.execute_test("A2DP/SNK/SET/BV-01-I") 119 120 @PtsBaseClass.pts_test_wrap 121 def test_a2dp_snk_set_bv_02_i(self): 122 return self.pts.execute_test("A2DP/SNK/SET/BV-02-I") 123 124 @PtsBaseClass.pts_test_wrap 125 def test_a2dp_snk_set_bv_03_i(self): 126 return self.pts.execute_test("A2DP/SNK/SET/BV-03-I") 127 128 @PtsBaseClass.pts_test_wrap 129 def test_a2dp_snk_set_bv_03_i_bv_05_i(self): 130 return self.pts.execute_test("A2DP/SNK/SET/BV-05-I") 131 132 @PtsBaseClass.pts_test_wrap 133 def test_a2dp_snk_sus_bv_01_i(self): 134 return self.pts.execute_test("A2DP/SNK/SUS/BV-01-I") 135 136 # END A2DP SINK TESTCASES # 137