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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc

Issue 1704983002: Simplify CongestionController. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 <limits> 11 #include <limits>
12 #include <vector> 12 #include <vector>
13 13
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h" 19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" 20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h"
21 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" 21 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
24 #include "webrtc/modules/utility/include/mock/mock_process_thread.h"
25 #include "webrtc/system_wrappers/include/clock.h" 24 #include "webrtc/system_wrappers/include/clock.h"
26 25
27 using ::testing::_; 26 using ::testing::_;
28 using ::testing::Invoke; 27 using ::testing::Invoke;
29 28
30 namespace webrtc { 29 namespace webrtc {
31 namespace test { 30 namespace test {
32 31
33 class TransportFeedbackAdapterTest : public ::testing::Test { 32 class TransportFeedbackAdapterTest : public ::testing::Test {
34 public: 33 public:
35 TransportFeedbackAdapterTest() 34 TransportFeedbackAdapterTest()
36 : clock_(0), 35 : clock_(0),
37 bitrate_estimator_(nullptr), 36 bitrate_estimator_(nullptr),
38 bitrate_controller_(this), 37 bitrate_controller_(this),
39 receiver_estimated_bitrate_(0) {} 38 receiver_estimated_bitrate_(0) {}
40 39
41 virtual ~TransportFeedbackAdapterTest() {} 40 virtual ~TransportFeedbackAdapterTest() {}
42 41
43 virtual void SetUp() { 42 virtual void SetUp() {
44 adapter_.reset(new TransportFeedbackAdapter(&bitrate_controller_, &clock_, 43 adapter_.reset(new TransportFeedbackAdapter(&bitrate_controller_, &clock_));
45 &process_thread_));
46 44
47 bitrate_estimator_ = new MockRemoteBitrateEstimator(); 45 bitrate_estimator_ = new MockRemoteBitrateEstimator();
48 EXPECT_CALL(process_thread_, RegisterModule(bitrate_estimator_)).Times(1);
49 adapter_->SetBitrateEstimator(bitrate_estimator_); 46 adapter_->SetBitrateEstimator(bitrate_estimator_);
50 } 47 }
51 48
52 virtual void TearDown() { 49 virtual void TearDown() {
53 EXPECT_CALL(process_thread_, DeRegisterModule(bitrate_estimator_)).Times(1);
54 adapter_.reset(); 50 adapter_.reset();
55 } 51 }
56 52
57 protected: 53 protected:
58 // Proxy class used since TransportFeedbackAdapter will own the instance 54 // Proxy class used since TransportFeedbackAdapter will own the instance
59 // passed at construction. 55 // passed at construction.
60 class MockBitrateControllerAdapter : public MockBitrateController { 56 class MockBitrateControllerAdapter : public MockBitrateController {
61 public: 57 public:
62 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) 58 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner)
63 : MockBitrateController(), owner_(owner) {} 59 : MockBitrateController(), owner_(owner) {}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 98
103 // Utility method, to reset arrival_time_ms before adding send time. 99 // Utility method, to reset arrival_time_ms before adding send time.
104 void OnSentPacket(PacketInfo info) { 100 void OnSentPacket(PacketInfo info) {
105 info.arrival_time_ms = 0; 101 info.arrival_time_ms = 0;
106 adapter_->AddPacket(info.sequence_number, info.payload_size, 102 adapter_->AddPacket(info.sequence_number, info.payload_size,
107 info.was_paced); 103 info.was_paced);
108 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); 104 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms);
109 } 105 }
110 106
111 SimulatedClock clock_; 107 SimulatedClock clock_;
112 MockProcessThread process_thread_;
113 MockRemoteBitrateEstimator* bitrate_estimator_; 108 MockRemoteBitrateEstimator* bitrate_estimator_;
114 MockBitrateControllerAdapter bitrate_controller_; 109 MockBitrateControllerAdapter bitrate_controller_;
115 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_; 110 rtc::scoped_ptr<TransportFeedbackAdapter> adapter_;
116 111
117 uint32_t receiver_estimated_bitrate_; 112 uint32_t receiver_estimated_bitrate_;
118 }; 113 };
119 114
120 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { 115 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) {
121 std::vector<PacketInfo> packets; 116 std::vector<PacketInfo> packets;
122 packets.push_back(PacketInfo(100, 200, 0, 1500, true)); 117 packets.push_back(PacketInfo(100, 200, 0, 1500, true));
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 })); 310 }));
316 adapter_->OnTransportFeedback(*feedback.get()); 311 adapter_->OnTransportFeedback(*feedback.get());
317 312
318 sent_packets.push_back(info); 313 sent_packets.push_back(info);
319 314
320 ComparePacketVectors(sent_packets, received_feedback); 315 ComparePacketVectors(sent_packets, received_feedback);
321 } 316 }
322 317
323 } // namespace test 318 } // namespace test
324 } // namespace webrtc 319 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698