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

Unified Diff: webrtc/base/testclient_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/base/testclient_unittest.cc
diff --git a/webrtc/base/testclient_unittest.cc b/webrtc/base/testclient_unittest.cc
index 55078134c3a2b4ad7bc1fb5b873029ae97586b95..edebd5c95e0c3e82d8711b35c09b531898610aec 100644
--- a/webrtc/base/testclient_unittest.cc
+++ b/webrtc/base/testclient_unittest.cc
@@ -8,10 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/testclient.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/nethelpers.h"
#include "webrtc/base/physicalsocketserver.h"
-#include "webrtc/base/testclient.h"
+#include "webrtc/base/ptr_util.h"
#include "webrtc/base/testechoserver.h"
#include "webrtc/base/thread.h"
@@ -23,7 +24,7 @@ void TestUdpInternal(const SocketAddress& loopback) {
->CreateAsyncSocket(loopback.family(), SOCK_DGRAM);
socket->Bind(loopback);
- TestClient client(new AsyncUDPSocket(socket));
+ TestClient client(MakeUnique<AsyncUDPSocket>(socket));
SocketAddress addr = client.address(), from;
EXPECT_EQ(3, client.SendTo("foo", 3, addr));
EXPECT_TRUE(client.CheckNextPacket("foo", 3, &from));
@@ -37,11 +38,11 @@ void TestTcpInternal(const SocketAddress& loopback) {
AsyncSocket* socket = main->socketserver()
->CreateAsyncSocket(loopback.family(), SOCK_STREAM);
- AsyncTCPSocket* tcp_socket = AsyncTCPSocket::Create(
- socket, loopback, server.address());
+ std::unique_ptr<AsyncTCPSocket> tcp_socket(
+ AsyncTCPSocket::Create(socket, loopback, server.address()));
kwiberg-webrtc 2017/05/05 11:04:42 Hmm. Maybe auto tcp_socket = WrapUnique(
nisse-webrtc 2017/05/05 12:12:56 Not mentioning the type is a mixed blessing, thoug
kwiberg-webrtc 2017/05/05 12:40:31 Yes. I'd say it's a justifiable leap of faith to a
ASSERT_TRUE(tcp_socket != nullptr);
- TestClient client(tcp_socket);
+ TestClient client(std::move(tcp_socket));
SocketAddress addr = client.address(), from;
EXPECT_TRUE(client.CheckConnected());
EXPECT_EQ(3, client.Send("foo", 3));

Powered by Google App Engine
This is Rietveld 408576698