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

Unified Diff: webrtc/p2p/base/relayserver_unittest.cc

Issue 2859373003: Refactor TestClient to use std::unique_ptr, and fix VirtualSocketServerTest leaks. (Closed)
Patch Set: Created 3 years, 7 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/p2p/base/relayserver_unittest.cc
diff --git a/webrtc/p2p/base/relayserver_unittest.cc b/webrtc/p2p/base/relayserver_unittest.cc
index 0c98286af9507d6d097a824691becf38f9d9407a..a53a66668a5b932f77b06df0ef5c528c44106e91 100644
--- a/webrtc/p2p/base/relayserver_unittest.cc
+++ b/webrtc/p2p/base/relayserver_unittest.cc
@@ -11,16 +11,17 @@
#include <memory>
#include <string>
-#include "webrtc/p2p/base/relayserver.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/physicalsocketserver.h"
+#include "webrtc/base/ptr_util.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/testclient.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/virtualsocketserver.h"
+#include "webrtc/p2p/base/relayserver.h"
using rtc::SocketAddress;
using namespace cricket;
@@ -55,9 +56,9 @@ class RelayServerTest : public testing::Test {
rtc::AsyncUDPSocket::Create(ss_.get(), server_ext_addr));
client1_.reset(new rtc::TestClient(
- rtc::AsyncUDPSocket::Create(ss_.get(), client1_addr)));
+ WrapUnique(rtc::AsyncUDPSocket::Create(ss_.get(), client1_addr))));
client2_.reset(new rtc::TestClient(
- rtc::AsyncUDPSocket::Create(ss_.get(), client2_addr)));
+ WrapUnique(rtc::AsyncUDPSocket::Create(ss_.get(), client2_addr))));
}
void Allocate() {
@@ -116,24 +117,22 @@ class RelayServerTest : public testing::Test {
}
StunMessage* Receive(rtc::TestClient* client) {
StunMessage* msg = NULL;
- rtc::TestClient::Packet* packet =
+ std::unique_ptr<rtc::TestClient::Packet> packet =
client->NextPacket(rtc::TestClient::kTimeoutMs);
if (packet) {
rtc::ByteBufferWriter buf(packet->buf, packet->size);
rtc::ByteBufferReader read_buf(buf);
msg = new RelayMessage();
msg->Read(&read_buf);
- delete packet;
}
return msg;
}
std::string ReceiveRaw(rtc::TestClient* client) {
std::string raw;
- rtc::TestClient::Packet* packet =
+ std::unique_ptr<rtc::TestClient::Packet> packet =
client->NextPacket(rtc::TestClient::kTimeoutMs);
if (packet) {
raw = std::string(packet->buf, packet->size);
- delete packet;
}
return raw;
}

Powered by Google App Engine
This is Rietveld 408576698