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

Side by Side Diff: chrome/browser/extensions/api/socket/combined_socket_unittest.cc

Issue 2257113002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/extensions/api/socket/mock_tcp_client_socket.h" 8 #include "chrome/browser/extensions/api/socket/mock_tcp_client_socket.h"
9 #include "extensions/browser/api/socket/socket.h" 9 #include "extensions/browser/api/socket/socket.h"
10 #include "extensions/browser/api/socket/tcp_socket.h" 10 #include "extensions/browser/api/socket/tcp_socket.h"
11 #include "extensions/browser/api/socket/tls_socket.h" 11 #include "extensions/browser/api/socket/tls_socket.h"
12 #include "net/socket/stream_socket.h" 12 #include "net/socket/stream_socket.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace extensions { 16 namespace extensions {
17 17
18 const int kBufferLength = 10; 18 const int kBufferLength = 10;
19 19
20 template <typename T> 20 template <typename T>
21 std::unique_ptr<T> CreateTestSocket( 21 std::unique_ptr<T> CreateTestSocket(
22 std::unique_ptr<MockTCPClientSocket> stream); 22 std::unique_ptr<MockTCPClientSocket> stream);
23 23
24 template <> 24 template <>
25 std::unique_ptr<TCPSocket> CreateTestSocket( 25 std::unique_ptr<TCPSocket> CreateTestSocket(
26 std::unique_ptr<MockTCPClientSocket> stream) { 26 std::unique_ptr<MockTCPClientSocket> stream) {
27 return base::WrapUnique( 27 return base::MakeUnique<TCPSocket>(std::move(stream), "fake id",
28 new TCPSocket(std::move(stream), "fake id", true /* is_connected */)); 28 true /* is_connected */);
29 } 29 }
30 30
31 template <> 31 template <>
32 std::unique_ptr<TLSSocket> CreateTestSocket( 32 std::unique_ptr<TLSSocket> CreateTestSocket(
33 std::unique_ptr<MockTCPClientSocket> stream) { 33 std::unique_ptr<MockTCPClientSocket> stream) {
34 return base::WrapUnique(new TLSSocket(std::move(stream), "fake id")); 34 return base::MakeUnique<TLSSocket>(std::move(stream), "fake id");
35 } 35 }
36 36
37 class CombinedSocketTest : public testing::Test { 37 class CombinedSocketTest : public testing::Test {
38 public: 38 public:
39 CombinedSocketTest() : count_(0), io_buffer_(nullptr) {} 39 CombinedSocketTest() : count_(0), io_buffer_(nullptr) {}
40 40
41 // Strict test for synchronous (immediate) read behavior 41 // Strict test for synchronous (immediate) read behavior
42 template <typename T> 42 template <typename T>
43 void TestRead() { 43 void TestRead() {
44 net::IOBuffer* buffer = nullptr; 44 net::IOBuffer* buffer = nullptr;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 TEST_F(CombinedSocketTest, TlsReadAfterDisconnect) { 136 TEST_F(CombinedSocketTest, TlsReadAfterDisconnect) {
137 TestReadAfterDisconnect<TLSSocket>(); 137 TestReadAfterDisconnect<TLSSocket>();
138 } 138 }
139 139
140 TEST_F(CombinedSocketTest, TcpReadAfterDisconnect) { 140 TEST_F(CombinedSocketTest, TcpReadAfterDisconnect) {
141 TestReadAfterDisconnect<TCPSocket>(); 141 TestReadAfterDisconnect<TCPSocket>();
142 } 142 }
143 143
144 } // namespace extensions 144 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698