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

Unified Diff: webrtc/modules/pacing/paced_sender_unittest.cc

Issue 2340763004: Add AlrDetector (Closed)
Patch Set: Fix ASAN/TSAN failures Created 4 years, 3 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/pacing/paced_sender_unittest.cc
diff --git a/webrtc/modules/pacing/paced_sender_unittest.cc b/webrtc/modules/pacing/paced_sender_unittest.cc
index c4f34ef69e4de8a8f5ff2ae6bd729e2765d876b0..1df68f16afba89ab427a66ff397210e4983fb465 100644
--- a/webrtc/modules/pacing/paced_sender_unittest.cc
+++ b/webrtc/modules/pacing/paced_sender_unittest.cc
@@ -99,6 +99,24 @@ class PacedSenderProbing : public PacedSender::PacketSender {
int padding_sent_;
};
+class PacingObserver : public PacedSender::PacingObserver {
+ public:
+ PacingObserver() : total_bytes_sent_(0), total_elapsed_time_(0) {}
+
+ void OnBytesSent(size_t bytes_sent, int64_t elapsed_time_ms) override {
+ total_bytes_sent_ += bytes_sent;
+ total_elapsed_time_ += elapsed_time_ms;
+ }
+
+ size_t bytes_sent() { return total_bytes_sent_; }
+
+ int64_t elapsed_time_ms() { return total_elapsed_time_; }
+
+ private:
+ size_t total_bytes_sent_;
+ int64_t total_elapsed_time_;
+};
+
class PacedSenderTest : public ::testing::Test {
protected:
PacedSenderTest() : clock_(123456) {
@@ -912,6 +930,40 @@ TEST_F(PacedSenderTest, ProbingUsesRetransmissions) {
kFirstClusterBps, kBitrateProbingError);
}
+TEST_F(PacedSenderTest, ValidatePacingObserver) {
+ const size_t kPacketSize = 1200;
+ const int kInitialBitrateBps = 300000;
+ uint32_t ssrc = 12346;
+ uint16_t sequence_number = 1234;
+
+ PacedSenderProbing packet_sender;
+ PacingObserver pacing_observer;
+ send_bucket_.reset(
+ new PacedSender(&clock_, &packet_sender, &pacing_observer));
+ send_bucket_->CreateProbeCluster(kFirstClusterBps, kFirstClusterCount);
+ send_bucket_->SetEstimatedBitrate(kInitialBitrateBps);
+
+ for (int i = 0; i < kFirstClusterCount; ++i) {
+ send_bucket_->InsertPacket(PacedSender::kNormalPriority, ssrc,
+ sequence_number++, clock_.TimeInMilliseconds(),
+ kPacketSize, false);
+ }
+
+ int64_t start = clock_.TimeInMilliseconds();
+ while (packet_sender.packets_sent() < kFirstClusterCount) {
+ int time_until_process = send_bucket_->TimeUntilNextProcess();
+ if (time_until_process <= 0) {
+ send_bucket_->Process();
+ } else {
+ clock_.AdvanceTimeMilliseconds(time_until_process);
+ }
+ }
+
+ EXPECT_EQ(pacing_observer.bytes_sent(), kPacketSize * kFirstClusterCount);
+ EXPECT_GE(pacing_observer.elapsed_time_ms(),
+ (clock_.TimeInMilliseconds() - start));
+}
+
TEST_F(PacedSenderTest, PriorityInversion) {
uint32_t ssrc = 12346;
uint16_t sequence_number = 1234;
« webrtc/modules/pacing/paced_sender.h ('K') | « webrtc/modules/pacing/paced_sender.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698