1 # Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 # use this file except in compliance with the License. You may obtain a copy of 3 # the License at 4 # 5 # http://www.apache.org/licenses/LICENSE-2.0 6 # 7 # Unless required by applicable law or agreed to in writing, software 8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 # License for the specific language governing permissions and limitations under 11 # the License. 12 """ 13 Test script for Bluetooth OTA testing. 14 """ 15 16 from acts.libs.ota import ota_updater 17 from acts.test_decorators import test_tracker_info 18 from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 19 from acts.test_utils.bt.bt_test_utils import pair_pri_to_sec 20 from acts import signals 21 22 23 class BtOtaTest(BluetoothBaseTest): 24 def setup_class(self): 25 super(BtOtaTest, self).setup_class() 26 ota_updater.initialize(self.user_params, self.android_devices) 27 self.dut = self.android_devices[0] 28 self.pre_ota_name = self.dut.droid.bluetoothGetLocalName() 29 self.pre_ota_address = self.dut.droid.bluetoothGetLocalAddress() 30 self.sec_address = self.android_devices[ 31 1].droid.bluetoothGetLocalAddress() 32 33 # Pairing devices 34 if not pair_pri_to_sec(self.dut, self.android_devices[1]): 35 raise signals.TestSkipClass( 36 "Failed to bond devices prior to update") 37 38 #Run OTA below, if ota fails then abort all tests 39 try: 40 ota_updater.update(self.dut) 41 except Exception as err: 42 raise signals.TestSkipClass( 43 "Failed up apply OTA update. Aborting tests") 44 45 @BluetoothBaseTest.bt_test_wrap 46 @test_tracker_info(uuid='57545ef0-2c2e-463c-9dbf-28da73cc76df') 47 def test_device_name_persists(self): 48 """Test device name persists after OTA update 49 50 Test device name persists after OTA update 51 52 Steps: 53 1. Verify pre OTA device name matches post OTA device name 54 55 Expected Result: 56 Bluetooth Device name persists 57 58 Returns: 59 Pass if True 60 Fail if False 61 62 TAGS: OTA 63 Priority: 2 64 """ 65 return self.pre_ota_name == self.dut.droid.bluetoothGetLocalName() 66 67 @BluetoothBaseTest.bt_test_wrap 68 @test_tracker_info(uuid='1fd5e1a5-d930-499c-aebc-c1872ab49568') 69 def test_device_address_persists(self): 70 """Test device address persists after OTA update 71 72 Test device address persists after OTA update 73 74 Steps: 75 1. Verify pre OTA device address matches post OTA device address 76 77 Expected Result: 78 Bluetooth Device address persists 79 80 Returns: 81 Pass if True 82 Fail if False 83 84 TAGS: OTA 85 Priority: 2 86 """ 87 return self.pre_ota_address == self.dut.droid.bluetoothGetLocalAddress( 88 ) 89 90 @BluetoothBaseTest.bt_test_wrap 91 @test_tracker_info(uuid='2e6704e6-3df0-43fb-8425-41ff841d7473') 92 def test_bluetooth_state_persists(self): 93 """Test device Bluetooth state persists after OTA update 94 95 Test device Bluetooth state persists after OTA update 96 97 Steps: 98 1. Verify post OTA Bluetooth state is on 99 100 Expected Result: 101 Bluetooth Device Bluetooth state is on 102 103 Returns: 104 Pass if True 105 Fail if False 106 107 TAGS: OTA 108 Priority: 2 109 """ 110 return self.dut.droid.bluetoothCheckState() 111 112 @BluetoothBaseTest.bt_test_wrap 113 @test_tracker_info(uuid='eb1c0a22-4b4e-4984-af17-ace3bcd203de') 114 def test_bonded_devices_persist(self): 115 """Test device bonded devices persists after OTA update 116 117 Test device address persists after OTA update 118 119 Steps: 120 1. Verify pre OTA device bonded devices matches post OTA device 121 bonded devices 122 123 Expected Result: 124 Bluetooth Device bonded devices persists 125 126 Returns: 127 Pass if True 128 Fail if False 129 130 TAGS: OTA 131 Priority: 1 132 """ 133 bonded_devices = self.dut.droid.bluetoothGetBondedDevices() 134 for b in bonded_devices: 135 if b['address'] == self.sec_address: 136 return True 137 return False 138