This CL removes all usages of our custom ostream << overloads.
This prepares us for removing them altogether.
Bug: webrtc:8982
Change-Id: I66002cc8d4bf0e07925766d568d2498422f0f38e
Reviewed-on: https://webrtc-review.googlesource.com/64142
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Henrik Grunell <henrikg@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22707}
diff --git a/api/candidate.cc b/api/candidate.cc
index 62cd1bd..d51fb84 100644
--- a/api/candidate.cc
+++ b/api/candidate.cc
@@ -73,8 +73,9 @@
sensitive ? address_.ToSensitiveString() : address_.ToString();
ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_
<< ":" << protocol_ << ":" << priority_ << ":" << address << ":" << type_
- << ":" << related_address_ << ":" << username_ << ":" << password_ << ":"
- << network_id_ << ":" << network_cost_ << ":" << generation_ << "]";
+ << ":" << related_address_.ToString() << ":" << username_ << ":"
+ << password_ << ":" << network_id_ << ":" << network_cost_ << ":"
+ << generation_ << "]";
return ost.str();
}
diff --git a/api/rtcerror.h b/api/rtcerror.h
index 760bad8..d7dec29 100644
--- a/api/rtcerror.h
+++ b/api/rtcerror.h
@@ -150,11 +150,11 @@
// Helper macro that can be used by implementations to create an error with a
// message and log it. |message| should be a string literal or movable
// std::string.
-#define LOG_AND_RETURN_ERROR_EX(type, message, severity) \
- { \
- RTC_DCHECK(type != RTCErrorType::NONE); \
- RTC_LOG(severity) << message << " (" << type << ")"; \
- return webrtc::RTCError(type, message); \
+#define LOG_AND_RETURN_ERROR_EX(type, message, severity) \
+ { \
+ RTC_DCHECK(type != RTCErrorType::NONE); \
+ RTC_LOG(severity) << message << " (" << ToString(type) << ")"; \
+ return webrtc::RTCError(type, message); \
}
#define LOG_AND_RETURN_ERROR(type, message) \
diff --git a/api/rtcerror_unittest.cc b/api/rtcerror_unittest.cc
index d8f7ca6..90593cf 100644
--- a/api/rtcerror_unittest.cc
+++ b/api/rtcerror_unittest.cc
@@ -58,15 +58,6 @@
namespace webrtc {
-// Simple test for ostream operator for RTCErrorType.
-TEST(RTCErrorTypeTest, OstreamOperator) {
- std::ostringstream oss;
- oss << webrtc::RTCErrorType::NONE << ' '
- << webrtc::RTCErrorType::INVALID_PARAMETER << ' '
- << webrtc::RTCErrorType::INTERNAL_ERROR;
- EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str());
-}
-
// Test that the default constructor creates a "no error" error.
TEST(RTCErrorTest, DefaultConstructor) {
RTCError e;
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 451708a..3880eab 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -75,6 +75,7 @@
"../modules/rtp_rtcp",
"../modules/rtp_rtcp:rtp_rtcp_format",
"../modules/utility",
+ "../rtc_base:audio_format_to_string",
"../rtc_base:checks",
"../rtc_base:rate_limiter",
"../rtc_base:rtc_base",
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index cf02388..b8c88e8 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -23,6 +23,7 @@
#include "rtc_base/event.h"
#include "rtc_base/function_view.h"
#include "rtc_base/logging.h"
+#include "rtc_base/strings/audio_format_to_string.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/timeutils.h"
#include "system_wrappers/include/field_trial.h"
@@ -509,7 +510,8 @@
spec.payload_type, spec.format, new_config.codec_pair_id);
if (!encoder) {
- RTC_DLOG(LS_ERROR) << "Unable to create encoder for " << spec.format;
+ RTC_DLOG(LS_ERROR) << "Unable to create encoder for "
+ << rtc::ToString(spec.format);
return false;
}
// If a bitrate has been specified for the codec, use it over the
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 2a0e38a..58238af 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,7 @@
"../api/audio:audio_mixer_api",
"../api/audio_codecs:audio_codecs_api",
"../modules/audio_processing:audio_processing_statistics",
+ "../rtc_base:audio_format_to_string",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
]
diff --git a/call/audio_send_stream.cc b/call/audio_send_stream.cc
index 3458e73..1c08c2e 100644
--- a/call/audio_send_stream.cc
+++ b/call/audio_send_stream.cc
@@ -10,6 +10,7 @@
#include "call/audio_send_stream.h"
#include "rtc_base/stringencode.h"
+#include "rtc_base/strings/audio_format_to_string.h"
namespace webrtc {
@@ -67,7 +68,7 @@
ss << ", cng_payload_type: "
<< (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
ss << ", payload_type: " << payload_type;
- ss << ", format: " << format;
+ ss << ", format: " << rtc::ToString(format);
ss << '}';
return ss.str();
}
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 69e47c1..ffc4883 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -258,6 +258,7 @@
"../modules/audio_processing/aec_dump:aec_dump",
"../modules/video_coding:video_codec_interface",
"../modules/video_coding:video_coding",
+ "../rtc_base:audio_format_to_string",
"../rtc_base:checks",
]
diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc
index d6ec44b..df50642 100644
--- a/media/engine/webrtcvoiceengine.cc
+++ b/media/engine/webrtcvoiceengine.cc
@@ -40,6 +40,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/stringencode.h"
+#include "rtc_base/strings/audio_format_to_string.h"
#include "rtc_base/stringutils.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h"
@@ -689,7 +690,7 @@
}
} else {
RTC_LOG(LS_ERROR) << "Unable to assign payload type to format: "
- << format;
+ << rtc::ToString(format);
}
return opt_codec;
@@ -1529,7 +1530,7 @@
auto format = AudioCodecToSdpAudioFormat(codec);
if (!IsCodec(codec, "cn") && !IsCodec(codec, "telephone-event") &&
!engine()->decoder_factory_->IsSupportedDecoder(format)) {
- RTC_LOG(LS_ERROR) << "Unsupported codec: " << format;
+ RTC_LOG(LS_ERROR) << "Unsupported codec: " << rtc::ToString(format);
return false;
}
// We allow adding new codecs but don't allow changing the payload type of
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index ea69666..1fb13e5 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -148,6 +148,7 @@
":audio_coding_module_typedefs",
":neteq",
":rent_a_codec",
+ "../../rtc_base:audio_format_to_string",
"../../rtc_base:rtc_base_approved",
"../../api:optional",
"../../logging:rtc_event_log_api",
@@ -1087,6 +1088,7 @@
"../../api/audio_codecs:audio_codecs_api",
"../../common_audio",
"../../common_audio:common_audio_c",
+ "../../rtc_base:audio_format_to_string",
"../../rtc_base:checks",
"../../rtc_base:gtest_prod",
"../../rtc_base:rtc_base_approved",
diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc
index 0d5dcae..4d0209b 100644
--- a/modules/audio_coding/acm2/acm_receiver.cc
+++ b/modules/audio_coding/acm2/acm_receiver.cc
@@ -26,6 +26,7 @@
#include "rtc_base/format_macros.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
+#include "rtc_base/strings/audio_format_to_string.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
@@ -260,7 +261,8 @@
neteq_->RegisterPayloadType(rtp_payload_type, audio_format);
if (!success) {
RTC_LOG(LERROR) << "AcmReceiver::AddCodec failed for payload type "
- << rtp_payload_type << ", decoder format " << audio_format;
+ << rtp_payload_type << ", decoder format "
+ << rtc::ToString(audio_format);
}
return success;
}
diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc
index 7244c8d..40b0dc7 100644
--- a/modules/audio_coding/neteq/decoder_database.cc
+++ b/modules/audio_coding/neteq/decoder_database.cc
@@ -15,6 +15,7 @@
#include "api/audio_codecs/audio_decoder.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
+#include "rtc_base/strings/audio_format_to_string.h"
namespace webrtc {
@@ -95,7 +96,7 @@
RTC_DCHECK(factory_);
decoder_ = factory_->MakeAudioDecoder(audio_format_, codec_pair_id_);
}
- RTC_DCHECK(decoder_) << "Failed to create: " << audio_format_;
+ RTC_DCHECK(decoder_) << "Failed to create: " << rtc::ToString(audio_format_);
return decoder_.get();
}
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 78015d9..4e780c3 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -46,6 +46,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/sanitizer.h"
+#include "rtc_base/strings/audio_format_to_string.h"
#include "rtc_base/system/fallthrough.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h"
@@ -262,7 +263,8 @@
bool NetEqImpl::RegisterPayloadType(int rtp_payload_type,
const SdpAudioFormat& audio_format) {
RTC_LOG(LS_VERBOSE) << "NetEqImpl::RegisterPayloadType: payload type "
- << rtp_payload_type << ", codec " << audio_format;
+ << rtp_payload_type << ", codec "
+ << rtc::ToString(audio_format);
rtc::CritScope lock(&crit_sect_);
return decoder_database_->RegisterPayload(rtp_payload_type, audio_format) ==
DecoderDatabase::kOK;
diff --git a/modules/rtp_rtcp/source/rtp_format_h264.cc b/modules/rtp_rtcp/source/rtp_format_h264.cc
index 46f726b..3eda5be 100644
--- a/modules/rtp_rtcp/source/rtp_format_h264.cc
+++ b/modules/rtp_rtcp/source/rtp_format_h264.cc
@@ -337,11 +337,11 @@
packets_.pop();
input_fragments_.pop_front();
} else if (packet.aggregated) {
- RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_);
+ RTC_CHECK(H264PacketizationMode::NonInterleaved == packetization_mode_);
bool is_last_packet = num_packets_left_ == 1;
NextAggregatePacket(rtp_packet, is_last_packet);
} else {
- RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_);
+ RTC_CHECK(H264PacketizationMode::NonInterleaved == packetization_mode_);
NextFragmentPacket(rtp_packet);
}
RTC_DCHECK_LE(rtp_packet->payload_size(), max_payload_len_);
diff --git a/p2p/base/relayport.cc b/p2p/base/relayport.cc
index 52416ca..d1c5ac6 100644
--- a/p2p/base/relayport.cc
+++ b/p2p/base/relayport.cc
@@ -443,7 +443,8 @@
rtc::PacketOptions options; // Default dscp set to NO_CHANGE.
int sent = socket_->SendTo(data, size, GetAddress(), options);
if (sent <= 0) {
- RTC_LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress()
+ RTC_LOG(LS_VERBOSE) << "OnSendPacket: failed sending to "
+ << GetAddress().ToString()
<< strerror(socket_->GetError());
RTC_DCHECK(sent < 0);
}
@@ -652,7 +653,7 @@
if (current_connection_) {
const ProtocolAddress* ra = current_connection_->protocol_address();
RTC_LOG(LS_WARNING) << "Relay " << ra->proto << " connection to "
- << ra->address << " timed out";
+ << ra->address.ToString() << " timed out";
// Currently we connect to each server address in sequence. If we
// have more addresses to try, treat this is an error and move on to
diff --git a/p2p/base/stunserver_unittest.cc b/p2p/base/stunserver_unittest.cc
index d1b65b2..6b44360 100644
--- a/p2p/base/stunserver_unittest.cc
+++ b/p2p/base/stunserver_unittest.cc
@@ -89,8 +89,9 @@
EXPECT_EQ(1, mapped_addr->family());
EXPECT_EQ(client_addr.port(), mapped_addr->port());
if (mapped_addr->ipaddr() != client_addr.ipaddr()) {
- RTC_LOG(LS_WARNING) << "Warning: mapped IP (" << mapped_addr->ipaddr()
- << ") != local IP (" << client_addr.ipaddr() << ")";
+ RTC_LOG(LS_WARNING) << "Warning: mapped IP ("
+ << mapped_addr->ipaddr().ToString() << ") != local IP ("
+ << client_addr.ipaddr().ToString() << ")";
}
delete msg;
diff --git a/p2p/base/turnport.cc b/p2p/base/turnport.cc
index fa3bc17..bf858be 100644
--- a/p2p/base/turnport.cc
+++ b/p2p/base/turnport.cc
@@ -467,8 +467,8 @@
server_address_.address = socket_->GetRemoteAddress();
}
- RTC_LOG(LS_INFO) << "TurnPort connected to " << socket->GetRemoteAddress()
- << " using tcp.";
+ RTC_LOG(LS_INFO) << "TurnPort connected to "
+ << socket->GetRemoteAddress().ToString() << " using tcp.";
SendRequest(new TurnAllocateRequest(this), 0);
}
@@ -584,7 +584,8 @@
// Try to find an entry for this specific address; we should have one.
TurnEntry* entry = FindEntry(addr);
if (!entry) {
- RTC_LOG(LS_ERROR) << "Did not find the TurnEntry for address: " << addr;
+ RTC_LOG(LS_ERROR) << "Did not find the TurnEntry for address "
+ << addr.ToString();
return 0;
}
diff --git a/p2p/base/turnserver.cc b/p2p/base/turnserver.cc
index aa5b5ed..2a154aa 100644
--- a/p2p/base/turnserver.cc
+++ b/p2p/base/turnserver.cc
@@ -715,7 +715,7 @@
RTC_LOG(LS_WARNING) << ToString()
<< ": Received send indication without permission"
" peer="
- << peer_attr->GetAddress();
+ << peer_attr->GetAddress().ToString();
}
}
@@ -739,7 +739,8 @@
AddPermission(peer_attr->GetAddress().ipaddr());
RTC_LOG(LS_INFO) << ToString()
- << ": Created permission, peer=" << peer_attr->GetAddress();
+ << ": Created permission, peer="
+ << peer_attr->GetAddress().ToString();
// Send a success response.
TurnMessage response;
@@ -789,7 +790,7 @@
RTC_LOG(LS_INFO) << ToString()
<< ": Bound channel, id=" << channel_id
- << ", peer=" << peer_attr->GetAddress();
+ << ", peer=" << peer_attr->GetAddress().ToString();
// Send a success response.
TurnMessage response;
@@ -841,7 +842,8 @@
} else {
RTC_LOG(LS_WARNING)
<< ToString()
- << ": Received external packet without permission, peer=" << addr;
+ << ": Received external packet without permission, peer="
+ << addr.ToString();
}
}
diff --git a/p2p/client/basicportallocator_unittest.cc b/p2p/client/basicportallocator_unittest.cc
index df6eb4c..f39e61e 100644
--- a/p2p/client/basicportallocator_unittest.cc
+++ b/p2p/client/basicportallocator_unittest.cc
@@ -540,8 +540,8 @@
uint32_t total_candidates = 0;
if (!host_candidate_addr.IsNil()) {
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp",
- rtc::SocketAddress(kPrivateAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp",
+ rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)));
++total_candidates;
}
if (!stun_candidate_addr.IsNil()) {
@@ -549,20 +549,23 @@
if (host_candidate_addr.IsNil()) {
related_address.SetIP(rtc::GetAnyIP(stun_candidate_addr.family()));
}
- EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "stun", "udp",
- rtc::SocketAddress(stun_candidate_addr, 0), related_address);
+ EXPECT_TRUE(HasCandidateWithRelatedAddr(
+ candidates_, "stun", "udp",
+ rtc::SocketAddress(stun_candidate_addr, 0), related_address));
++total_candidates;
}
if (!relay_candidate_udp_transport_addr.IsNil()) {
- EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
- rtc::SocketAddress(relay_candidate_udp_transport_addr, 0),
- rtc::SocketAddress(stun_candidate_addr, 0));
+ EXPECT_TRUE(HasCandidateWithRelatedAddr(
+ candidates_, "relay", "udp",
+ rtc::SocketAddress(relay_candidate_udp_transport_addr, 0),
+ rtc::SocketAddress(stun_candidate_addr, 0)));
++total_candidates;
}
if (!relay_candidate_tcp_transport_addr.IsNil()) {
- EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
- rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0),
- rtc::SocketAddress(stun_candidate_addr, 0));
+ EXPECT_TRUE(HasCandidateWithRelatedAddr(
+ candidates_, "relay", "udp",
+ rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0),
+ rtc::SocketAddress(stun_candidate_addr, 0)));
++total_candidates;
}
@@ -604,9 +607,9 @@
const std::vector<Candidate>& ready_candidates =
session_->ReadyCandidates();
EXPECT_EQ(3U, ready_candidates.size());
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
}
void TestUdpTurnPortPrunesTcpTurnPort() {
@@ -644,9 +647,9 @@
const std::vector<Candidate>& ready_candidates =
session_->ReadyCandidates();
EXPECT_EQ(2U, ready_candidates.size());
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
}
void TestEachInterfaceHasItsOwnTurnPorts() {
@@ -694,20 +697,20 @@
const std::vector<Candidate>& ready_candidates =
session_->ReadyCandidates();
EXPECT_EQ(10U, ready_candidates.size());
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr2);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp",
- kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp",
- kClientIPv6Addr2);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp",
- kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp",
- kClientIPv6Addr2);
- EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr2));
+ EXPECT_TRUE(
+ HasCandidate(ready_candidates, "local", "udp", kClientIPv6Addr));
+ EXPECT_TRUE(
+ HasCandidate(ready_candidates, "local", "udp", kClientIPv6Addr2));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "tcp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "local", "tcp", kClientAddr2));
+ EXPECT_TRUE(
+ HasCandidate(ready_candidates, "local", "tcp", kClientIPv6Addr));
+ EXPECT_TRUE(
+ HasCandidate(ready_candidates, "local", "tcp", kClientIPv6Addr2));
+ EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
}
};
@@ -791,7 +794,7 @@
kDefaultAllocationTimeout, fake_clock);
// Should only get one Wi-Fi candidate.
EXPECT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
}
// Test that when the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set and
@@ -817,8 +820,8 @@
kDefaultAllocationTimeout, fake_clock);
// Should only get two candidates, none of which is cell.
EXPECT_EQ(2U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", unknown1);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", unknown2);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", unknown1));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", unknown2));
}
// Test that when the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set and
@@ -845,7 +848,7 @@
kDefaultAllocationTimeout, fake_clock);
// Should only get one Wi-Fi candidate.
EXPECT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
}
// Test that if the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set, but the
@@ -866,7 +869,7 @@
kDefaultAllocationTimeout, fake_clock);
// Make sure we got the cell candidate.
EXPECT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", cellular);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", cellular));
}
// Test that if both PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set, and there is
@@ -889,8 +892,8 @@
kDefaultAllocationTimeout, fake_clock);
// Make sure we got both wifi and cell candidates.
EXPECT_EQ(2U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi_link_local);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", cellular);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi_link_local));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", cellular));
}
// Test that if both PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set, and there is
@@ -916,8 +919,8 @@
kDefaultAllocationTimeout, fake_clock);
// Make sure we got only wifi candidates.
EXPECT_EQ(2U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi_link_local);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi_link_local));
}
// Test that no more than allocator.max_ipv6_networks() IPv6 networks are used
@@ -940,8 +943,8 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(2U, candidates_.size());
// Ensure the expected two interfaces (eth0 and eth1) were used.
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr2);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr2));
}
// Ensure that allocator.max_ipv6_networks() doesn't prevent IPv4 networks from
@@ -966,9 +969,9 @@
EXPECT_EQ(3U, candidates_.size());
// Ensure that only one IPv6 interface was used, but both IPv4 interfaces
// were used.
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr2);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr2));
}
// Test that we could use loopback interface as host candidate.
@@ -993,14 +996,14 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(7U, candidates_.size());
EXPECT_EQ(4U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
- kRelaySslTcpIntAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
+ EXPECT_TRUE(
+ HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
}
// Test that when the same network interface is brought down and up, the
@@ -1092,7 +1095,7 @@
// a single TCP active candidate, since that doesn't require creating a
// socket).
ASSERT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
candidate_allocation_done_ = false;
// Now simulate the interface coming up, with the newfound ability to bind
@@ -1104,11 +1107,11 @@
kDefaultAllocationTimeout, fake_clock);
// Should get UDP and TCP candidate.
ASSERT_EQ(2U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
// TODO(deadbeef): This is actually the same active TCP candidate as before.
// We should extend this test to also verify that a server candidate is
// gathered.
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
}
// Verify candidates with default step delay of 1sec.
@@ -1121,13 +1124,13 @@
EXPECT_EQ(2U, ports_.size());
ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 2000, fake_clock);
EXPECT_EQ(3U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
- kRelaySslTcpIntAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
+ EXPECT_TRUE(
+ HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), 1500, fake_clock);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
EXPECT_EQ(4U, ports_.size());
EXPECT_TRUE(candidate_allocation_done_);
// If we Stop gathering now, we shouldn't get a second "done" callback.
@@ -1184,14 +1187,14 @@
for (const Candidate& candidate : candidates_) {
// Check the port number for the UDP/STUN/TCP port objects.
if (candidate.type() != RELAY_PORT_TYPE) {
- EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort);
+ EXPECT_TRUE(CheckPort(candidate.address(), kMinPort, kMaxPort));
++num_nonrelay_candidates;
}
}
EXPECT_EQ(3, num_nonrelay_candidates);
// Check the port number used to connect to the relay server.
- EXPECT_PRED3(CheckPort, relay_server_.GetConnection(0).source(), kMinPort,
- kMaxPort);
+ EXPECT_TRUE(
+ CheckPort(relay_server_.GetConnection(0).source(), kMinPort, kMaxPort));
}
// Test that if we have no network adapters, we bind to the ANY address and
@@ -1221,8 +1224,8 @@
// candidate for it is useless and shouldn't be signaled. So we only have
// STUN/TURN candidates.
EXPECT_EQ(3U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
// Again, two TURN candidates, using UDP/TCP for the first hop to the TURN
// server.
EXPECT_EQ(2,
@@ -1355,11 +1358,11 @@
EXPECT_EQ(2U, ports_.size());
EXPECT_EQ(2U, candidates_.size());
Candidate turn_candidate;
- EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", kTurnUdpExtAddr,
- &turn_candidate);
+ EXPECT_TRUE(FindCandidate(candidates_, "relay", "udp", kTurnUdpExtAddr,
+ &turn_candidate));
// The TURN candidate should use TCP to contact the TURN server.
EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
}
// Disable for asan, see
@@ -1388,12 +1391,12 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(5U, candidates_.size());
EXPECT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
- kRelaySslTcpIntAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
+ EXPECT_TRUE(
+ HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
}
#endif // if !defined(ADDRESS_SANITIZER)
@@ -1411,12 +1414,12 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(5U, candidates_.size());
EXPECT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
- kRelaySslTcpIntAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
+ EXPECT_TRUE(
+ HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
}
// Test that we don't crash or malfunction if we can't create any sockets.
@@ -1442,17 +1445,17 @@
EXPECT_EQ_SIMULATED_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout,
fake_clock);
EXPECT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
// RelayPort connection timeout is 3sec. TCP connection with RelayServer
// will be tried after about 3 seconds.
EXPECT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 3500, fake_clock);
EXPECT_EQ(3U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
- kRelaySslTcpIntAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
+ EXPECT_TRUE(
+ HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
// We wait at least for a full STUN timeout, which
// cricket::STUN_TOTAL_TIMEOUT seconds. But since 3-3.5 seconds
// already passed (see above), we wait 3 seconds less than that.
@@ -1521,8 +1524,8 @@
session_->StartGettingPorts();
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
EXPECT_EQ(1U, candidates_.size());
EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state.
@@ -1593,9 +1596,9 @@
ASSERT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(7U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
EXPECT_EQ(4U, ports_.size());
for (const Candidate& candidate : candidates_) {
EXPECT_EQ(kIceUfrag0, candidate.username());
@@ -1616,7 +1619,7 @@
ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout,
fake_clock);
EXPECT_EQ(3U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
}
@@ -1635,9 +1638,9 @@
ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout,
fake_clock);
ASSERT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(3U, candidates_.size());
@@ -1663,11 +1666,11 @@
kDefaultAllocationTimeout, fake_clock);
ASSERT_EQ(3U, candidates_.size());
ASSERT_EQ(3U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
}
// Test that if prune_turn_ports is set, TCP TURN port will not be used
@@ -1790,11 +1793,11 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(3U, candidates_.size());
ASSERT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
// Local port will be created first and then TURN port.
@@ -1828,13 +1831,15 @@
ASSERT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(3U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
Candidate stun_candidate;
- EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
- EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
- stun_candidate.address());
+ EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
+ &stun_candidate));
+ EXPECT_TRUE(HasCandidateWithRelatedAddr(
+ candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
+ stun_candidate.address()));
// Local port will be created first and then TURN port.
// TODO(deadbeef): This isn't something the BasicPortAllocator API contract
@@ -1863,9 +1868,9 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(2U, candidates_.size());
ASSERT_EQ(2U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
EXPECT_EQ(1U, ports_[0]->Candidates().size());
EXPECT_EQ(1U, ports_[1]->Candidates().size());
}
@@ -1890,14 +1895,15 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(3U, candidates_.size());
ASSERT_EQ(3U, ports_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
Candidate stun_candidate;
- EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
+ EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
+ &stun_candidate));
Candidate turn_candidate;
- EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
- &turn_candidate);
+ EXPECT_TRUE(FindCandidate(candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
+ &turn_candidate));
// Not using shared socket, so the STUN request's server reflexive address
// should be different than the TURN request's server reflexive address.
EXPECT_NE(turn_candidate.related_address(), stun_candidate.address());
@@ -1926,13 +1932,15 @@
ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout,
fake_clock);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
Candidate stun_candidate;
- EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
- EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
- stun_candidate.address());
+ EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
+ rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
+ &stun_candidate));
+ EXPECT_TRUE(HasCandidateWithRelatedAddr(
+ candidates_, "relay", "udp",
+ rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
+ stun_candidate.address()));
// Don't bother waiting for STUN timeout, since we already verified
// that we got a STUN candidate from the TURN server.
@@ -1952,7 +1960,7 @@
ASSERT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout,
fake_clock);
EXPECT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
// STUN timeout is 9.5sec. We need to wait to get candidate done signal.
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, kStunTimeoutMs,
fake_clock);
@@ -1978,7 +1986,7 @@
EXPECT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout,
fake_clock);
EXPECT_EQ(1U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kPrivateAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kPrivateAddr));
EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
}
@@ -1996,10 +2004,10 @@
kDefaultAllocationTimeout, fake_clock);
EXPECT_EQ(4U, ports_.size());
EXPECT_EQ(4U, candidates_.size());
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientIPv6Addr);
- EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientIPv6Addr));
+ EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
}
TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) {
diff --git a/pc/peerconnection_ice_unittest.cc b/pc/peerconnection_ice_unittest.cc
index edf2bf8..e8f450f 100644
--- a/pc/peerconnection_ice_unittest.cc
+++ b/pc/peerconnection_ice_unittest.cc
@@ -527,7 +527,7 @@
if (candidate_ip == address.ipaddr()) {
return ::testing::AssertionSuccess();
}
- candidate_hosts << "\n" << candidate_ip;
+ candidate_hosts << "\n" << candidate_ip.ToString();
}
return ::testing::AssertionFailure()
<< address_expr << " (host " << address.HostAsURIString()
diff --git a/rtc_base/ipaddress_unittest.cc b/rtc_base/ipaddress_unittest.cc
index 90c9559..3698d3f 100644
--- a/rtc_base/ipaddress_unittest.cc
+++ b/rtc_base/ipaddress_unittest.cc
@@ -288,39 +288,39 @@
IPAddress addr(v4addr);
IPAddress addr2(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(INADDR_ANY);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(INADDR_LOOPBACK);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(kIPv4PublicAddr);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(kIPv4RFC1918Addr);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(in6addr_any);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(in6addr_loopback);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(kIPv6LinkLocalAddr);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr = IPAddress(kIPv6PublicAddr);
addr2 = IPAddress(addr);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
}
TEST(IPAddressTest, TestEquality) {
@@ -446,46 +446,46 @@
EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv4AnyAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(INADDR_LOOPBACK);
EXPECT_TRUE(IPFromString(kIPv4LoopbackAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv4LoopbackAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(kIPv4RFC1918Addr);
EXPECT_TRUE(IPFromString(kIPv4RFC1918AddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv4RFC1918AddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(kIPv4PublicAddr);
EXPECT_TRUE(IPFromString(kIPv4PublicAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv4PublicAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(in6addr_any);
EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv6AnyAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(in6addr_loopback);
EXPECT_TRUE(IPFromString(kIPv6LoopbackAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv6LoopbackAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(kIPv6LinkLocalAddr);
EXPECT_TRUE(IPFromString(kIPv6LinkLocalAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv6LinkLocalAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(kIPv6PublicAddr);
EXPECT_TRUE(IPFromString(kIPv6PublicAddrString, &addr));
EXPECT_EQ(addr.ToString(), kIPv6PublicAddrString);
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
addr2 = IPAddress(kIPv4MappedRFC1918Addr);
EXPECT_TRUE(IPFromString(kIPv4MappedV4StyleAddrString, &addr));
- EXPECT_PRED2(AreEqual, addr, addr2);
+ EXPECT_TRUE(AreEqual(addr, addr2));
// Broken cases, should set addr to AF_UNSPEC.
EXPECT_PRED1(BrokenIPStringFails, kIPv4BrokenString1);
diff --git a/rtc_base/nat_unittest.cc b/rtc_base/nat_unittest.cc
index d68df1d..68f0f1c 100644
--- a/rtc_base/nat_unittest.cc
+++ b/rtc_base/nat_unittest.cc
@@ -232,11 +232,12 @@
}
}
if (ext_addr2.IsNil()) {
- RTC_LOG(LS_WARNING) << "No available IP of same family as " << int_addr;
+ RTC_LOG(LS_WARNING) << "No available IP of same family as "
+ << int_addr.ToString();
return;
}
- RTC_LOG(LS_INFO) << "selected ip " << ext_addr2.ipaddr();
+ RTC_LOG(LS_INFO) << "selected ip " << ext_addr2.ipaddr().ToString();
SocketAddress ext_addrs[4] = {
SocketAddress(ext_addr1),
diff --git a/rtc_base/physicalsocketserver_unittest.cc b/rtc_base/physicalsocketserver_unittest.cc
index d09385bb..81f1c9d 100644
--- a/rtc_base/physicalsocketserver_unittest.cc
+++ b/rtc_base/physicalsocketserver_unittest.cc
@@ -201,13 +201,13 @@
server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
sink.Monitor(client1.get());
EXPECT_EQ(AsyncSocket::CS_CLOSED, client1->GetState());
- EXPECT_PRED1(IsUnspecOrEmptyIP, client1->GetLocalAddress().ipaddr());
+ EXPECT_TRUE(IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr()));
std::unique_ptr<AsyncSocket> client2(
server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
sink.Monitor(client2.get());
EXPECT_EQ(AsyncSocket::CS_CLOSED, client2->GetState());
- EXPECT_PRED1(IsUnspecOrEmptyIP, client2->GetLocalAddress().ipaddr());
+ EXPECT_TRUE(IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr()));
// Create server and listen.
std::unique_ptr<AsyncSocket> server(
diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc
index a31cc02..be958d3 100644
--- a/rtc_base/socket_unittest.cc
+++ b/rtc_base/socket_unittest.cc
@@ -224,7 +224,7 @@
ss_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
sink.Monitor(client.get());
EXPECT_EQ(AsyncSocket::CS_CLOSED, client->GetState());
- EXPECT_PRED1(IsUnspecOrEmptyIP, client->GetLocalAddress().ipaddr());
+ EXPECT_TRUE(IsUnspecOrEmptyIP(client->GetLocalAddress().ipaddr()));
// Create server and listen.
std::unique_ptr<AsyncSocket> server(
diff --git a/rtc_base/socketaddress.cc b/rtc_base/socketaddress.cc
index 54a41d4..bddb7bc 100644
--- a/rtc_base/socketaddress.cc
+++ b/rtc_base/socketaddress.cc
@@ -26,12 +26,11 @@
#include <unistd.h>
#endif
-#include <sstream>
-
#include "rtc_base/byteorder.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/nethelpers.h"
+#include "rtc_base/strings/string_builder.h"
#if defined(WEBRTC_WIN)
#include "rtc_base/win32.h"
@@ -161,21 +160,21 @@
}
std::string SocketAddress::PortAsString() const {
- std::ostringstream ost;
- ost << port_;
- return ost.str();
+ return std::to_string(port_);
}
std::string SocketAddress::ToString() const {
- std::ostringstream ost;
- ost << *this;
- return ost.str();
+ char buf[1024];
+ rtc::SimpleStringBuilder sb(buf);
+ sb << HostAsURIString() << ":" << port();
+ return sb.str();
}
std::string SocketAddress::ToSensitiveString() const {
- std::ostringstream ost;
- ost << HostAsSensitiveURIString() << ":" << port();
- return ost.str();
+ char buf[1024];
+ rtc::SimpleStringBuilder sb(buf);
+ sb << HostAsSensitiveURIString() << ":" << port();
+ return sb.str();
}
bool SocketAddress::FromString(const std::string& str) {
diff --git a/rtc_base/socketaddress_unittest.cc b/rtc_base/socketaddress_unittest.cc
index 0d168df..fb195b6 100644
--- a/rtc_base/socketaddress_unittest.cc
+++ b/rtc_base/socketaddress_unittest.cc
@@ -255,34 +255,34 @@
TEST(SocketAddressTest, TestEqualityOperators) {
SocketAddress addr1("1.2.3.4", 5678);
SocketAddress addr2("1.2.3.4", 5678);
- EXPECT_PRED2(AreEqual, addr1, addr2);
+ EXPECT_TRUE(AreEqual(addr1, addr2));
addr2 = SocketAddress("0.0.0.1", 5678);
- EXPECT_PRED2(AreUnequal, addr1, addr2);
+ EXPECT_TRUE(AreUnequal(addr1, addr2));
addr2 = SocketAddress("1.2.3.4", 1234);
- EXPECT_PRED2(AreUnequal, addr1, addr2);
+ EXPECT_TRUE(AreUnequal(addr1, addr2));
addr2 = SocketAddress(kTestV6AddrString, 5678);
- EXPECT_PRED2(AreUnequal, addr1, addr2);
+ EXPECT_TRUE(AreUnequal(addr1, addr2));
addr1 = SocketAddress(kTestV6AddrString, 5678);
- EXPECT_PRED2(AreEqual, addr1, addr2);
+ EXPECT_TRUE(AreEqual(addr1, addr2));
addr2 = SocketAddress(kTestV6AddrString, 1234);
- EXPECT_PRED2(AreUnequal, addr1, addr2);
+ EXPECT_TRUE(AreUnequal(addr1, addr2));
addr2 = SocketAddress("fe80::1", 5678);
- EXPECT_PRED2(AreUnequal, addr1, addr2);
+ EXPECT_TRUE(AreUnequal(addr1, addr2));
SocketAddress addr3("a.b.c.d", 1);
SocketAddress addr4("b.b.c.d", 1);
- EXPECT_PRED2(AreUnequal, addr3, addr4);
- EXPECT_PRED2(AreEqual, addr3, addr3);
+ EXPECT_TRUE(AreUnequal(addr3, addr4));
+ EXPECT_TRUE(AreEqual(addr3, addr3));
addr3.SetIP(addr1.ip());
addr4.SetIP(addr1.ip());
- EXPECT_PRED2(AreEqual,addr3, addr4);
+ EXPECT_TRUE(AreEqual(addr3, addr4));
}
bool IsLessThan(const SocketAddress& addr1, const SocketAddress& addr2) {
@@ -299,19 +299,19 @@
EXPECT_FALSE(addr2 < addr1);
addr2 = SocketAddress("1.2.3.4", 5679);
- EXPECT_PRED2(IsLessThan, addr1, addr2);
+ EXPECT_TRUE(IsLessThan(addr1, addr2));
addr2 = SocketAddress("2.2.3.4", 49152);
- EXPECT_PRED2(IsLessThan, addr1, addr2);
+ EXPECT_TRUE(IsLessThan(addr1, addr2));
addr2 = SocketAddress(kTestV6AddrString, 5678);
- EXPECT_PRED2(IsLessThan, addr1, addr2);
+ EXPECT_TRUE(IsLessThan(addr1, addr2));
addr1 = SocketAddress("fe80::1", 5678);
- EXPECT_PRED2(IsLessThan, addr2, addr1);
+ EXPECT_TRUE(IsLessThan(addr2, addr1));
addr2 = SocketAddress("fe80::1", 5679);
- EXPECT_PRED2(IsLessThan, addr1, addr2);
+ EXPECT_TRUE(IsLessThan(addr1, addr2));
addr2 = SocketAddress("fe80::1", 5678);
EXPECT_FALSE(addr1 < addr2);
@@ -319,7 +319,7 @@
SocketAddress addr3("a.b.c.d", 1);
SocketAddress addr4("b.b.c.d", 1);
- EXPECT_PRED2(IsLessThan, addr3, addr4);
+ EXPECT_TRUE(IsLessThan(addr3, addr4));
}
TEST(SocketAddressTest, TestToSensitiveString) {
diff --git a/rtc_base/ssladapter_unittest.cc b/rtc_base/ssladapter_unittest.cc
index 0996b01..c15ecfe 100644
--- a/rtc_base/ssladapter_unittest.cc
+++ b/rtc_base/ssladapter_unittest.cc
@@ -81,7 +81,7 @@
}
int Connect(const std::string& hostname, const rtc::SocketAddress& address) {
- RTC_LOG(LS_INFO) << "Initiating connection with " << address;
+ RTC_LOG(LS_INFO) << "Initiating connection with " << address.ToString();
int rv = ssl_adapter_->Connect(address);
@@ -157,7 +157,7 @@
RTC_LOG(LS_INFO) << ((ssl_mode_ == rtc::SSL_MODE_DTLS) ? "UDP" : "TCP")
<< " server listening on "
- << server_socket_->GetLocalAddress();
+ << server_socket_->GetLocalAddress().ToString();
}
rtc::SocketAddress GetAddress() const {
diff --git a/rtc_base/stringutils.h b/rtc_base/stringutils.h
index 386ca9e..b42cfa5 100644
--- a/rtc_base/stringutils.h
+++ b/rtc_base/stringutils.h
@@ -312,6 +312,7 @@
// Remove leading and trailing whitespaces.
std::string string_trim(const std::string& s);
+// TODO(jonasolsson): replace with absl::Hex when that becomes available.
std::string ToHex(const int i);
} // namespace rtc
diff --git a/rtc_base/virtualsocketserver.cc b/rtc_base/virtualsocketserver.cc
index d8771e7..fab5900 100644
--- a/rtc_base/virtualsocketserver.cc
+++ b/rtc_base/virtualsocketserver.cc
@@ -409,7 +409,8 @@
} else if ((SOCK_STREAM == type_) && (CS_CONNECTING == state_)) {
CompleteConnect(data->addr, true);
} else {
- RTC_LOG(LS_VERBOSE) << "Socket at " << local_addr_ << " is not listening";
+ RTC_LOG(LS_VERBOSE) << "Socket at " << local_addr_.ToString()
+ << " is not listening";
server_->Disconnect(server_->LookupBinding(data->addr));
}
delete data;
@@ -805,7 +806,8 @@
VirtualSocket* remote = LookupBinding(remote_addr);
if (!CanInteractWith(socket, remote)) {
RTC_LOG(LS_INFO) << "Address family mismatch between "
- << socket->GetLocalAddress() << " and " << remote_addr;
+ << socket->GetLocalAddress().ToString() << " and "
+ << remote_addr.ToString();
return -1;
}
if (remote != nullptr) {
@@ -813,7 +815,7 @@
msg_queue_->PostDelayed(RTC_FROM_HERE, delay, remote, MSG_ID_CONNECT,
new MessageAddress(addr));
} else {
- RTC_LOG(LS_INFO) << "No one listening at " << remote_addr;
+ RTC_LOG(LS_INFO) << "No one listening at " << remote_addr.ToString();
msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT);
}
return 0;
@@ -856,17 +858,18 @@
dummy_socket->SetLocalAddress(remote_addr);
if (!CanInteractWith(socket, dummy_socket.get())) {
RTC_LOG(LS_VERBOSE) << "Incompatible address families: "
- << socket->GetLocalAddress() << " and "
- << remote_addr;
+ << socket->GetLocalAddress().ToString() << " and "
+ << remote_addr.ToString();
return -1;
}
- RTC_LOG(LS_VERBOSE) << "No one listening at " << remote_addr;
+ RTC_LOG(LS_VERBOSE) << "No one listening at " << remote_addr.ToString();
return static_cast<int>(data_size);
}
if (!CanInteractWith(socket, recipient)) {
RTC_LOG(LS_VERBOSE) << "Incompatible address families: "
- << socket->GetLocalAddress() << " and " << remote_addr;
+ << socket->GetLocalAddress().ToString() << " and "
+ << remote_addr.ToString();
return -1;
}