1#!/usr/bin/env python3 2# 3# Copyright 2020 - 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 time 18 19from cert.gd_base_test import GdBaseTestClass 20from cert.truth import assertThat 21from google.protobuf import empty_pb2 as empty_proto 22from facade import rootservice_pb2 as facade_rootservice 23from hci.facade import controller_facade_pb2 as controller_facade 24 25 26class ControllerTest(GdBaseTestClass): 27 28 def setup_class(self): 29 super().setup_class(dut_module='HCI_INTERFACES', cert_module='HCI_INTERFACES') 30 31 def test_get_addresses(self): 32 cert_address = self.cert.hci_controller.GetMacAddressSimple() 33 dut_address = self.dut.hci_controller.GetMacAddressSimple() 34 35 assertThat(cert_address).isNotEqualTo(dut_address) 36 time.sleep(1) # This shouldn't be needed b/149120542 37 38 def test_write_local_name(self): 39 self.dut.hci_controller.WriteLocalName(controller_facade.NameMsg(name=b'ImTheDUT')) 40 self.cert.hci_controller.WriteLocalName(controller_facade.NameMsg(name=b'ImTheCert')) 41 cert_name = self.cert.hci_controller.GetLocalNameSimple() 42 dut_name = self.dut.hci_controller.GetLocalNameSimple() 43 44 assertThat(dut_name).isEqualTo(b'ImTheDUT') 45 assertThat(cert_name).isEqualTo(b'ImTheCert') 46