Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3816b5e authored by Zach Johnson's avatar Zach Johnson
Browse files

Add HciMatchers.LoopbackOf to avoid imprecise matching

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --host
Change-Id: Id9b18af3075225b3ac09a6af485d424476151b33
parent 228116d6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -163,6 +163,11 @@ class HciMatchers(object):
    def RemoteOobDataRequest():
        return lambda event: HciMatchers.EventWithCode(EventCode.REMOTE_OOB_DATA_REQUEST)

    @staticmethod
    def LoopbackOf(packet):
        data = bytes(hci_packets.LoopbackCommandBuilder(packet).Serialize())
        return lambda event: data == event.payload


class NeighborMatchers(object):

+1 −4
Original line number Diff line number Diff line
@@ -110,13 +110,10 @@ class DirectHciTest(GdBaseTestClass):
    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
        self.dut_hci.register_for_events(EventCode.LOOPBACK_COMMAND)

        self.dut_hci.send_command_with_complete(WriteLoopbackModeBuilder(LoopbackMode.ENABLE_LOCAL))

        self.dut_hci.send_command_with_complete(ReadLocalNameBuilder())

        looped_bytes = bytes(ReadLocalNameBuilder().Serialize())
        assertThat(self.dut_hci.get_event_stream()).emits(lambda packet: looped_bytes in packet.payload)
        assertThat(self.dut_hci.get_event_stream()).emits(HciMatchers.LoopbackOf(ReadLocalNameBuilder()))

    def test_inquiry_from_dut(self):
        self.dut_hci.register_for_events(EventCode.INQUIRY_RESULT)