Index: webrtc/api/statscollector_unittest.cc |
diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/api/statscollector_unittest.cc |
index baa35d36595d12b61f7fea0d62ed128eb44fc025..d027769018f35547c79486a7c8be55f1f90d08e9 100644 |
--- a/webrtc/api/statscollector_unittest.cc |
+++ b/webrtc/api/statscollector_unittest.cc |
@@ -41,6 +41,7 @@ |
using testing::_; |
using testing::DoAll; |
using testing::Field; |
+using testing::Invoke; |
using testing::Return; |
using testing::ReturnNull; |
using testing::ReturnRef; |
@@ -504,7 +505,7 @@ class StatsCollectorTest : public testing::Test { |
&event_log_)), |
session_(media_controller_.get()) { |
// By default, we ignore session GetStats calls. |
- EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(ReturnNull()); |
// Add default returns for mock classes. |
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
@@ -607,9 +608,11 @@ class StatsCollectorTest : public testing::Test { |
// Instruct the session to return stats containing the transport channel. |
InitSessionStats(vc_name); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
// Constructs an ssrc stats update. |
if (voice_sender_info) |
@@ -707,9 +710,11 @@ class StatsCollectorTest : public testing::Test { |
EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer( |
transport_stats.transport_name)) |
.WillOnce(Return(remote_cert.release())); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillOnce(Invoke( |
+ [&session_stats](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats)); |
+ })); |
stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
@@ -848,9 +853,11 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
@@ -895,9 +902,11 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
@@ -1007,9 +1016,11 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
@@ -1103,9 +1114,11 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { |
Return(true))); |
InitSessionStats(kVcName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
StatsReports reports; |
@@ -1172,9 +1185,11 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) { |
// Instruct the session to return stats containing the transport channel. |
InitSessionStats(kVcName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
// Constructs an ssrc stats update. |
cricket::VideoMediaInfo stats_read; |
@@ -1215,9 +1230,11 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
@@ -1421,9 +1438,11 @@ TEST_F(StatsCollectorTest, NoTransport) { |
transport_stats; |
// Configure MockWebRtcSession |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [&session_stats](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats)); |
+ })); |
stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
stats.GetStats(NULL, &reports); |
@@ -1478,9 +1497,11 @@ TEST_F(StatsCollectorTest, NoCertificates) { |
transport_stats; |
// Configure MockWebRtcSession |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillOnce(DoAll(SetArgPointee<0>(session_stats), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [&session_stats](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats)); |
+ })); |
stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); |
stats.GetStats(NULL, &reports); |
@@ -1557,8 +1578,11 @@ TEST_F(StatsCollectorTest, FilterOutNegativeInitialValues) { |
// Instruct the session to return stats containing the transport channel. |
InitSessionStats(kVcName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
cricket::VoiceSenderInfo voice_sender_info; |
voice_sender_info.add_ssrc(kSsrcOfTrack); |
@@ -1711,9 +1735,11 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { |
// Instruct the session to return stats containing the transport channel. |
InitSessionStats(kVcName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
stats.RemoveLocalAudioTrack(audio_track_.get(), kSsrcOfTrack); |
cricket::VoiceSenderInfo voice_sender_info; |
@@ -1785,9 +1811,11 @@ TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) { |
// Instruct the session to return stats containing the transport channel. |
InitSessionStats(kVcName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), |
- Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
cricket::VoiceSenderInfo voice_sender_info; |
InitVoiceSenderInfo(&voice_sender_info); |
@@ -1905,8 +1933,11 @@ TEST_F(StatsCollectorTest, VerifyVideoSendSsrcStats) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |
@@ -1950,8 +1981,11 @@ TEST_F(StatsCollectorTest, VerifyVideoReceiveSsrcStats) { |
const char kVideoChannelName[] = "video"; |
InitSessionStats(kVideoChannelName); |
- EXPECT_CALL(session_, GetTransportStats(_)) |
- .WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_), Return(true))); |
+ EXPECT_CALL(session_, GetSessionStats(_)).WillRepeatedly(Invoke( |
+ [this](const ChannelNamePairs&) { |
+ return std::unique_ptr<SessionStats>( |
+ new SessionStats(session_stats_)); |
+ })); |
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel(); |
cricket::VideoChannel video_channel(worker_thread_, network_thread_, |