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

Side by Side Diff: webrtc/call/bitrate_allocator_unittest.cc

Issue 1441673002: Move BitrateAllocator from BitrateController logic to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <vector> 12 #include <vector>
13 13
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webrtc/modules/bitrate_controller/include/bitrate_allocator.h" 15 #include "webrtc/call/bitrate_allocator.h"
16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 class TestBitrateObserver : public BitrateObserver { 20 class TestBitrateObserver : public BitrateObserver {
21 public: 21 public:
22 TestBitrateObserver() 22 TestBitrateObserver()
23 : last_bitrate_(0), last_fraction_loss_(0), last_rtt_(0) {} 23 : last_bitrate_(0), last_fraction_loss_(0), last_rtt_(0) {}
24 24
25 virtual void OnNetworkChanged(uint32_t bitrate, 25 virtual void OnNetworkChanged(uint32_t bitrate,
(...skipping 20 matching lines...) Expand all
46 46
47 TEST_F(BitrateAllocatorTest, UpdatingBitrateObserver) { 47 TEST_F(BitrateAllocatorTest, UpdatingBitrateObserver) {
48 TestBitrateObserver bitrate_observer; 48 TestBitrateObserver bitrate_observer;
49 int start_bitrate = 49 int start_bitrate =
50 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000); 50 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000);
51 EXPECT_EQ(300000, start_bitrate); 51 EXPECT_EQ(300000, start_bitrate);
52 allocator_->OnNetworkChanged(200000, 0, 0); 52 allocator_->OnNetworkChanged(200000, 0, 0);
53 EXPECT_EQ(200000u, bitrate_observer.last_bitrate_); 53 EXPECT_EQ(200000u, bitrate_observer.last_bitrate_);
54 54
55 // TODO(pbos): Expect capping to 1.5M instead of 3M when not boosting the max 55 // TODO(pbos): Expect capping to 1.5M instead of 3M when not boosting the max
56 // bitrate for FEC/retransmissions (see TODO in BitrateAllocator). 56 // bitrate for FEC/retransmissions (see todo in BitrateAllocator).
57 allocator_->OnNetworkChanged(4000000, 0, 0); 57 allocator_->OnNetworkChanged(4000000, 0, 0);
58 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_); 58 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_);
59 start_bitrate = 59 start_bitrate =
60 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 4000000); 60 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 4000000);
61 EXPECT_EQ(4000000, start_bitrate); 61 EXPECT_EQ(4000000, start_bitrate);
62 62
63 start_bitrate = 63 start_bitrate =
64 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000); 64 allocator_->AddBitrateObserver(&bitrate_observer, 100000, 1500000);
65 EXPECT_EQ(3000000, start_bitrate); 65 EXPECT_EQ(3000000, start_bitrate);
66 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_); 66 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 allocator_->OnNetworkChanged(1000, 0, 0); 203 allocator_->OnNetworkChanged(1000, 0, 0);
204 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap. 204 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap.
205 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap. 205 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap.
206 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap. 206 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap.
207 207
208 allocator_->RemoveBitrateObserver(&bitrate_observer_1); 208 allocator_->RemoveBitrateObserver(&bitrate_observer_1);
209 allocator_->RemoveBitrateObserver(&bitrate_observer_2); 209 allocator_->RemoveBitrateObserver(&bitrate_observer_2);
210 allocator_->RemoveBitrateObserver(&bitrate_observer_3); 210 allocator_->RemoveBitrateObserver(&bitrate_observer_3);
211 } 211 }
212 } // namespace webrtc 212 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698