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

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: 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
Index: webrtc/api/statscollector_unittest.cc
diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/api/statscollector_unittest.cc
index d4a59a1a6d5f360f32dc0a4606477dc8d4a2ce92..b86e3b5a06ede5a7bbd92fe12d1c6debeab384b0 100644
--- a/webrtc/api/statscollector_unittest.cc
+++ b/webrtc/api/statscollector_unittest.cc
@@ -81,9 +81,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.
@@ -659,10 +665,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.
@@ -690,10 +697,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)));
@@ -803,8 +809,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";
@@ -849,8 +855,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";
@@ -961,8 +967,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);
@@ -1033,8 +1039,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.
@@ -1117,8 +1123,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.
@@ -1168,8 +1174,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);
@@ -1329,9 +1335,11 @@ TEST_F(StatsCollectorTest, ChainedCertificateReportsCreated) {
remote_ders[1] = "non-";
remote_ders[2] = "intersecting";
remote_ders[3] = "set";
- rtc::FakeSSLCertificate remote_cert(DersToPems(remote_ders));
+ auto remote_cert = rtc::scoped_ptr<rtc::FakeSSLCertificate>(
+ 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
@@ -1343,10 +1351,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));
+ auto remote_cert = rtc::scoped_ptr<rtc::FakeSSLCertificate>(
+ 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
@@ -1356,8 +1366,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.
@@ -1413,8 +1423,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.
@@ -1465,11 +1475,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");
+ auto remote_cert = rtc::scoped_ptr<rtc::FakeSSLCertificate>(
+ 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
@@ -1479,8 +1490,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.
@@ -1514,8 +1525,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.
@@ -1543,8 +1554,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.
@@ -1604,8 +1615,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.
@@ -1691,8 +1702,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.

Powered by Google App Engine
This is Rietveld 408576698