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

Commit a0709c42 authored by Ted Wang's avatar Ted Wang Committed by Gerrit Code Review
Browse files

Merge "L2CAP: Add test case for TSPC_L2CAP_2_7 Can Sent Reject"

parents a94eadf3 6fa51dc8
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -335,6 +335,27 @@ class PTSL2capTest(PTSBaseTestClass):
                l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc'))
            self._assert_connection_close(due_connection_close_asserts)

    def test_L2CAP_ERM_BV_16_C(self):
        """
         L2CAP/ERM/BV-16-C [Send S-Frame [REJ]]
        Verify the IUT can send an S-frame [REJ] after receiving out of sequence I-frames.
        """
        with self._dut_connection_stream() as dut_connection_stream, \
            self._dut_connection_close_stream() as dut_connection_close_stream:
            due_connection_asserts = EventAsserts(dut_connection_stream)
            due_connection_close_asserts = EventAsserts(
                dut_connection_close_stream)
            psm = 1

            self.device_under_test.l2cap.SetDynamicChannel(
                l2cap_facade_pb2.SetEnableDynamicChannelRequest(
                    psm=psm,
                    retransmission_mode=l2cap_facade_pb2.
                    RetransmissionFlowControlMode.ERTM))
            self._assert_connection_complete(due_connection_asserts)
            self._assert_connection_close(
                due_connection_close_asserts, timeout=60)

    def test_L2CAP_ERM_BV_18_C(self):
        """
        L2CAP/ERM/BV-18-C [Receive S-Frame [RR] Final Bit = 1]
+53 −0
Original line number Diff line number Diff line
@@ -825,6 +825,59 @@ class SimpleL2capTest(GdBaseTestClass):
                    lambda log: match_frame(log, scid=scid, payload=b'abc'),
                    timeout=timedelta(seconds=0.5))

    def test_send_rej(self):
        """
        L2CAP/ERM/BV-16-C [Send S-Frame [REJ]]
        Verify the IUT can send an S-frame [REJ] after receiving out of sequence I-frames.
        """
        with EventCallbackStream(
                self.cert_device.l2cap.FetchL2capLog(
                    empty_pb2.Empty())) as l2cap_log_stream:
            l2cap_event_asserts = EventAsserts(l2cap_log_stream)

            self._register_callbacks(l2cap_log_stream)
            signal_id = 3
            scid = 0x0101
            tx_window = 5
            self.retransmission_mode = l2cap_cert_pb2.ChannelRetransmissionFlowControlMode.ERTM

            self._setup_link(l2cap_event_asserts)
            self._open_channel(
                l2cap_event_asserts, mode=self.retransmission_mode)

            self.cert_device.l2cap.SendIFrame(
                l2cap_cert_pb2.IFrame(
                    channel=self.scid_dcid_map[scid],
                    req_seq=0,
                    tx_seq=0,
                    sar=0,
                    information=b'abc'))
            l2cap_event_asserts.assert_event_occurs(
                    lambda log: match_frame(log, scid=scid, control_field=b'\x01\x01')
                )
            self.cert_device.l2cap.SendIFrame(
                l2cap_cert_pb2.IFrame(
                    channel=self.scid_dcid_map[scid],
                    req_seq=0,
                    tx_seq=(tx_window - 1),
                    sar=0,
                    information=b'abc'))
            l2cap_event_asserts.assert_event_occurs(
                    lambda log: match_frame(log, scid=scid, control_field=b'\x05\x01')
                )
            for i in range(1, tx_window):
                self.cert_device.l2cap.SendIFrame(
                    l2cap_cert_pb2.IFrame(
                        channel=self.scid_dcid_map[scid],
                        req_seq=0,
                        tx_seq=(i),
                        sar=0))
                l2cap_event_asserts.assert_event_occurs(
                        lambda log :log.HasField("data_packet") and \
                        log.data_packet.channel == scid and \
                        bytes([get_enhanced_control_field(log.data_packet.payload)[1]]) == bytes([i + 1])
                    )

    def test_receive_s_frame_rr_final_bit_set(self):
        """
        L2CAP/ERM/BV-18-C [Receive S-Frame [RR] Final Bit = 1]