src/connectivity/bluetooth/core/bt-host/l2cap/enhanced_retransmission_mode_engines_unittest.cc
// This tests the integration of receiving Selective Reject frames that are poll requests,
// triggering retransmission as well as acknowledgment that frees up transmit window. This mirrors
// the L2CAP Test Specification v5.0.2 L2CAP/ERM/BV-14-C.
This tests the integration of receiving Selective Reject frames that are poll requests,
triggering retransmission as well as acknowledgment that frees up transmit window. This mirrors
the L2CAP Test Specification v5.0.2 L2CAP/ERM/BV-14-C.
This tests the integration of receiving Selective Reject frames that are poll requests triggering retransmission as well as acknowledgment that frees up transmit window . This mirrors the L2CAP Test Specification v5 . 0 . 2 L2CAP / ERM / BV - 14 - C .
TEST_F(L2CAP_EnhancedRetransmissionModeEnginesTest,
       RetransmitAfterReceivingSelectiveRejectPollRequestSFrame) {
  int tx_count = 0;
  std::array<int, 4> iframe_tx_counts{};
  auto tx_callback = [&tx_count, &iframe_tx_counts](ByteBufferPtr pdu) {
    tx_count++;
    ASSERT_LE(sizeof(SimpleInformationFrameHeader), pdu->size());
    ASSERT_TRUE(pdu->As<EnhancedControlField>().designates_information_frame());
    const auto& header = pdu->As<SimpleInformationFrameHeader>();
    ASSERT_GT(iframe_tx_counts.size(), header.tx_seq());
    iframe_tx_counts[header.tx_seq()]++;
  };
  auto [rx_engine, tx_engine] = MakeLinkedEnhancedRetransmissionModeEngines(
      kTestChannelId, kDefaultMTU, kMaxTransmissions, 3, tx_callback,
      NoOpFailureCallback);
  ASSERT_TRUE(rx_engine);
  ASSERT_TRUE(tx_engine);
  for (int i = 0; i < 4; i++) {
    tx_engine->QueueSdu(std::make_unique<DynamicByteBuffer>(StaticByteBuffer('a' + i)));
  }
  EXPECT_EQ(3, tx_count);
  EXPECT_THAT(iframe_tx_counts, testing::ElementsAre(1, 1, 1, 0));
  auto selective_reject =
      StaticByteBuffer(0b1 | kExtendedControlSrejFunctionMask | kExtendedControlPBitMask, 1);
  rx_engine->ProcessPdu(
      Fragmenter(kTestHandle)
          .BuildFrame(kTestChannelId, selective_reject, FrameCheckSequenceOption::kIncludeFcs));
  EXPECT_EQ(5, tx_count);
  EXPECT_THAT(iframe_tx_counts, testing::ElementsAre(1, 2, 1, 1));
}
TEST_F ( L2CAP_EnhancedRetransmissionModeEnginesTest , RetransmitAfterReceivingSelectiveRejectPollRequestSFrame ) { int tx_count = 0 ; std :: array < int , 4 > iframe_tx_counts { } ; auto tx_callback = [ & tx_count , & iframe_tx_counts ] ( ByteBufferPtr pdu ) { tx_count ++ ; ASSERT_LE ( sizeof ( SimpleInformationFrameHeader ) , pdu -> size ( ) ) ; ASSERT_TRUE ( pdu -> As < EnhancedControlField > ( ) . designates_information_frame ( ) ) ; const auto & header = pdu -> As < SimpleInformationFrameHeader > ( ) ; ASSERT_GT ( iframe_tx_counts . size ( ) , header . tx_seq ( ) ) ; iframe_tx_counts [ header . tx_seq ( ) ] ++ ; } ; auto [ rx_engine , tx_engine ] = MakeLinkedEnhancedRetransmissionModeEngines ( kTestChannelId , kDefaultMTU , kMaxTransmissions , 3 , tx_callback , NoOpFailureCallback ) ; ASSERT_TRUE ( rx_engine ) ; ASSERT_TRUE ( tx_engine ) ; for ( int i = 0 ; i < 4 ; i ++ ) { tx_engine -> QueueSdu ( std :: make_unique < DynamicByteBuffer > ( StaticByteBuffer ( ' ' + i ) ) ) ; } EXPECT_EQ ( 3 , tx_count ) ; EXPECT_THAT ( iframe_tx_counts , testing :: ElementsAre ( 1 , 1 , 1 , 0 ) ) ; auto selective_reject = StaticByteBuffer ( 0b1 | kExtendedControlSrejFunctionMask | kExtendedControlPBitMask , 1 ) ; rx_engine -> ProcessPdu ( Fragmenter ( kTestHandle ) . BuildFrame ( kTestChannelId , selective_reject , FrameCheckSequenceOption :: kIncludeFcs ) ) ; EXPECT_EQ ( 5 , tx_count ) ; EXPECT_THAT ( iframe_tx_counts , testing :: ElementsAre ( 1 , 2 , 1 , 1 ) ) ; }
This tests the integration of receiving Selective Reject frames that are poll requests,
triggering retransmission as well as acknowledgment that frees up transmit window.
This tests the integration of receiving Selective Reject frames that are poll requests triggering retransmission as well as acknowledgment that frees up transmit window .
/*n_frames_in_tx_window=*/ // TxWindow caps transmissions. // Receive an S-frame containing a poll request retransmission request for seq = 1. See Core Spec // v5.0, Vol 3, Part A, Section 3.3.2 S-Frame Enhanced Control Field. // Check that this caused a retransmission of I-Frames 1 and 3 because the poll request // acknowledged I-Frame 0, freeing up space in the transmit window.