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

Side by Side Diff: webrtc/modules/congestion_controller/probe_controller_unittest.cc

Issue 2235373004: Probing: Add support for exponential startup probing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@fix_probing2
Patch Set: Address comments and add unit tests Created 4 years, 3 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "webrtc/base/logging.h"
14 #include "webrtc/modules/congestion_controller/probe_controller.h"
15 #include "webrtc/modules/pacing/mock/mock_paced_sender.h"
16 #include "webrtc/system_wrappers/include/clock.h"
17
18 using testing::_;
19 using testing::AtLeast;
20 using testing::NiceMock;
21
22 namespace webrtc {
23 namespace test {
24
25 namespace {
26
27 constexpr int kMinBitrateBps = 100;
28 constexpr int kStartBitrateBps = 300;
29 constexpr int kMaxBitrateBps = 1000;
30
31 } // namespace
32
33 class ProbeControllerTest : public ::testing::Test {
34 protected:
35 ProbeControllerTest() : clock_(0) {
36 probe_controller_.reset(new ProbeController(&pacer_, &clock_));
37 }
38 ~ProbeControllerTest() override {}
39
40 SimulatedClock clock_;
41 NiceMock<MockPacedSender> pacer_;
42 std::unique_ptr<ProbeController> probe_controller_;
43 };
44
45 TEST_F(ProbeControllerTest, InitiatesProbingAtStart) {
46 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2));
47 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
48 kMaxBitrateBps);
49 }
50
51 TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) {
52 EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2));
53 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
54 kMaxBitrateBps);
55 clock_.AdvanceTimeMilliseconds(25);
56
57 probe_controller_->SetEstimatedBitrate(kStartBitrateBps);
58 EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _));
59 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
60 kMaxBitrateBps + 100);
61 }
62
63 TEST_F(ProbeControllerTest, TestExponentialProbing) {
64 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
65 kMaxBitrateBps);
66 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _));
67 probe_controller_->SetEstimatedBitrate(1800);
68 }
69
70 TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) {
71 probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
72 kMaxBitrateBps);
73
74 // Advance far enough to cause a time out in waiting for probing result.
75 clock_.AdvanceTimeMilliseconds(5000);
76 EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0);
77 probe_controller_->SetEstimatedBitrate(1800);
78 }
79
80 } // namespace test
81 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698