Probing: Add support for exponential startup probing

Adds support for exponentially probing the bandwidth at start-up to allow
ramp-up to real capacity of the network.

BUG=webrtc:6332
R=philipel@webrtc.org, stefan@webrtc.org

Review URL: https://codereview.webrtc.org/2235373004 .

Cr-Commit-Position: refs/heads/master@{#14189}
diff --git a/webrtc/modules/congestion_controller/probe_controller_unittest.cc b/webrtc/modules/congestion_controller/probe_controller_unittest.cc
new file mode 100644
index 0000000..6932775
--- /dev/null
+++ b/webrtc/modules/congestion_controller/probe_controller_unittest.cc
@@ -0,0 +1,82 @@
+/*
+ *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+#include <memory>
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/modules/congestion_controller/probe_controller.h"
+#include "webrtc/modules/pacing/mock/mock_paced_sender.h"
+#include "webrtc/system_wrappers/include/clock.h"
+
+using testing::_;
+using testing::AtLeast;
+using testing::NiceMock;
+
+namespace webrtc {
+namespace test {
+
+namespace {
+
+constexpr int kMinBitrateBps = 100;
+constexpr int kStartBitrateBps = 300;
+constexpr int kMaxBitrateBps = 1000;
+
+}  // namespace
+
+class ProbeControllerTest : public ::testing::Test {
+ protected:
+  ProbeControllerTest() : clock_(0) {
+    probe_controller_.reset(new ProbeController(&pacer_, &clock_));
+  }
+  ~ProbeControllerTest() override {}
+
+  SimulatedClock clock_;
+  NiceMock<MockPacedSender> pacer_;
+  std::unique_ptr<ProbeController> probe_controller_;
+};
+
+TEST_F(ProbeControllerTest, InitiatesProbingAtStart) {
+  EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2));
+  probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
+                                 kMaxBitrateBps);
+}
+
+TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) {
+  EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2));
+  probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
+                                 kMaxBitrateBps);
+  clock_.AdvanceTimeMilliseconds(25);
+
+  probe_controller_->SetEstimatedBitrate(kStartBitrateBps);
+  EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _));
+  probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
+                                 kMaxBitrateBps + 100);
+}
+
+TEST_F(ProbeControllerTest, TestExponentialProbing) {
+  probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
+                                 kMaxBitrateBps);
+  EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _));
+  probe_controller_->SetEstimatedBitrate(1800);
+}
+
+TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) {
+  probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps,
+                                 kMaxBitrateBps);
+
+  // Advance far enough to cause a time out in waiting for probing result.
+  clock_.AdvanceTimeMilliseconds(5000);
+  EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0);
+  probe_controller_->SetEstimatedBitrate(1800);
+}
+
+}  // namespace test
+}  // namespace webrtc