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

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

Issue 1358413003: Revert of TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/webrtcsession.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/statscollector_unittest.cc
diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc
index 0a9d947841a6dd685723969ee0307c5fa19fdba9..9b037c414987cb3ce8937d79b17b70c9fc1ef6d8 100644
--- a/talk/app/webrtc/statscollector_unittest.cc
+++ b/talk/app/webrtc/statscollector_unittest.cc
@@ -27,8 +27,6 @@
#include <stdio.h>
-#include <algorithm>
-
#include "talk/app/webrtc/statscollector.h"
#include "talk/app/webrtc/mediastream.h"
@@ -47,7 +45,7 @@
#include "webrtc/base/fakesslidentity.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/network.h"
-#include "webrtc/p2p/base/faketransportcontroller.h"
+#include "webrtc/p2p/base/fakesession.h"
using rtc::scoped_ptr;
using testing::_;
@@ -91,12 +89,7 @@
MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*));
MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*));
MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*));
- MOCK_METHOD2(GetLocalCertificate,
- bool(const std::string& transport_name,
- rtc::scoped_refptr<rtc::RTCCertificate>* certificate));
- MOCK_METHOD2(GetRemoteSSLCertificate,
- bool(const std::string& transport_name,
- rtc::SSLCertificate** cert));
+ MOCK_METHOD1(GetTransport, cricket::Transport*(const std::string&));
};
class MockVideoMediaChannel : public cricket::FakeVideoMediaChannel {
@@ -507,7 +500,7 @@
cricket::TransportStats transport_stats;
cricket::TransportChannelStats channel_stats;
channel_stats.component = 1;
- transport_stats.transport_name = kTransportName;
+ transport_stats.content_name = kTransportName;
transport_stats.channel_stats.push_back(channel_stats);
session_stats_.transport_stats[kTransportName] = transport_stats;
@@ -654,27 +647,36 @@
channel_stats.ssl_cipher = "the-ssl-cipher";
cricket::TransportStats transport_stats;
- transport_stats.transport_name = "audio";
+ transport_stats.content_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.transport_name] =
+ session_stats.transport_stats[transport_stats.content_name] =
transport_stats;
- // Fake certificate to report
+ // Fake certificates to report.
rtc::scoped_refptr<rtc::RTCCertificate> local_certificate(
rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::FakeSSLIdentity>(
- new rtc::FakeSSLIdentity(local_cert))
- .Pass()));
+ 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->SetRemoteSSLCertificate(remote_cert_copy.get());
// Configure MockWebRtcSession
- EXPECT_CALL(session_,
- GetLocalCertificate(transport_stats.transport_name, _))
- .WillOnce(DoAll(SetArgPointee<1>(local_certificate), Return(true)));
- EXPECT_CALL(session_,
- GetRemoteSSLCertificate(transport_stats.transport_name, _))
- .WillOnce(
- DoAll(SetArgPointee<1>(remote_cert.GetReference()), Return(true)));
+ EXPECT_CALL(session_, GetTransport(transport_stats.content_name))
+ .WillRepeatedly(Return(transport.get()));
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -788,17 +790,14 @@
TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .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,17 +833,14 @@
TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .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(),
@@ -950,16 +946,13 @@
TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .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(),
@@ -1018,13 +1011,11 @@
TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The transport_name known by the video channel.
+ // The content_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1082,7 +1073,7 @@
StatsCollectorForTest stats(&session_);
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The transport_name known by the video channel.
+ // The content_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1105,13 +1096,11 @@
TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
- // The transport_name known by the video channel.
+ // The content_name known by the video channel.
const std::string kVcName("vcname");
cricket::VideoChannel video_channel(rtc::Thread::Current(),
media_channel, NULL, kVcName, false);
@@ -1156,16 +1145,13 @@
TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .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(),
@@ -1344,11 +1330,6 @@
TEST_F(StatsCollectorTest, NoTransport) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1356,14 +1337,16 @@
channel_stats.component = 1;
cricket::TransportStats transport_stats;
- transport_stats.transport_name = "audio";
+ transport_stats.content_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.transport_name] =
+ session_stats.transport_stats[transport_stats.content_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)));
@@ -1406,11 +1389,6 @@
TEST_F(StatsCollectorTest, NoCertificates) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
StatsReports reports; // returned values.
// Fake stats to process.
@@ -1418,18 +1396,23 @@
channel_stats.component = 1;
cricket::TransportStats transport_stats;
- transport_stats.transport_name = "audio";
+ transport_stats.content_name = "audio";
transport_stats.channel_stats.push_back(channel_stats);
cricket::SessionStats session_stats;
- session_stats.transport_stats[transport_stats.transport_name] =
+ session_stats.transport_stats[transport_stats.content_name] =
transport_stats;
// Fake transport object.
rtc::scoped_ptr<cricket::FakeTransport> transport(
- new cricket::FakeTransport(transport_stats.transport_name));
+ 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)));
@@ -1475,13 +1458,12 @@
TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The transport_name known by the voice channel.
+ // The content_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);
@@ -1510,13 +1492,11 @@
TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The transport_name known by the voice channel.
+ // The content_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);
@@ -1539,13 +1519,11 @@
TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The transport_name known by the voice channel.
+ // The content_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);
@@ -1600,13 +1578,11 @@
TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The transport_name known by the voice channel.
+ // The content_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);
@@ -1687,13 +1663,11 @@
TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) {
StatsCollectorForTest stats(&session_);
- EXPECT_CALL(session_, GetLocalCertificate(_, _))
- .WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
-
+ // Ignore unused callback (logspam).
+ EXPECT_CALL(session_, GetTransport(_))
+ .WillRepeatedly(Return(static_cast<cricket::Transport*>(NULL)));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
- // The transport_name known by the voice channel.
+ // The content_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);
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/webrtcsession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698