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

Unified Diff: webrtc/api/statscollector_unittest.cc

Issue 1802013002: A bunch of interfaces: Return scoped_ptr<SSLCertificate> (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: less auto Created 4 years, 9 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 | « webrtc/api/statscollector.cc ('k') | webrtc/api/webrtcsession.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/statscollector_unittest.cc
diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/api/statscollector_unittest.cc
index a1cd1e820fe7f02c911bcafc917a33612cf57630..b8cdafc86ad12e734a564d9e03bbc9c949ccb821 100644
--- a/webrtc/api/statscollector_unittest.cc
+++ b/webrtc/api/statscollector_unittest.cc
@@ -82,9 +82,15 @@ class MockWebRtcSession : public webrtc::WebRtcSession {
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));
+
+ // Workaround for gmock's inability to cope with move-only return values.
+ rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
+ const std::string& transport_name) override {
+ return rtc::scoped_ptr<rtc::SSLCertificate>(
+ GetRemoteSSLCertificate_ReturnsRawPointer(transport_name));
+ }
+ MOCK_METHOD1(GetRemoteSSLCertificate_ReturnsRawPointer,
+ rtc::SSLCertificate*(const std::string& transport_name));
};
// The factory isn't really used; it just satisfies the base PeerConnection.
@@ -662,10 +668,11 @@ class StatsCollectorTest : public testing::Test {
VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info);
}
- void TestCertificateReports(const rtc::FakeSSLCertificate& local_cert,
- const std::vector<std::string>& local_ders,
- const rtc::FakeSSLCertificate& remote_cert,
- const std::vector<std::string>& remote_ders) {
+ void TestCertificateReports(
+ const rtc::FakeSSLCertificate& local_cert,
+ const std::vector<std::string>& local_ders,
+ rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert,
+ const std::vector<std::string>& remote_ders) {
StatsCollectorForTest stats(&pc_);
StatsReports reports; // returned values.
@@ -693,10 +700,9 @@ class StatsCollectorTest : public testing::Test {
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_, GetRemoteSSLCertificate_ReturnsRawPointer(
+ transport_stats.transport_name))
+ .WillOnce(Return(remote_cert.release()));
EXPECT_CALL(session_, GetTransportStats(_))
.WillOnce(DoAll(SetArgPointee<0>(session_stats),
Return(true)));
@@ -806,8 +812,8 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
const char kVideoChannelName[] = "video";
@@ -852,8 +858,8 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
const char kVideoChannelName[] = "video";
@@ -964,8 +970,8 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
@@ -1036,8 +1042,8 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The transport_name known by the video channel.
@@ -1120,8 +1126,8 @@ TEST_F(StatsCollectorTest, RemoteSsrcInfoIsPresent) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVideoMediaChannel* media_channel = new MockVideoMediaChannel();
// The transport_name known by the video channel.
@@ -1171,8 +1177,8 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
const char kVideoChannelName[] = "video";
InitSessionStats(kVideoChannelName);
@@ -1332,9 +1338,11 @@ TEST_F(StatsCollectorTest, ChainedCertificateReportsCreated) {
remote_ders[1] = "non-";
remote_ders[2] = "intersecting";
remote_ders[3] = "set";
- rtc::FakeSSLCertificate remote_cert(DersToPems(remote_ders));
+ rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert(
+ new rtc::FakeSSLCertificate(DersToPems(remote_ders)));
- TestCertificateReports(local_cert, local_ders, remote_cert, remote_ders);
+ TestCertificateReports(local_cert, local_ders, std::move(remote_cert),
+ remote_ders);
}
// This test verifies that all certificates without chains are correctly
@@ -1346,10 +1354,12 @@ TEST_F(StatsCollectorTest, ChainlessCertificateReportsCreated) {
// Build remote certificate.
std::string remote_der = "This is somebody else's der.";
- rtc::FakeSSLCertificate remote_cert(DerToPem(remote_der));
+ rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert(
+ new rtc::FakeSSLCertificate(DerToPem(remote_der)));
TestCertificateReports(local_cert, std::vector<std::string>(1, local_der),
- remote_cert, std::vector<std::string>(1, remote_der));
+ std::move(remote_cert),
+ std::vector<std::string>(1, remote_der));
}
// This test verifies that the stats are generated correctly when no
@@ -1359,8 +1369,8 @@ TEST_F(StatsCollectorTest, NoTransport) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
StatsReports reports; // returned values.
@@ -1416,8 +1426,8 @@ TEST_F(StatsCollectorTest, NoCertificates) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
StatsReports reports; // returned values.
@@ -1468,11 +1478,12 @@ TEST_F(StatsCollectorTest, UnsupportedDigestIgnored) {
// Build a remote certificate with an unsupported digest algorithm.
std::string remote_der = "This is somebody else's der.";
- rtc::FakeSSLCertificate remote_cert(DerToPem(remote_der));
- remote_cert.set_digest_algorithm("foobar");
+ rtc::scoped_ptr<rtc::FakeSSLCertificate> remote_cert(
+ new rtc::FakeSSLCertificate(DerToPem(remote_der)));
+ remote_cert->set_digest_algorithm("foobar");
TestCertificateReports(local_cert, std::vector<std::string>(1, local_der),
- remote_cert, std::vector<std::string>());
+ std::move(remote_cert), std::vector<std::string>());
}
// This test verifies that a local stats object can get statistics via
@@ -1482,8 +1493,8 @@ TEST_F(StatsCollectorTest, GetStatsFromLocalAudioTrack) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel.
@@ -1517,8 +1528,8 @@ TEST_F(StatsCollectorTest, GetStatsFromRemoteStream) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel.
@@ -1546,8 +1557,8 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel.
@@ -1607,8 +1618,8 @@ TEST_F(StatsCollectorTest, LocalAndRemoteTracksWithSameSsrc) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel.
@@ -1694,8 +1705,8 @@ TEST_F(StatsCollectorTest, TwoLocalTracksWithSameSsrc) {
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
- EXPECT_CALL(session_, GetRemoteSSLCertificate(_, _))
- .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
// The transport_name known by the voice channel.
« no previous file with comments | « webrtc/api/statscollector.cc ('k') | webrtc/api/webrtcsession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698