@@ -563,11 +563,13 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
563
563
564
564
constexpr auto timeout = 1s;
565
565
566
+ // +1 makes sure that 2 frames are needed - hence "multi-frame".
566
567
const auto payload = makeIotaArray<UDPARD_MTU_DEFAULT_MAX_SINGLE_FRAME + 1 >(b (' 0' ));
567
568
TransferTxMetadata metadata{{0x13 , Priority::Nominal}, {}};
568
569
569
570
scheduler_.scheduleAt (1s, [&](const auto &) {
570
571
//
572
+ // Expect 1st frame sending.
571
573
EXPECT_CALL (tx_socket_mock_, send (_, _, _, _))
572
574
.WillOnce ([&](auto deadline, auto endpoint, auto , auto fragments) {
573
575
EXPECT_THAT (now (), metadata.deadline - timeout);
@@ -579,15 +581,22 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
579
581
});
580
582
EXPECT_CALL (tx_socket_mock_, registerCallback (_)) //
581
583
.WillOnce (Invoke ([&](auto function) { //
582
- return scheduler_.registerAndScheduleNamedCallback (" " , now () + 10us, std::move (function));
584
+ return scheduler_.registerAndScheduleNamedCallback (" tx " , now () + 10us, std::move (function));
583
585
}));
584
586
587
+ // There was never any TX yet, so no callback should be registered.
588
+ EXPECT_FALSE (scheduler_.hasNamedCallback (" tx" ));
589
+
585
590
metadata.deadline = now () + timeout;
586
591
auto failure = session->send (metadata, makeSpansFrom (payload));
587
592
EXPECT_THAT (failure, Eq (cetl::nullopt));
593
+
594
+ // We just did TX - it should register callback (to run at +10us) for the 1st frame.
595
+ EXPECT_TRUE (scheduler_.hasNamedCallback (" tx" ));
588
596
});
589
597
scheduler_.scheduleAt (1s + 10us, [&](const auto &) {
590
598
//
599
+ // Expect 2nd frame sending.
591
600
EXPECT_CALL (tx_socket_mock_, send (_, _, _, _))
592
601
.WillOnce ([&](auto deadline, auto endpoint, auto , auto fragments) {
593
602
EXPECT_THAT (now (), metadata.deadline - timeout + 10us);
@@ -599,6 +608,19 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
599
608
return ITxSocket::SendResult::Success{true /* is_accepted */ };
600
609
});
601
610
});
611
+ scheduler_.scheduleAt (1s + 20us, [&](const auto &) {
612
+ //
613
+ // Callback is still there b/c the 2nd frame was sent.
614
+ ASSERT_TRUE (scheduler_.hasNamedCallback (" tx" ));
615
+
616
+ // Emulate that media done with the 2nd frame - this should remove the callback b/c TX queue is empty.
617
+ scheduler_.scheduleNamedCallback (" tx" , now ());
618
+ });
619
+ scheduler_.scheduleAt (1s + 20us + 1us, [&](const auto &) {
620
+ //
621
+ // TX pipeline encountered an empty queue - hence the callback should be dropped.
622
+ EXPECT_FALSE (scheduler_.hasNamedCallback (" tx" ));
623
+ });
602
624
scheduler_.scheduleAt (9s, [&](const auto &) {
603
625
//
604
626
session.reset ();
0 commit comments