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

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: Set media engine on voice channel 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 ab9181f4875d78a5904e94201e32e1915fe1dcdd..bd058d85f6fd09284e5446a1194590c1899be089 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(GetIdentity,
+ bool(const std::string& content_name,
+ rtc::SSLIdentity** identity));
+ MOCK_METHOD2(GetRemoteCertificate,
+ bool(const std::string& content_name,
+ rtc::SSLCertificate** cert));
};
class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel {
@@ -655,27 +662,16 @@ class StatsCollectorTest : public testing::Test {
session_stats.transport_stats[transport_stats.content_name] =
transport_stats;
- // Fake certificates to report.
+ // Fake identity to report
rtc::FakeSSLIdentity local_identity(local_cert);
- 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->SetIdentity(&local_identity);
- cricket::FakeTransportChannel* channel =
- static_cast<cricket::FakeTransportChannel*>(
- transport->CreateChannel(channel_stats.component));
- EXPECT_FALSE(channel == NULL);
- channel->SetRemoteCertificate(remote_cert_copy.get());
// Configure MockWebRtcSession
- EXPECT_CALL(session_, GetTransport(transport_stats.content_name))
- .WillRepeatedly(Return(transport.get()));
+ EXPECT_CALL(session_, GetIdentity(transport_stats.content_name, _))
+ .WillOnce(DoAll(SetArgPointee<1>(local_identity.GetReference()),
+ Return(true)));
+ EXPECT_CALL(session_, GetRemoteCertificate(transport_stats.content_name, _))
+ .WillOnce(
+ DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true)));
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -789,14 +785,16 @@ TEST_F(StatsCollectorTest, ExtractDataInfo) {
TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).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(),
@@ -832,14 +830,16 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).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(),
@@ -945,13 +945,15 @@ TEST_F(StatsCollectorTest, TrackObjectExistsWithoutUpdateStats) {
TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).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(),
@@ -1010,9 +1012,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The content_name known by the video channel.
const std::string kVcName("vcname");
@@ -1095,9 +1098,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The content_name known by the video channel.
const std::string kVcName("vcname");
@@ -1144,13 +1148,15 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).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(),
@@ -1329,6 +1335,10 @@ TEST_F(StatsCollectorTest, ChainlessCertificateReportsCreated) {
TEST_F(StatsCollectorTest, NoTransport) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1344,8 +1354,6 @@ TEST_F(StatsCollectorTest, NoTransport) {
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)));
@@ -1388,6 +1396,10 @@ TEST_F(StatsCollectorTest, NoTransport) {
TEST_F(StatsCollectorTest, NoCertificates) {
StatsCollectorForTest stats(&session_);
+ EXPECT_CALL(session_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1405,13 +1417,9 @@ TEST_F(StatsCollectorTest, NoCertificates) {
// Fake transport object.
rtc::scoped_ptr<cricket::FakeTransport> transport(
new cricket::FakeTransport(
- session_.signaling_thread(),
- session_.worker_thread(),
transport_stats.content_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)));
@@ -1457,9 +1465,9 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The content_name known by the voice channel.
@@ -1491,9 +1499,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The content_name known by the voice channel.
const std::string kVcName("vcname");
@@ -1518,9 +1527,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The content_name known by the voice channel.
const std::string kVcName("vcname");
@@ -1577,9 +1587,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The content_name known by the voice channel.
const std::string kVcName("vcname");
@@ -1662,9 +1673,10 @@ 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_, GetIdentity(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteCertificate(_, _))
+ .WillRepeatedly(Return(false));
+
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The content_name known by the voice channel.
const std::string kVcName("vcname");

Powered by Google App Engine
This is Rietveld 408576698