Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc

Issue 2633923003: Add rtcp::TransportFeedback::GetReceivedPackets() (Closed)
Patch Set: Fix for android compilers Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
index dbb3eaa4d78abd41074875cb2bb1ebfb854a43a5..cb7d6299050791875a15b388f9a46f0a46ea144b 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
@@ -16,11 +16,29 @@
#include "webrtc/test/gtest.h"
using ::testing::_;
-using ::testing::InSequence;
+using ::testing::ElementsAre;
using ::testing::Invoke;
using ::testing::Return;
namespace webrtc {
+namespace {
+
+std::vector<uint16_t> SequenceNumbers(const rtcp::TransportFeedback& packet) {
terelius 2017/01/17 16:32:23 It is unclear whether packet refers to the RTCP fe
danilchap 2017/01/17 17:20:14 Done.
+ std::vector<uint16_t> sequence_numbers;
+ for (const auto& received_packet : packet.GetReceivedPackets()) {
+ sequence_numbers.push_back(received_packet.sequence_number());
+ }
+ return sequence_numbers;
+}
+
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
+std::vector<int64_t> TimestampsMs(const rtcp::TransportFeedback& packet) {
+ std::vector<int64_t> timestamps;
+ int64_t timestamp_us = packet.GetBaseTimeUs();
+ for (const auto& received_packet : packet.GetReceivedPackets()) {
+ timestamps.push_back((timestamp_us += received_packet.delta_us()) / 1000);
+ }
+ return timestamps;
+}
class MockPacketRouter : public PacketRouter {
public:
@@ -62,20 +80,12 @@ TEST_F(RemoteEstimatorProxyTest, SendsSinglePacketFeedback) {
IncomingPacket(kBaseSeq, kBaseTimeMs);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done. To avoid growing these lines too much notice
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(1u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[0]);
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq));
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs));
return true;
}));
@@ -87,20 +97,12 @@ TEST_F(RemoteEstimatorProxyTest, DuplicatedPackets) {
IncomingPacket(kBaseSeq, kBaseTimeMs + 1000);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(1u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[0]);
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq));
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs));
return true;
}));
@@ -111,30 +113,19 @@ TEST_F(RemoteEstimatorProxyTest, FeedbackWithMissingStart) {
// First feedback.
IncomingPacket(kBaseSeq, kBaseTimeMs);
IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1000);
- EXPECT_CALL(router_, SendFeedback(_)).Times(1).WillOnce(Return(true));
+ EXPECT_CALL(router_, SendFeedback(_)).WillOnce(Return(true));
Process();
// Second feedback starts with a missing packet (DROP kBaseSeq + 2).
IncomingPacket(kBaseSeq + 3, kBaseTimeMs + 3000);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(2u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kNotReceived,
- status_vec[0]);
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[1]);
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs + 3000,
- (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq + 3));
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs + 3000));
return true;
}));
@@ -147,27 +138,15 @@ TEST_F(RemoteEstimatorProxyTest, SendsFeedbackWithVaryingDeltas) {
IncomingPacket(kBaseSeq + 2, kBaseTimeMs + (2 * kMaxSmallDeltaMs) + 1);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(3u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[0]);
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[1]);
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedLargeDelta,
- status_vec[2]);
-
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(3u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
- EXPECT_EQ(kMaxSmallDeltaMs, delta_vec[1] / 1000);
- EXPECT_EQ(kMaxSmallDeltaMs + 1, delta_vec[2] / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet),
+ ElementsAre(kBaseSeq, kBaseSeq + 1, kBaseSeq + 2));
+ EXPECT_THAT(TimestampsMs(*packet),
+ ElementsAre(kBaseTimeMs, kBaseTimeMs + kMaxSmallDeltaMs,
+ kBaseTimeMs + (2 * kMaxSmallDeltaMs) + 1));
return true;
}));
@@ -181,45 +160,24 @@ TEST_F(RemoteEstimatorProxyTest, SendsFragmentedFeedback) {
IncomingPacket(kBaseSeq, kBaseTimeMs);
IncomingPacket(kBaseSeq + 1, kBaseTimeMs + kTooLargeDelta);
- InSequence s;
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(1u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[0]);
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq));
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs));
return true;
}))
- .RetiresOnSaturation();
-
- EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([kTooLargeDelta, this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<rtcp::TransportFeedback::StatusSymbol> status_vec =
- packet->GetStatusVector();
- EXPECT_EQ(1u, status_vec.size());
- EXPECT_EQ(rtcp::TransportFeedback::StatusSymbol::kReceivedSmallDelta,
- status_vec[0]);
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs + kTooLargeDelta,
- (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet), ElementsAre(kBaseSeq + 1));
+ EXPECT_THAT(TimestampsMs(*packet),
+ ElementsAre(kBaseTimeMs + kTooLargeDelta));
return true;
- }))
- .RetiresOnSaturation();
+ }));
Process();
}
@@ -231,15 +189,11 @@ TEST_F(RemoteEstimatorProxyTest, GracefullyHandlesReorderingAndWrap) {
IncomingPacket(kLargeSeq, kBaseTimeMs + kDeltaMs);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs));
return true;
}));
@@ -251,16 +205,14 @@ TEST_F(RemoteEstimatorProxyTest, ResendsTimestampsOnReordering) {
IncomingPacket(kBaseSeq + 2, kBaseTimeMs + 2);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(2u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
- EXPECT_EQ(2, delta_vec[1] / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet),
+ ElementsAre(kBaseSeq, kBaseSeq + 2));
+ EXPECT_THAT(TimestampsMs(*packet),
+ ElementsAre(kBaseTimeMs, kBaseTimeMs + 2));
return true;
}));
@@ -269,17 +221,14 @@ TEST_F(RemoteEstimatorProxyTest, ResendsTimestampsOnReordering) {
IncomingPacket(kBaseSeq + 1, kBaseTimeMs + 1);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq + 1, packet->GetBaseSequence());
EXPECT_EQ(kMediaSsrc, packet->media_ssrc());
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(2u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs + 1,
- (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
- EXPECT_EQ(1, delta_vec[1] / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet),
+ ElementsAre(kBaseSeq + 1, kBaseSeq + 2));
+ EXPECT_THAT(TimestampsMs(*packet),
+ ElementsAre(kBaseTimeMs + 1, kBaseTimeMs + 2));
return true;
}));
@@ -293,14 +242,10 @@ TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) {
IncomingPacket(kBaseSeq + 2, kBaseTimeMs);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq + 2, packet->GetBaseSequence());
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs, (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kBaseTimeMs));
return true;
}));
@@ -309,15 +254,10 @@ TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) {
IncomingPacket(kBaseSeq + 3, kTimeoutTimeMs); // kBaseSeq + 2 times out here.
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) {
- packet->Build();
EXPECT_EQ(kBaseSeq + 3, packet->GetBaseSequence());
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(1u, delta_vec.size());
- EXPECT_EQ(kTimeoutTimeMs,
- (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
+ EXPECT_THAT(TimestampsMs(*packet), ElementsAre(kTimeoutTimeMs));
return true;
}));
@@ -329,21 +269,14 @@ TEST_F(RemoteEstimatorProxyTest, RemovesTimestampsOutOfScope) {
IncomingPacket(kBaseSeq + 1, kTimeoutTimeMs - 1);
EXPECT_CALL(router_, SendFeedback(_))
- .Times(1)
.WillOnce(Invoke([kTimeoutTimeMs, this](rtcp::TransportFeedback* packet) {
terelius 2017/01/17 16:32:23 feedback_packet?
danilchap 2017/01/17 17:20:14 Done.
- packet->Build();
EXPECT_EQ(kBaseSeq, packet->GetBaseSequence());
- // Four status entries (kBaseSeq + 3 missing).
- EXPECT_EQ(4u, packet->GetStatusVector().size());
-
- // Only three actual timestamps.
- std::vector<int64_t> delta_vec = packet->GetReceiveDeltasUs();
- EXPECT_EQ(3u, delta_vec.size());
- EXPECT_EQ(kBaseTimeMs - 1,
- (packet->GetBaseTimeUs() + delta_vec[0]) / 1000);
- EXPECT_EQ(kTimeoutTimeMs - kBaseTimeMs, delta_vec[1] / 1000);
- EXPECT_EQ(1, delta_vec[2] / 1000);
+ EXPECT_THAT(SequenceNumbers(*packet),
+ ElementsAre(kBaseSeq, kBaseSeq + 1, kBaseSeq + 3));
+ EXPECT_THAT(
+ TimestampsMs(*packet),
+ ElementsAre(kBaseTimeMs - 1, kTimeoutTimeMs - 1, kTimeoutTimeMs));
return true;
}));
@@ -391,4 +324,5 @@ TEST_F(RemoteEstimatorProxyTest, TwccReportsUse5PercentOfAvailableBandwidth) {
EXPECT_EQ(136, proxy_.TimeUntilNextProcess());
}
+} // namespace
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698