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 17from blueberry.tests.gd.cert.truth import assertThat 18from blueberry.tests.topshim.lib.topshim_base_test import TopshimBaseTest 19from blueberry.tests.topshim.lib.adapter_client import AdapterClient 20 21from mobly import test_runner 22 23 24class AdapterTest(TopshimBaseTest): 25 26 def test_verify_adapter_started(self): 27 print("Adapter is verified when test starts") 28 29 def test_enable_inquiry_scan(self): 30 status, discovery_mode = self.dut().enable_inquiry_scan() 31 assertThat(status).isEqualTo("Success") 32 assertThat(discovery_mode).isEqualTo("ConnectableDiscoverable") 33 34 def test_enable_page_scan(self): 35 status, discovery_mode = self.dut().enable_page_scan() 36 assertThat(status).isEqualTo("Success") 37 assertThat(discovery_mode).isEqualTo("Connectable") 38 39 def test_disable_page_scan(self): 40 status, discovery_mode = self.dut().disable_page_scan() 41 assertThat(status).isEqualTo("Success") 42 assertThat(discovery_mode).isEqualTo("None_") 43 44 def test_set_local_io_caps(self): 45 status, caps = self.dut().set_local_io_caps(3) 46 assertThat(status).isEqualTo("Success") 47 assertThat(caps).isEqualTo("None_") 48 49 def test_start_discovery(self): 50 state = self.dut().toggle_discovery(True) 51 assertThat(state).isEqualTo("Started") 52 # Reset device to not discovering. 53 self.dut().toggle_discovery(False) 54 55 def test_cancel_discovery(self): 56 self.dut().toggle_discovery(True) 57 state = self.dut().toggle_discovery(False) 58 assertThat(state).isEqualTo("Stopped") 59 60 def test_find_device_device_available(self): 61 self.dut().enable_inquiry_scan() 62 self.cert().enable_inquiry_scan() 63 self.dut().toggle_discovery(True) 64 device_addr = self.dut().find_device() 65 assertThat(device_addr).isNotNone() 66 # Reset DUT device discovering and scanning to None 67 self.dut().disable_page_scan() 68 self.dut().toggle_discovery(False) 69 # Reset CERT device to not discoverable 70 self.cert().disable_page_scan() 71 72 73if __name__ == "__main__": 74 test_runner.main() 75