Chromium Code Reviews| Index: webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| diff --git a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| index 56219363fdf70c06e1abe54267fcb569537e31da..3f140684f07a5b6876556ab126a1076e9d16015a 100644 |
| --- a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| +++ b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc |
| @@ -28,6 +28,8 @@ using testing::Return; |
| using testing::SaveArg; |
| using testing::StrictMock; |
| +namespace webrtc { |
| + |
| namespace { |
| const webrtc::PacedPacketInfo kPacingInfo0(0, 5, 2000); |
| const webrtc::PacedPacketInfo kPacingInfo1(1, 8, 4000); |
| @@ -40,9 +42,17 @@ uint32_t AbsSendTime(int64_t t, int64_t denom) { |
| return (((t << 18) + (denom >> 1)) / denom) & 0x00fffffful; |
| } |
| +class MockPacketRouter : public PacketRouter { |
| + public: |
| + MOCK_METHOD2(OnReceiveBitrateChanged, |
| + void(const std::vector<uint32_t>& ssrcs, |
| + uint32_t bitrate)); |
| +}; |
| + |
| +const uint32_t kInitialBitrateBps = 60000; |
| + |
| } // namespace |
| -namespace webrtc { |
| namespace test { |
| class CongestionControllerTest : public ::testing::Test { |
| @@ -143,7 +153,6 @@ class CongestionControllerTest : public ::testing::Test { |
| std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; |
| PacketRouter packet_router_; |
| std::unique_ptr<CongestionController> controller_; |
| - const uint32_t kInitialBitrateBps = 60000; |
| rtc::Optional<uint32_t> target_bitrate_bps_; |
| }; |
| @@ -335,13 +344,11 @@ TEST_F(CongestionControllerTest, GetProbingInterval) { |
| controller_->Process(); |
| } |
| -TEST_F(CongestionControllerTest, OnReceivedPacketWithAbsSendTime) { |
| - NiceMock<MockCongestionObserver> observer; |
| - StrictMock<MockRemoteBitrateObserver> remote_bitrate_observer; |
| - std::unique_ptr<PacedSender> pacer(new NiceMock<MockPacedSender>()); |
| - controller_.reset( |
| - new CongestionController(&clock_, &observer, &remote_bitrate_observer, |
| - &event_log_, &packet_router_, std::move(pacer))); |
| +TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) { |
|
nisse-webrtc
2017/04/03 11:32:35
This test works fine without a test fixture. At so
|
| + StrictMock<MockPacketRouter> packet_router; |
| + SimulatedClock clock_(123456); |
| + |
| + ReceiveSideCongestionController controller(&clock_, &packet_router); |
| size_t payload_size = 1000; |
| RTPHeader header; |
| @@ -349,14 +356,14 @@ TEST_F(CongestionControllerTest, OnReceivedPacketWithAbsSendTime) { |
| header.extension.hasAbsoluteSendTime = true; |
| std::vector<unsigned int> ssrcs; |
| - EXPECT_CALL(remote_bitrate_observer, OnReceiveBitrateChanged(_, _)) |
| + EXPECT_CALL(packet_router, OnReceiveBitrateChanged(_, _)) |
| .WillRepeatedly(SaveArg<0>(&ssrcs)); |
| for (int i = 0; i < 10; ++i) { |
| clock_.AdvanceTimeMilliseconds((1000 * payload_size) / kInitialBitrateBps); |
| int64_t now_ms = clock_.TimeInMilliseconds(); |
| header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000); |
| - controller_->OnReceivedPacket(now_ms, payload_size, header); |
| + controller.OnReceivedPacket(now_ms, payload_size, header); |
| } |
| ASSERT_EQ(1u, ssrcs.size()); |