From 342695d068400987a376f2df045d750a2a47979b Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 9 Apr 2018 14:41:57 +0200 Subject: [PATCH] Removes network ostream operators. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ostream operators does not work consistently with gtest since the definitions would have to be included before the first include of gtest. This is tricky to ensure and the end result is that the operators will sometimes work and sometimes not without obvious explanations. To avoid causing confusing behavior, this CL removes the operators pending a better solution. Bug: None Change-Id: I66bead0efb7246d368359ddf9e9bfad9d67c05da Reviewed-on: https://webrtc-review.googlesource.com/68640 Reviewed-by: Björn Terelius Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#22808} --- .../bbr/windowed_filter_unittest.cc | 19 ++++--- .../goog_cc/probe_controller_unittest.cc | 1 - .../network_control/BUILD.gn | 2 - .../test/network_control_tester.cc | 20 ++++--- .../test/network_ostream_operators.cc | 57 ------------------- .../test/network_ostream_operators.h | 44 -------------- 6 files changed, 22 insertions(+), 121 deletions(-) delete mode 100644 modules/congestion_controller/network_control/test/network_ostream_operators.cc delete mode 100644 modules/congestion_controller/network_control/test/network_ostream_operators.h diff --git a/modules/congestion_controller/bbr/windowed_filter_unittest.cc b/modules/congestion_controller/bbr/windowed_filter_unittest.cc index 8a8d726e70..10888f5e99 100644 --- a/modules/congestion_controller/bbr/windowed_filter_unittest.cc +++ b/modules/congestion_controller/bbr/windowed_filter_unittest.cc @@ -11,7 +11,7 @@ #include "modules/congestion_controller/bbr/windowed_filter.h" #include "modules/congestion_controller/bbr/rtt_stats.h" -#include "modules/congestion_controller/network_control/test/network_ostream_operators.h" +#include "modules/congestion_controller/network_control/include/network_units_to_string.h" #include "test/gtest.h" namespace webrtc { @@ -33,11 +33,11 @@ class WindowedFilterTest : public ::testing::Test { TimeDelta rtt_sample = TimeDelta::ms(10); for (int i = 0; i < 5; ++i) { windowed_min_rtt_.Update(rtt_sample, now_ms); - RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << rtt_sample + RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << ToString(rtt_sample) << " mins: " - << " " << windowed_min_rtt_.GetBest() << " " - << windowed_min_rtt_.GetSecondBest() << " " - << windowed_min_rtt_.GetThirdBest(); + << " " << ToString(windowed_min_rtt_.GetBest()) << " " + << ToString(windowed_min_rtt_.GetSecondBest()) << " " + << ToString(windowed_min_rtt_.GetThirdBest()); now_ms += 25; rtt_sample = rtt_sample + TimeDelta::ms(10); } @@ -55,10 +55,11 @@ class WindowedFilterTest : public ::testing::Test { DataRate bw_sample = DataRate::bps(1000); for (int i = 0; i < 5; ++i) { windowed_max_bw_.Update(bw_sample, now_ms); - RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << bw_sample << " maxs: " - << " " << windowed_max_bw_.GetBest() << " " - << windowed_max_bw_.GetSecondBest() << " " - << windowed_max_bw_.GetThirdBest(); + RTC_LOG(LS_VERBOSE) << "i: " << i << " sample: " << ToString(bw_sample) + << " maxs: " + << " " << ToString(windowed_max_bw_.GetBest()) << " " + << ToString(windowed_max_bw_.GetSecondBest()) << " " + << ToString(windowed_max_bw_.GetThirdBest()); now_ms += 25; bw_sample = DataRate::bps(bw_sample.bps() - 100); } diff --git a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc index 52903acf49..470c2b8a44 100644 --- a/modules/congestion_controller/goog_cc/probe_controller_unittest.cc +++ b/modules/congestion_controller/goog_cc/probe_controller_unittest.cc @@ -11,7 +11,6 @@ #include "modules/congestion_controller/goog_cc/probe_controller.h" #include "modules/congestion_controller/network_control/include/network_types.h" -#include "modules/congestion_controller/network_control/test/network_ostream_operators.h" #include "rtc_base/logging.h" #include "system_wrappers/include/clock.h" #include "test/gmock.h" diff --git a/modules/congestion_controller/network_control/BUILD.gn b/modules/congestion_controller/network_control/BUILD.gn index 4ced3f2e80..a60b331129 100644 --- a/modules/congestion_controller/network_control/BUILD.gn +++ b/modules/congestion_controller/network_control/BUILD.gn @@ -34,8 +34,6 @@ if (rtc_include_tests) { "test/mock_network_control.h", "test/network_control_tester.cc", "test/network_control_tester.h", - "test/network_ostream_operators.cc", - "test/network_ostream_operators.h", ] deps = [ ":network_control", diff --git a/modules/congestion_controller/network_control/test/network_control_tester.cc b/modules/congestion_controller/network_control/test/network_control_tester.cc index 08d62ef15f..0bfef77927 100644 --- a/modules/congestion_controller/network_control/test/network_control_tester.cc +++ b/modules/congestion_controller/network_control/test/network_control_tester.cc @@ -9,7 +9,7 @@ */ #include "modules/congestion_controller/network_control/test/network_control_tester.h" -#include "modules/congestion_controller/network_control/test/network_ostream_operators.h" +#include "modules/congestion_controller/network_control/include/network_units_to_string.h" #include @@ -21,23 +21,27 @@ namespace { void Update(NetworkControlUpdate* target, const NetworkControlUpdate& update) { if (update.congestion_window) { RTC_LOG(LS_INFO) << "Received window=" - << update.congestion_window->data_window << "\n"; + << ToString(update.congestion_window->data_window) << "\n"; target->congestion_window = update.congestion_window; } if (update.pacer_config) { - RTC_LOG(LS_INFO) << "Received pacing at:" << update.pacer_config->at_time - << ": rate=" << update.pacer_config->data_rate() << "\n"; + RTC_LOG(LS_INFO) << "Received pacing at:" + << ToString(update.pacer_config->at_time) + << ": rate=" << ToString(update.pacer_config->data_rate()) + << "\n"; target->pacer_config = update.pacer_config; } if (update.target_rate) { - RTC_LOG(LS_INFO) << "Received target at:" << update.target_rate->at_time - << ": rate=" << update.target_rate->target_rate << "\n"; + RTC_LOG(LS_INFO) << "Received target at:" + << ToString(update.target_rate->at_time) + << ": rate=" << ToString(update.target_rate->target_rate) + << "\n"; target->target_rate = update.target_rate; } for (const auto& probe : update.probe_cluster_configs) { target->probe_cluster_configs.push_back(probe); - RTC_LOG(LS_INFO) << "Received probe at:" << probe.at_time - << ": target=" << probe.target_data_rate << "\n"; + RTC_LOG(LS_INFO) << "Received probe at:" << ToString(probe.at_time) + << ": target=" << ToString(probe.target_data_rate) << "\n"; } } } // namespace diff --git a/modules/congestion_controller/network_control/test/network_ostream_operators.cc b/modules/congestion_controller/network_control/test/network_ostream_operators.cc deleted file mode 100644 index 353c3c8c58..0000000000 --- a/modules/congestion_controller/network_control/test/network_ostream_operators.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2018 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 "modules/congestion_controller/network_control/test/network_ostream_operators.h" -#include "modules/congestion_controller/network_control/include/network_units_to_string.h" - -namespace webrtc { - -std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const DataRate& value) { - return os << ToString(value); -} -std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const DataSize& value) { - return os << ToString(value); -} -std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const Timestamp& value) { - return os << ToString(value); -} -std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const TimeDelta& value) { - return os << ToString(value); -} - -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const CongestionWindow& window) { - return os << "CongestionWindow(...)"; -} -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const ProbeClusterConfig& config) { - return os << "ProbeClusterConfig(...)"; -} -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const PacerConfig& config) { - return os << "PacerConfig(...)"; -} -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const TargetTransferRate& target_rate) { - return os << "TargetTransferRate(...)"; -} -} // namespace webrtc diff --git a/modules/congestion_controller/network_control/test/network_ostream_operators.h b/modules/congestion_controller/network_control/test/network_ostream_operators.h deleted file mode 100644 index 2177aa9e4b..0000000000 --- a/modules/congestion_controller/network_control/test/network_ostream_operators.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -#ifndef MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_TEST_NETWORK_OSTREAM_OPERATORS_H_ -#define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_TEST_NETWORK_OSTREAM_OPERATORS_H_ -// Overloading ostream << operator is required for gtest printing. -#include // no-presubmit-check TODO(webrtc:8982) -#include "modules/congestion_controller/network_control/include/network_types.h" - -namespace webrtc { -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const DataRate& datarate); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const DataSize& datasize); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const Timestamp& timestamp); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const TimeDelta& delta); - -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const CongestionWindow& window); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const ProbeClusterConfig& config); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const PacerConfig& config); -::std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) - ::std::ostream& os, // no-presubmit-check TODO(webrtc:8982) - const TargetTransferRate& target_rate); -} // namespace webrtc -#endif // MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_TEST_NETWORK_OSTREAM_OPERATORS_H_