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

Unified Diff: webrtc/call/bitrate_allocator_unittest.cc

Issue 1972183004: Reland "Remove ViEEncoder::SetNetworkStatus" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix bug in BitrateAllocator::Allocate(bitrate) Created 4 years, 7 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
« no previous file with comments | « webrtc/call/bitrate_allocator.cc ('k') | webrtc/modules/congestion_controller/congestion_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/bitrate_allocator_unittest.cc
diff --git a/webrtc/call/bitrate_allocator_unittest.cc b/webrtc/call/bitrate_allocator_unittest.cc
index 253d3fb3df54cda2e5491633090479218cc306d4..4017645c1d6f022988184fb5ac67b44ccc509649 100644
--- a/webrtc/call/bitrate_allocator_unittest.cc
+++ b/webrtc/call/bitrate_allocator_unittest.cc
@@ -222,4 +222,32 @@ TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) {
allocator_->RemoveObserver(&bitrate_observer_2);
allocator_->RemoveObserver(&bitrate_observer_3);
}
+
+TEST_F(BitrateAllocatorTest, AddObserverWhileNetworkDown) {
+ TestBitrateObserver bitrate_observer_1;
+ int start_bitrate =
+ allocator_->AddObserver(&bitrate_observer_1, 50000, 400000, true);
+ EXPECT_EQ(300000, start_bitrate);
+
+ // Set network down, ie, no available bitrate.
+ allocator_->OnNetworkChanged(0, 0, 0);
+
+ EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_);
+
+ TestBitrateObserver bitrate_observer_2;
+ start_bitrate =
+ allocator_->AddObserver(&bitrate_observer_2, 50000, 400000, true);
+
+ // Expect the start_bitrate to be set as if the network was still up but that
+ // the new observer have been notified that the network is down.
+ EXPECT_EQ(300000 / 2, start_bitrate);
+ EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_);
+ EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
+
+ // Set network back up.
+ allocator_->OnNetworkChanged(1500000, 0, 50);
+ EXPECT_EQ(750000u, bitrate_observer_1.last_bitrate_);
+ EXPECT_EQ(750000u, bitrate_observer_2.last_bitrate_);
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/call/bitrate_allocator.cc ('k') | webrtc/modules/congestion_controller/congestion_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698