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

Unified Diff: webrtc/api/rtcstatscollector_unittest.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Addressed comments 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..6966d599831fdd6a7ed3a49603ed82b2bb2cabdc 100644
--- a/webrtc/api/rtcstatscollector_unittest.cc
+++ b/webrtc/api/rtcstatscollector_unittest.cc
@@ -311,7 +311,7 @@ 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_, GetSessionStats(_)).WillRepeatedly(ReturnNull());
EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly(
Return(false));
EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
@@ -626,10 +626,11 @@ 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(_)).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(
Invoke([this, &local_certinfo](const std::string& transport_name,
@@ -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(_)).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,11 +791,12 @@ 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(_)).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(
Invoke([this, &audio_local_certinfo, &video_local_certinfo](
@@ -847,10 +851,11 @@ 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(_)).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(
Invoke([this, &local_certinfo](const std::string& transport_name,
@@ -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(_)).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(_)).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(_)).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(_)).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(_)).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(_)).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(_)).WillRepeatedly(Invoke(
+ [&session_stats](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats));
}));
// Get stats without RTCP, an active connection or certificates.

Powered by Google App Engine
This is Rietveld 408576698