@@ -563,11 +563,13 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
563563
564564 constexpr auto timeout = 1s;
565565
566+ // +1 makes sure that 2 frames are needed - hence "multi-frame".
566567 const auto payload = makeIotaArray<UDPARD_MTU_DEFAULT_MAX_SINGLE_FRAME + 1 >(b (' 0' ));
567568 TransferTxMetadata metadata{{0x13 , Priority::Nominal}, {}};
568569
569570 scheduler_.scheduleAt (1s, [&](const auto &) {
570571 //
572+ // Expect 1st frame sending.
571573 EXPECT_CALL (tx_socket_mock_, send (_, _, _, _))
572574 .WillOnce ([&](auto deadline, auto endpoint, auto , auto fragments) {
573575 EXPECT_THAT (now (), metadata.deadline - timeout);
@@ -579,15 +581,22 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
579581 });
580582 EXPECT_CALL (tx_socket_mock_, registerCallback (_)) //
581583 .WillOnce (Invoke ([&](auto function) { //
582- return scheduler_.registerAndScheduleNamedCallback (" " , now () + 10us, std::move (function));
584+ return scheduler_.registerAndScheduleNamedCallback (" tx " , now () + 10us, std::move (function));
583585 }));
584586
587+ // There was never any TX yet, so no callback should be registered.
588+ EXPECT_FALSE (scheduler_.hasNamedCallback (" tx" ));
589+
585590 metadata.deadline = now () + timeout;
586591 auto failure = session->send (metadata, makeSpansFrom (payload));
587592 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" ));
588596 });
589597 scheduler_.scheduleAt (1s + 10us, [&](const auto &) {
590598 //
599+ // Expect 2nd frame sending.
591600 EXPECT_CALL (tx_socket_mock_, send (_, _, _, _))
592601 .WillOnce ([&](auto deadline, auto endpoint, auto , auto fragments) {
593602 EXPECT_THAT (now (), metadata.deadline - timeout + 10us);
@@ -599,6 +608,19 @@ TEST_F(TestUpdTransport, sending_multiframe_payload_for_non_anonymous)
599608 return ITxSocket::SendResult::Success{true /* is_accepted */ };
600609 });
601610 });
611+ scheduler_.scheduleAt (1s + 20us, [&](const auto &) {
612+ //
613+ // Callback 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+ });
602624 scheduler_.scheduleAt (9s, [&](const auto &) {
603625 //
604626 session.reset ();
0 commit comments