Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 config.remote_ssrc = 5548; | 302 config.remote_ssrc = 5548; |
| 303 stream = call->CreateFlexfecReceiveStream(config); | 303 stream = call->CreateFlexfecReceiveStream(config); |
| 304 EXPECT_NE(stream, nullptr); | 304 EXPECT_NE(stream, nullptr); |
| 305 streams.push_back(stream); | 305 streams.push_back(stream); |
| 306 | 306 |
| 307 for (auto s : streams) { | 307 for (auto s : streams) { |
| 308 call->DestroyFlexfecReceiveStream(s); | 308 call->DestroyFlexfecReceiveStream(s); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 // TODO(zstein): This is just a motivating example for | 312 class CallBitrateTest : public testing::Test { |
|
the sun
2017/05/16 21:30:11
I don't really see the point of using a fixture he
Zach Stein
2017/05/17 18:00:12
The utility struct looks cleaner to me too - thank
| |
| 313 // MockSendSideCongestionController. It should be deleted once we have more | 313 public: |
| 314 // meaningful tests. | 314 void SetUp() { |
| 315 TEST(CallTest, MockSendSideCongestionControllerExample) { | 315 Clock* clock = Clock::GetRealTimeClock(); |
| 316 RtcEventLogNullImpl event_log; | 316 mock_cc_ = rtc::MakeUnique< |
| 317 Call::Config config(&event_log); | 317 testing::NiceMock<test::MockSendSideCongestionController>>( |
| 318 clock, &event_log_, &packet_router_); | |
| 319 } | |
| 318 | 320 |
| 319 SimulatedClock clock(123456); | 321 void CreateCall() { |
| 320 PacketRouter packet_router; | 322 Call::Config config(&event_log_); |
| 321 testing::NiceMock<test::MockSendSideCongestionController> mock_cc( | 323 CreateCall(config); |
| 322 &clock, &event_log, &packet_router); | 324 } |
| 323 auto transport_send = | 325 |
| 324 rtc::MakeUnique<FakeRtpTransportControllerSend>(&mock_cc); | 326 void CreateCall(const Call::Config& config) { |
| 325 std::unique_ptr<Call> call(Call::Create(config, std::move(transport_send))); | 327 std::unique_ptr<RtpTransportControllerSendInterface> fake_controller = |
| 328 rtc::MakeUnique<FakeRtpTransportControllerSend>(&packet_router_, | |
| 329 mock_cc_.get()); | |
| 330 call_.reset(Call::Create(config, std::move(fake_controller))); | |
| 331 } | |
| 332 | |
| 333 std::unique_ptr<testing::NiceMock<test::MockSendSideCongestionController>> | |
| 334 mock_cc_; | |
| 335 std::unique_ptr<Call> call_; | |
| 336 webrtc::RtcEventLogNullImpl event_log_; | |
| 337 | |
| 338 private: | |
| 339 PacketRouter packet_router_; | |
| 340 }; | |
| 341 | |
| 342 TEST_F(CallBitrateTest, SetBitrateConfigWithValidConfigCallsSetBweBitrates) { | |
| 343 CreateCall(); | |
| 326 | 344 |
| 327 Call::Config::BitrateConfig bitrate_config; | 345 Call::Config::BitrateConfig bitrate_config; |
| 328 bitrate_config.min_bitrate_bps = 1; | 346 bitrate_config.min_bitrate_bps = 1; |
| 329 bitrate_config.start_bitrate_bps = 2; | 347 bitrate_config.start_bitrate_bps = 2; |
| 330 bitrate_config.max_bitrate_bps = 3; | 348 bitrate_config.max_bitrate_bps = 3; |
| 331 | 349 |
| 332 EXPECT_CALL(mock_cc, SetBweBitrates(1, 2, 3)); | 350 EXPECT_CALL(*mock_cc_, SetBweBitrates(1, 2, 3)); |
| 333 call->SetBitrateConfig(bitrate_config); | 351 call_->SetBitrateConfig(bitrate_config); |
| 352 } | |
| 353 | |
| 354 TEST_F(CallBitrateTest, SetBitrateConfigWithDifferentMinCallsSetBweBitrates) { | |
| 355 CreateCall(); | |
| 356 | |
| 357 Call::Config::BitrateConfig bitrate_config; | |
| 358 bitrate_config.min_bitrate_bps = 10; | |
| 359 bitrate_config.start_bitrate_bps = 20; | |
| 360 bitrate_config.max_bitrate_bps = 30; | |
| 361 call_->SetBitrateConfig(bitrate_config); | |
| 362 | |
| 363 bitrate_config.min_bitrate_bps = 11; | |
| 364 EXPECT_CALL(*mock_cc_, SetBweBitrates(11, 20, 30)); | |
| 365 call_->SetBitrateConfig(bitrate_config); | |
| 366 } | |
| 367 | |
| 368 TEST_F(CallBitrateTest, SetBitrateConfigWithDifferentStartCallsSetBweBitrates) { | |
| 369 CreateCall(); | |
| 370 | |
| 371 Call::Config::BitrateConfig bitrate_config; | |
| 372 bitrate_config.min_bitrate_bps = 10; | |
| 373 bitrate_config.start_bitrate_bps = 20; | |
| 374 bitrate_config.max_bitrate_bps = 30; | |
| 375 call_->SetBitrateConfig(bitrate_config); | |
| 376 | |
| 377 bitrate_config.start_bitrate_bps = 21; | |
| 378 EXPECT_CALL(*mock_cc_, SetBweBitrates(10, 21, 30)); | |
| 379 call_->SetBitrateConfig(bitrate_config); | |
| 380 } | |
| 381 | |
| 382 TEST_F(CallBitrateTest, SetBitrateConfigWithDifferentMaxCallsSetBweBitrates) { | |
| 383 CreateCall(); | |
| 384 | |
| 385 Call::Config::BitrateConfig bitrate_config; | |
| 386 bitrate_config.min_bitrate_bps = 10; | |
| 387 bitrate_config.start_bitrate_bps = 20; | |
| 388 bitrate_config.max_bitrate_bps = 30; | |
| 389 call_->SetBitrateConfig(bitrate_config); | |
| 390 | |
| 391 bitrate_config.max_bitrate_bps = 31; | |
| 392 EXPECT_CALL(*mock_cc_, SetBweBitrates(10, 20, 31)); | |
| 393 call_->SetBitrateConfig(bitrate_config); | |
| 394 } | |
| 395 | |
| 396 TEST_F(CallBitrateTest, SetBitrateConfigWithSameConfigElidesSecondCall) { | |
| 397 CreateCall(); | |
| 398 | |
| 399 Call::Config::BitrateConfig bitrate_config; | |
| 400 bitrate_config.min_bitrate_bps = 1; | |
| 401 bitrate_config.start_bitrate_bps = 2; | |
| 402 bitrate_config.max_bitrate_bps = 3; | |
| 403 | |
| 404 EXPECT_CALL(*mock_cc_, SetBweBitrates(1, 2, 3)).Times(1); | |
| 405 call_->SetBitrateConfig(bitrate_config); | |
| 406 call_->SetBitrateConfig(bitrate_config); | |
| 407 } | |
| 408 | |
| 409 TEST_F(CallBitrateTest, | |
| 410 SetBitrateConfigWithSameMinMaxAndNegativeStartElidesSecondCall) { | |
| 411 CreateCall(); | |
| 412 | |
| 413 Call::Config::BitrateConfig bitrate_config; | |
| 414 bitrate_config.min_bitrate_bps = 1; | |
| 415 bitrate_config.start_bitrate_bps = 2; | |
| 416 bitrate_config.max_bitrate_bps = 3; | |
| 417 | |
| 418 EXPECT_CALL(*mock_cc_, SetBweBitrates(1, 2, 3)).Times(1); | |
| 419 call_->SetBitrateConfig(bitrate_config); | |
| 420 | |
| 421 bitrate_config.start_bitrate_bps = -1; | |
| 422 call_->SetBitrateConfig(bitrate_config); | |
| 334 } | 423 } |
| 335 | 424 |
| 336 } // namespace webrtc | 425 } // namespace webrtc |
| OLD | NEW |