1#!/usr/bin/env python3 2# 3# Copyright 2022 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of 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, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import binascii 18import io 19import logging 20import os 21import queue 22 23from blueberry.tests.gd.cert.context import get_current_context 24 25from blueberry.tests.sl4a_sl4a.lib import sl4a_sl4a_base_test 26from blueberry.tests.gd_sl4a.lib.bt_constants import ble_address_types 27from mobly import test_runner 28 29 30class LeAdvertisingTest(sl4a_sl4a_base_test.Sl4aSl4aBaseTestClass): 31 32 def setup_class(self): 33 super().setup_class() 34 35 def setup_test(self): 36 super().setup_test() 37 38 def teardown_test(self): 39 super().teardown_test() 40 41 def test_advertise_name(self): 42 rpa_address = self.cert_advertiser_.advertise_public_extended_pdu() 43 self.dut_scanner_.scan_for_name(self.cert_advertiser_.get_local_advertising_name()) 44 self.dut_scanner_.stop_scanning() 45 self.cert_advertiser_.stop_advertising() 46 47 def test_advertise_name_stress(self): 48 for i in range(0, 10): 49 self.test_advertise_name() 50 51 def test_advertise_name_twice_no_stop(self): 52 rpa_address = self.cert_advertiser_.advertise_public_extended_pdu() 53 self.dut_scanner_.scan_for_name(self.cert_advertiser_.get_local_advertising_name()) 54 self.dut_scanner_.stop_scanning() 55 rpa_address = self.cert_advertiser_.advertise_public_extended_pdu() 56 self.dut_scanner_.scan_for_name(self.cert_advertiser_.get_local_advertising_name()) 57 self.dut_scanner_.stop_scanning() 58 self.cert_advertiser_.stop_advertising() 59 60 61if __name__ == '__main__': 62 test_runner.main() 63