OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Let the pacer not be full next time the controller checks. | 101 // Let the pacer not be full next time the controller checks. |
102 // |OnNetworkChanged| should be called with the new estimate. | 102 // |OnNetworkChanged| should be called with the new estimate. |
103 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) | 103 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
104 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); | 104 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
105 EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_ * 2, _, _)); | 105 EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_ * 2, _, _)); |
106 clock_.AdvanceTimeMilliseconds(25); | 106 clock_.AdvanceTimeMilliseconds(25); |
107 controller_->Process(); | 107 controller_->Process(); |
108 } | 108 } |
109 | 109 |
| 110 TEST_F(CongestionControllerTest, SignalNetworkState) { |
| 111 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _)); |
| 112 controller_->SignalNetworkState(kNetworkDown); |
| 113 controller_->Process(); |
| 114 |
| 115 EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_, _, _)); |
| 116 controller_->SignalNetworkState(kNetworkUp); |
| 117 controller_->Process(); |
| 118 |
| 119 controller_->SignalNetworkState(kNetworkDown); |
| 120 controller_->SignalNetworkState(kNetworkUp); |
| 121 controller_->Process(); |
| 122 |
| 123 controller_->SignalNetworkState(kNetworkDown); |
| 124 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _)); |
| 125 controller_->Process(); |
| 126 |
| 127 controller_->SignalNetworkState(kNetworkUp); |
| 128 controller_->SignalNetworkState(kNetworkDown); |
| 129 controller_->Process(); |
| 130 } |
| 131 |
| 132 TEST_F(CongestionControllerTest, |
| 133 SignalNetworkStateAndQueueIsFullAndEstimateChange) { |
| 134 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
| 135 .WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1)); |
| 136 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _)); |
| 137 controller_->Process(); |
| 138 |
| 139 // Queue is full and network is down. Expect no bitrate change. |
| 140 controller_->SignalNetworkState(kNetworkDown); |
| 141 controller_->Process(); |
| 142 |
| 143 // Queue is full but network is up. Expect no bitrate change. |
| 144 controller_->SignalNetworkState(kNetworkUp); |
| 145 controller_->Process(); |
| 146 |
| 147 // Receive new estimate but let the queue still be full. |
| 148 bandwidth_observer_->OnReceivedEstimatedBitrate(initial_bitrate_bps_ * 2); |
| 149 clock_.AdvanceTimeMilliseconds(25); |
| 150 controller_->Process(); |
| 151 |
| 152 // Let the pacer not be full next time the controller checks. |
| 153 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) |
| 154 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); |
| 155 EXPECT_CALL(observer_, OnNetworkChanged(initial_bitrate_bps_ * 2, _, _)); |
| 156 controller_->Process(); |
| 157 } |
| 158 |
110 } // namespace test | 159 } // namespace test |
111 } // namespace webrtc | 160 } // namespace webrtc |
OLD | NEW |