Helpers in peer connection unit tests: Use scoped_ptr instead of raw pointers
A handful of helpers were using SessionDescriptionInterface** output
arguments to return ownership. Chenge them to either use a
rtc::scoped_ptr<SessionDescriptionInterface>* output parameter, or to
simply return a rtc::scoped_ptr<SessionDescriptionInterface>. Not
using raw pointers for things you own is good in general; it will also
be very convenient when scoped_ptr is gone, since unique_ptr doesn't
have .accept() or .use() methods.
BUG=webrtc:5520
Review URL: https://codereview.webrtc.org/1798173002
Cr-Commit-Position: refs/heads/master@{#12021}
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
index 533b9db..6400655 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/api/peerconnection_unittest.cc
@@ -196,7 +196,7 @@
void Negotiate(bool audio, bool video) {
rtc::scoped_ptr<SessionDescriptionInterface> offer;
- ASSERT_TRUE(DoCreateOffer(offer.use()));
+ ASSERT_TRUE(DoCreateOffer(&offer));
if (offer->description()->GetContentByName("audio")) {
offer->description()->GetContentByName("audio")->rejected = !audio;
@@ -831,7 +831,7 @@
webrtc::CreateSessionDescription("offer", msg, nullptr));
EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
rtc::scoped_ptr<SessionDescriptionInterface> answer;
- EXPECT_TRUE(DoCreateAnswer(answer.use()));
+ EXPECT_TRUE(DoCreateAnswer(&answer));
std::string sdp;
EXPECT_TRUE(answer->ToString(&sdp));
EXPECT_TRUE(DoSetLocalDescription(answer.release()));
@@ -848,7 +848,7 @@
EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
}
- bool DoCreateOfferAnswer(SessionDescriptionInterface** desc,
+ bool DoCreateOfferAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc,
bool offer) {
rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
observer(new rtc::RefCountedObject<
@@ -867,18 +867,18 @@
}
}
EXPECT_EQ_WAIT(true, observer->called(), kMaxWaitMs);
- *desc = observer->release_desc();
+ desc->reset(observer->release_desc());
if (observer->result() && ExpectIceRestart()) {
EXPECT_EQ(0u, (*desc)->candidates(0)->count());
}
return observer->result();
}
- bool DoCreateOffer(SessionDescriptionInterface** desc) {
+ bool DoCreateOffer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) {
return DoCreateOfferAnswer(desc, true);
}
- bool DoCreateAnswer(SessionDescriptionInterface** desc) {
+ bool DoCreateAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) {
return DoCreateOfferAnswer(desc, false);
}