예제 #1
0
    def test_loopback_hci_command(self):
        self.dut_hal.send_hci_command(
            hci_packets.WriteLoopbackModeBuilder(
                hci_packets.LoopbackMode.ENABLE_LOCAL))

        command = hci_packets.LeAddDeviceToConnectListBuilder(
            hci_packets.ConnectListAddressType.RANDOM, '0C:05:04:03:02:01')
        self.dut_hal.send_hci_command(command)

        assertThat(self.dut_hal.get_hci_event_stream()).emits(
            HciMatchers.LoopbackOf(command))
예제 #2
0
    def test_loopback_hci_command(self):
        with EventStream(self.dut.hal.FetchHciEvent(
                empty_pb2.Empty())) as hci_event_stream:

            self.send_dut_hci_command(
                hci_packets.WriteLoopbackModeBuilder(
                    hci_packets.LoopbackMode.ENABLE_LOCAL))

            command = hci_packets.LeAddDeviceToConnectListBuilder(
                hci_packets.ConnectListAddressType.RANDOM, '0C:05:04:03:02:01')
            self.send_dut_hci_command(command)

            assertThat(hci_event_stream).emits(
                lambda packet: bytes(command.Serialize()) in packet.payload)
예제 #3
0
    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
        self.dut_hci.register_for_events(
            hci_packets.EventCode.LOOPBACK_COMMAND)

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

        cmd2loop = hci_packets.ReadLocalNameBuilder()
        self.dut_hci.send_command_with_complete(cmd2loop)

        looped_bytes = bytes(cmd2loop.Serialize())
        assertThat(self.dut_hci.get_event_stream()).emits(
            lambda packet: looped_bytes in packet.event)
예제 #4
0
    def test_loopback_hci_command(self):
        with EventCallbackStream(
                self.device_under_test.hal.FetchHciEvent(
                    empty_pb2.Empty())) as hci_event_stream:

            self.send_dut_hci_command(
                hci_packets.WriteLoopbackModeBuilder(
                    hci_packets.LoopbackMode.ENABLE_LOCAL))

            hci_event_asserts = EventAsserts(hci_event_stream)

            command = hci_packets.LeAddDeviceToWhiteListBuilder(
                hci_packets.WhiteListAddressType.RANDOM, '0C:05:04:03:02:01')
            self.send_dut_hci_command(command)
            hci_event_asserts.assert_event_occurs(
                lambda packet: bytes(command.Serialize()) in packet.payload)
예제 #5
0
    def test_local_hci_cmd_and_event(self):
        # Loopback mode responds with ACL and SCO connection complete
        self.register_for_event(hci_packets.EventCode.CONNECTION_COMPLETE)
        self.register_for_event(hci_packets.EventCode.LOOPBACK_COMMAND)
        self.register_for_event(
            hci_packets.EventCode.CONNECTION_PACKET_TYPE_CHANGED)
        with EventStream(self.dut.hci.FetchEvents(
                empty_proto.Empty())) as hci_event_stream:

            self.enqueue_hci_command(
                hci_packets.WriteLoopbackModeBuilder(
                    hci_packets.LoopbackMode.ENABLE_LOCAL), True)

            cmd2loop = hci_packets.ReadLocalNameBuilder()
            self.enqueue_hci_command(cmd2loop, True)

            looped_bytes = bytes(cmd2loop.Serialize())
            hci_event_stream.assert_event_occurs(
                lambda packet: looped_bytes in packet.event)