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

Unified Diff: webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc

Issue 2306083002: Adding basic implementation of AudioNetworkAdaptor. (Closed)
Patch Set: more polish 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..53a2c2ccbdd11dcad148467cdd944998c339ba2e
--- /dev/null
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc
@@ -0,0 +1,72 @@
+/*
+ * 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 <utility>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h"
+#include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller.h"
+
+namespace webrtc {
+
+using ::testing::NiceMock;
+
+namespace {
+
+constexpr size_t kNumControllers = 3;
+
+struct ControllerManagerStates {
+ std::unique_ptr<ControllerManager> controller_manager;
+ std::vector<MockController*> mock_controllers;
+};
+
+ControllerManagerStates CreateControllerManager() {
+ ControllerManagerStates states;
+ std::vector<std::unique_ptr<Controller>> controllers;
+ for (size_t i = 0; i < kNumControllers; ++i) {
+ auto controller =
+ std::unique_ptr<MockController>(new NiceMock<MockController>());
+ EXPECT_CALL(*controller, Die());
+ states.mock_controllers.push_back(controller.get());
+ controllers.push_back(std::move(controller));
+ }
+ states.controller_manager.reset(new ControllerManagerImpl(
+ ControllerManagerImpl::Config(), std::move(controllers)));
+ return states;
+}
+
+} // namespace
+
+TEST(ControllerManagerTest, GetControllersReturnAllControllers) {
+ auto states = CreateControllerManager();
+
+ auto check = states.controller_manager->GetControllers();
+ // Verify that controllers in |check| are one-to-one mapped to those in
+ // |mock_controllers_|.
+ EXPECT_EQ(states.mock_controllers.size(), check.size());
+ for (auto& controller : check)
+ EXPECT_NE(states.mock_controllers.end(),
+ std::find(states.mock_controllers.begin(),
+ states.mock_controllers.end(), controller));
+}
+
+TEST(ControllerManagerTest, ControllersInDefaultOrderOnEmptyNetworkMetrics) {
+ auto states = CreateControllerManager();
+
+ // |network_metrics| are empty, and the controllers are supposed to follow the
+ // default order.
+ Controller::NetworkMetrics network_metrics;
+ auto check = states.controller_manager->GetSortedControllers(network_metrics);
+ EXPECT_EQ(states.mock_controllers.size(), check.size());
+ for (size_t i = 0; i < states.mock_controllers.size(); ++i)
+ EXPECT_EQ(states.mock_controllers[i], check[i]);
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698