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

Unified Diff: talk/app/webrtc/statscollector_unittest.cc

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More renaming, formatting and other polish Created 5 years, 4 months 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: talk/app/webrtc/statscollector_unittest.cc
diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc
index fd1ad617af4e49b2756c530e0be91746873b9246..ea016201e7201ddb678036ad152ec558fdbd236c 100644
--- a/talk/app/webrtc/statscollector_unittest.cc
+++ b/talk/app/webrtc/statscollector_unittest.cc
@@ -27,6 +27,8 @@
#include <stdio.h>
+#include <algorithm>
+
#include "talk/app/webrtc/statscollector.h"
#include "talk/app/webrtc/mediastream.h"
@@ -45,7 +47,7 @@
#include "webrtc/base/fakesslidentity.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/network.h"
-#include "webrtc/p2p/base/fakesession.h"
+#include "webrtc/p2p/base/faketransportcontroller.h"
using rtc::scoped_ptr;
using testing::_;
@@ -89,7 +91,12 @@ class MockWebRtcSession : public webrtc::WebRtcSession {
MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*));
MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*));
MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*));
- MOCK_METHOD1(GetTransport, cricket::Transport*(const std::string&));
+ MOCK_METHOD2(GetLocalCertificate,
+ bool(const std::string& transport_name,
+ rtc::scoped_refptr<rtc::RTCCertificate>* certificate));
+ MOCK_METHOD2(GetRemoteCertificate,
+ bool(const std::string& transport_name,
+ rtc::SSLCertificate** cert));
};
class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel {
@@ -501,7 +508,7 @@ class StatsCollectorTest : public testing::Test {
cricket::TransportStats transport_stats;
cricket::TransportChannelStats channel_stats;
channel_stats.component = 1;
- transport_stats.content_name = kTransportName;
+ transport_stats.transport_name = kTransportName;
transport_stats.channel_stats.push_back(channel_stats);
session_stats_.transport_stats[kTransportName] = transport_stats;
@@ -648,36 +655,27 @@ class StatsCollectorTest : public testing::Test {
channel_stats.ssl_cipher = "the-ssl-cipher";
cricket::TransportStats transport_stats;
- transport_stats.content_name = "audio";
+ transport_stats.transport_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.content_name] =
+ session_stats.transport_stats[transport_stats.transport_name] =
transport_stats;
- // Fake certificates to report.
+ // Fake certificate to report
rtc::scoped_refptr<rtc::RTCCertificate> local_certificate(
- rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::FakeSSLIdentity>(
- new rtc::FakeSSLIdentity(local_cert)).Pass()));
- rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert_copy(
- remote_cert.GetReference());
-
- // Fake transport object.
- rtc::scoped_ptr<cricket::FakeTransport> transport(
- new cricket::FakeTransport(
- session_.signaling_thread(),
- session_.worker_thread(),
- transport_stats.content_name));
- transport->SetCertificate(local_certificate);
- cricket::FakeTransportChannel* channel =
- static_cast<cricket::FakeTransportChannel*>(
- transport->CreateChannel(channel_stats.component));
- EXPECT_FALSE(channel == NULL);
- channel->SetRemoteCertificate(remote_cert_copy.get());
+ rtc::RTCCertificate::Create(
+ rtc::scoped_ptr<rtc::FakeSSLIdentity>(
+ new rtc::FakeSSLIdentity(local_cert)).Pass()));
// Configure MockWebRtcSession
- EXPECT_CALL(session_, GetTransport(transport_stats.content_name))
- .WillRepeatedly(Return(transport.get()));
+ EXPECT_CALL(session_,
+ GetLocalCertificate(transport_stats.transport_name, _))
+ .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true)));
+ EXPECT_CALL(session_,
+ GetRemoteCertificate(transport_stats.transport_name, _))
+ .WillOnce(
+ DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true)));
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -791,14 +789,17 @@ TEST_F(StatsCollectorTest, ExtractDataInfo) {
TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
EXPECT_CALL(session_, GetTransportStats(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
Return(true)));
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(),
@@ -834,14 +835,17 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
EXPECT_CALL(session_, GetTransportStats(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
Return(true)));
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(),
@@ -947,13 +951,16 @@ TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) {
TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
EXPECT_CALL(session_, GetTransportStats(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
Return(true)));
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(),
@@ -1012,11 +1019,13 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The content_name known by the video channel.
+ // The transport_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1074,7 +1083,7 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) {
StatsCollectorForTest stats(&session_);
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The content_name known by the video channel.
+ // The transport_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1097,11 +1106,13 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsAbsent) {
TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The content_name known by the video channel.
+ // The transport_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1146,13 +1157,16 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
EXPECT_CALL(session_, GetTransportStats(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(session_stats_),
Return(true)));
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
cricket::VideoChannel video_channel(rtc::Thread::Current(),
@@ -1331,6 +1345,11 @@ TEST_F(StatsCollectorTest, ChainlessCertificateReportsCreated) {
TEST_F(StatsCollectorTest, NoTransport) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1338,16 +1357,14 @@ TEST_F(StatsCollectorTest, NoTransport) {
channel_stats.component = 1;
cricket::TransportStats transport_stats;
- transport_stats.content_name = "audio";
+ transport_stats.transport_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.content_name] =
+ session_stats.transport_stats[transport_stats.transport_name] =
transport_stats;
// Configure MockWebRtcSession
- EXPECT_CALL(session_, GetTransport(transport_stats.content_name))
- .WillRepeatedly(ReturnNull());
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -1390,6 +1407,11 @@ TEST_F(StatsCollectorTest, NoTransport) {
TEST_F(StatsCollectorTest, NoCertificates) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1397,23 +1419,18 @@ TEST_F(StatsCollectorTest, NoCertificates) {
channel_stats.component = 1;
cricket::TransportStats transport_stats;
- transport_stats.content_name = "audio";
+ transport_stats.transport_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.content_name] =
+ session_stats.transport_stats[transport_stats.transport_name] =
transport_stats;
// Fake transport object.
rtc::scoped_ptr<cricket::FakeTransport> transport(
- new cricket::FakeTransport(
- session_.signaling_thread(),
- session_.worker_thread(),
- transport_stats.content_name));
+ new cricket::FakeTransport(transport_stats.transport_name));
// Configure MockWebRtcSession
- EXPECT_CALL(session_, GetTransport(transport_stats.content_name))
- .WillRepeatedly(Return(transport.get()));
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -1459,12 +1476,13 @@ TEST_F(StatsCollectorTest, UnsupportedDigestIgnored) {
TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The content_name known by the voice channel.
+ // The transport_name known by the voice channel.
const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(),
media_engine_, media_channel, NULL, kVcName, false);
@@ -1493,11 +1511,13 @@ TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) {
TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The content_name known by the voice channel.
+ // The transport_name known by the voice channel.
const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(),
media_engine_, media_channel, NULL, kVcName, false);
@@ -1520,11 +1540,13 @@ TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) {
TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The content_name known by the voice channel.
+ // The transport_name known by the voice channel.
const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(),
media_engine_, media_channel, NULL, kVcName, false);
@@ -1579,11 +1601,13 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The content_name known by the voice channel.
+ // The transport_name known by the voice channel.
const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(),
media_engine_, media_channel, NULL, kVcName, false);
@@ -1664,11 +1688,13 @@ TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) {
StatsCollectorForTest stats(&session_);
- // Ignore unused callback (logspam).
- EXPECT_CALL(session_, GetTransport(_))
- .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The content_name known by the voice channel.
+ // The transport_name known by the voice channel.
const std::string kVcName("vcname");
cricket::VoiceChannel voice_channel(rtc::Thread::Current(),
media_engine_, media_channel, NULL, kVcName, false);

Powered by Google App Engine
This is Rietveld 408576698