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

Unified Diff: webrtc/api/rtcstatscollector_unittest.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Created 4 years 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/api/rtcstatscollector_unittest.cc
diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc
index b973044c94751582d187dbc112f02703b1ff06c8..2681a6995929c31463b6cac6f0dd6d071833448c 100644
--- a/webrtc/api/rtcstatscollector_unittest.cc
+++ b/webrtc/api/rtcstatscollector_unittest.cc
@@ -311,10 +311,10 @@ class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver {
ReturnRef(data_channels_));
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
- EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly(
+ EXPECT_CALL(session_, GetSessionStats_n(_)).WillRepeatedly(ReturnNull());
+ EXPECT_CALL(session_, GetLocalCertificate_n(_, _)).WillRepeatedly(
Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_n_ReturnsRawPointer(_))
.WillRepeatedly(Return(nullptr));
}
@@ -626,12 +626,13 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
std::vector<std::string>({ "(remote) single certificate" }));
// Mock the session to return the local and remote certificates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this](SessionStats* stats) {
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [this](const ChannelNamePairs&) {
+ std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["transport"].transport_name = "transport";
- return true;
+ return stats;
}));
- EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
+ EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
@@ -641,7 +642,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
return false;
}));
EXPECT_CALL(test_->session(),
- GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
+ GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();
@@ -710,8 +711,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) {
session_stats.transport_stats["TransportName"].transport_name =
"TransportName";
- EXPECT_CALL(test_->session(), GetTransportStats(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
EXPECT_CALL(test_->session(), voice_channel())
.WillRepeatedly(Return(&voice_channel));
EXPECT_CALL(test_->session(), video_channel())
@@ -788,13 +791,14 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) {
video_remote_certinfo->ders);
// Mock the session to return the local and remote certificates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this](SessionStats* stats) {
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [this](const ChannelNamePairs&) {
+ std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["audio"].transport_name = "audio";
stats->transport_stats["video"].transport_name = "video";
- return true;
+ return stats;
}));
- EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
+ EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
Invoke([this, &audio_local_certinfo, &video_local_certinfo](
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
@@ -809,7 +813,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsMultiple) {
return false;
}));
EXPECT_CALL(test_->session(),
- GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
+ GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &audio_remote_certinfo, &video_remote_certinfo](
const std::string& transport_name) {
if (transport_name == "audio") {
@@ -847,12 +851,13 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) {
CreateFakeCertificateAndInfoFromDers(remote_ders);
// Mock the session to return the local and remote certificates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this](SessionStats* stats) {
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [this](const ChannelNamePairs&) {
+ std::unique_ptr<SessionStats> stats(new SessionStats());
stats->transport_stats["transport"].transport_name = "transport";
- return true;
+ return stats;
}));
- EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
+ EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
@@ -862,7 +867,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) {
return false;
}));
EXPECT_CALL(test_->session(),
- GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
+ GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();
@@ -975,10 +980,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
b_transport_channel_stats);
// Mock the session to return the desired candidates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this, &session_stats](SessionStats* stats) {
- *stats = session_stats;
- return true;
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
}));
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
@@ -1019,10 +1023,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
transport_channel_stats);
// Mock the session to return the desired candidates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this, &session_stats](SessionStats* stats) {
- *stats = session_stats;
- return true;
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
}));
rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
@@ -1343,8 +1346,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) {
session_stats.transport_stats["TransportName"].channel_stats.push_back(
channel_stats);
- EXPECT_CALL(test_->session(), GetTransportStats(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
EXPECT_CALL(test_->session(), voice_channel())
.WillRepeatedly(Return(&voice_channel));
@@ -1415,8 +1420,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) {
session_stats.transport_stats["TransportName"].channel_stats.push_back(
channel_stats);
- EXPECT_CALL(test_->session(), GetTransportStats(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
EXPECT_CALL(test_->session(), video_channel())
.WillRepeatedly(Return(&video_channel));
@@ -1484,8 +1491,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) {
session_stats.transport_stats["TransportName"].channel_stats.push_back(
channel_stats);
- EXPECT_CALL(test_->session(), GetTransportStats(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
EXPECT_CALL(test_->session(), voice_channel())
.WillRepeatedly(Return(&voice_channel));
@@ -1552,8 +1561,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) {
session_stats.transport_stats["TransportName"].channel_stats.push_back(
channel_stats);
- EXPECT_CALL(test_->session(), GetTransportStats(_))
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats), Return(true)));
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
+ }));
EXPECT_CALL(test_->session(), video_channel())
.WillRepeatedly(Return(&video_channel));
@@ -1613,10 +1624,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
// Mock the session to return the desired candidates.
- EXPECT_CALL(test_->session(), GetTransportStats(_)).WillRepeatedly(Invoke(
- [this, &session_stats](SessionStats* stats) {
- *stats = session_stats;
- return true;
+ EXPECT_CALL(test_->session(), GetSessionStats_n(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
}));
// Get stats without RTCP, an active connection or certificates.
@@ -1701,7 +1711,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
std::unique_ptr<CertificateInfo> remote_certinfo =
CreateFakeCertificateAndInfoFromDers(
std::vector<std::string>({ "(remote) local", "(remote) chain" }));
- EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
+ EXPECT_CALL(test_->session(), GetLocalCertificate_n(_, _)).WillRepeatedly(
Invoke([this, &local_certinfo](const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
if (transport_name == "transport") {
@@ -1711,7 +1721,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) {
return false;
}));
EXPECT_CALL(test_->session(),
- GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
+ GetRemoteSSLCertificate_n_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
[this, &remote_certinfo](const std::string& transport_name) {
if (transport_name == "transport")
return remote_certinfo->certificate->ssl_certificate().GetReference();

Powered by Google App Engine
This is Rietveld 408576698