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

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

Issue 2870383003: Simple tests for Call::SetBitrateConfig. (Closed)
Patch Set: Replace test fixture with utility struct. Created 3 years, 7 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
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
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 namespace {
313 // MockSendSideCongestionController. It should be deleted once we have more 313 struct CallBitrateHelper {
314 // meaningful tests. 314 CallBitrateHelper() : CallBitrateHelper(Call::Config(&event_log_)) {}
315 TEST(CallTest, MockSendSideCongestionControllerExample) {
316 RtcEventLogNullImpl event_log;
317 Call::Config config(&event_log);
318 315
319 SimulatedClock clock(123456); 316 explicit CallBitrateHelper(const Call::Config& config)
320 PacketRouter packet_router; 317 : mock_cc_(Clock::GetRealTimeClock(), &event_log_, &packet_router_),
321 testing::NiceMock<test::MockSendSideCongestionController> mock_cc( 318 call_(Call::Create(
322 &clock, &event_log, &packet_router); 319 config,
323 auto transport_send = 320 rtc::MakeUnique<FakeRtpTransportControllerSend>(&packet_router_,
324 rtc::MakeUnique<FakeRtpTransportControllerSend>(&mock_cc); 321 &mock_cc_))) {}
325 std::unique_ptr<Call> call(Call::Create(config, std::move(transport_send))); 322
323 webrtc::Call* operator->() { return call_.get(); }
324 testing::NiceMock<test::MockSendSideCongestionController>& mock_cc() {
325 return mock_cc_;
326 }
327
328 private:
329 webrtc::RtcEventLogNullImpl event_log_;
330 PacketRouter packet_router_;
331 testing::NiceMock<test::MockSendSideCongestionController> mock_cc_;
332 std::unique_ptr<Call> call_;
333 };
334 } // namespace
335
336 TEST(CallBitrateTest, SetBitrateConfigWithValidConfigCallsSetBweBitrates) {
337 CallBitrateHelper call;
326 338
327 Call::Config::BitrateConfig bitrate_config; 339 Call::Config::BitrateConfig bitrate_config;
328 bitrate_config.min_bitrate_bps = 1; 340 bitrate_config.min_bitrate_bps = 1;
329 bitrate_config.start_bitrate_bps = 2; 341 bitrate_config.start_bitrate_bps = 2;
330 bitrate_config.max_bitrate_bps = 3; 342 bitrate_config.max_bitrate_bps = 3;
331 343
332 EXPECT_CALL(mock_cc, SetBweBitrates(1, 2, 3)); 344 EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3));
333 call->SetBitrateConfig(bitrate_config); 345 call->SetBitrateConfig(bitrate_config);
334 } 346 }
335 347
348 TEST(CallBitrateTest, SetBitrateConfigWithDifferentMinCallsSetBweBitrates) {
349 CallBitrateHelper call;
350
351 Call::Config::BitrateConfig bitrate_config;
352 bitrate_config.min_bitrate_bps = 10;
353 bitrate_config.start_bitrate_bps = 20;
354 bitrate_config.max_bitrate_bps = 30;
355 call->SetBitrateConfig(bitrate_config);
356
357 bitrate_config.min_bitrate_bps = 11;
358 EXPECT_CALL(call.mock_cc(), SetBweBitrates(11, 20, 30));
359 call->SetBitrateConfig(bitrate_config);
360 }
361
362 TEST(CallBitrateTest, SetBitrateConfigWithDifferentStartCallsSetBweBitrates) {
363 CallBitrateHelper call;
364
365 Call::Config::BitrateConfig bitrate_config;
366 bitrate_config.min_bitrate_bps = 10;
367 bitrate_config.start_bitrate_bps = 20;
368 bitrate_config.max_bitrate_bps = 30;
369 call->SetBitrateConfig(bitrate_config);
370
371 bitrate_config.start_bitrate_bps = 21;
372 EXPECT_CALL(call.mock_cc(), SetBweBitrates(10, 21, 30));
373 call->SetBitrateConfig(bitrate_config);
374 }
375
376 TEST(CallBitrateTest, SetBitrateConfigWithDifferentMaxCallsSetBweBitrates) {
377 CallBitrateHelper call;
378
379 Call::Config::BitrateConfig bitrate_config;
380 bitrate_config.min_bitrate_bps = 10;
381 bitrate_config.start_bitrate_bps = 20;
382 bitrate_config.max_bitrate_bps = 30;
383 call->SetBitrateConfig(bitrate_config);
384
385 bitrate_config.max_bitrate_bps = 31;
386 EXPECT_CALL(call.mock_cc(), SetBweBitrates(10, 20, 31));
387 call->SetBitrateConfig(bitrate_config);
388 }
389
390 TEST(CallBitrateTest, SetBitrateConfigWithSameConfigElidesSecondCall) {
391 CallBitrateHelper call;
392
393 Call::Config::BitrateConfig bitrate_config;
394 bitrate_config.min_bitrate_bps = 1;
395 bitrate_config.start_bitrate_bps = 2;
396 bitrate_config.max_bitrate_bps = 3;
397
398 EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3)).Times(1);
399 call->SetBitrateConfig(bitrate_config);
400 call->SetBitrateConfig(bitrate_config);
401 }
402
403 TEST(CallBitrateTest,
404 SetBitrateConfigWithSameMinMaxAndNegativeStartElidesSecondCall) {
405 CallBitrateHelper call;
406
407 Call::Config::BitrateConfig bitrate_config;
408 bitrate_config.min_bitrate_bps = 1;
409 bitrate_config.start_bitrate_bps = 2;
410 bitrate_config.max_bitrate_bps = 3;
411
412 EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3)).Times(1);
413 call->SetBitrateConfig(bitrate_config);
414
415 bitrate_config.start_bitrate_bps = -1;
416 call->SetBitrateConfig(bitrate_config);
417 }
418
336 } // namespace webrtc 419 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_send_stream_unittest.cc ('k') | webrtc/call/fake_rtp_transport_controller_send.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698