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

Side by Side Diff: extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <utility> 5 #include <utility>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "extensions/browser/api/dns/host_resolver_wrapper.h" 9 #include "extensions/browser/api/dns/host_resolver_wrapper.h"
10 #include "extensions/browser/api/dns/mock_host_resolver_creator.h" 10 #include "extensions/browser/api/dns/mock_host_resolver_creator.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 }; 53 };
54 54
55 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) { 55 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) {
56 scoped_refptr<api::SocketsTcpCreateFunction> socket_create_function( 56 scoped_refptr<api::SocketsTcpCreateFunction> socket_create_function(
57 new api::SocketsTcpCreateFunction()); 57 new api::SocketsTcpCreateFunction());
58 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension(); 58 scoped_refptr<Extension> empty_extension = test_util::CreateEmptyExtension();
59 59
60 socket_create_function->set_extension(empty_extension.get()); 60 socket_create_function->set_extension(empty_extension.get());
61 socket_create_function->set_has_callback(true); 61 socket_create_function->set_has_callback(true);
62 62
63 scoped_ptr<base::Value> result( 63 std::unique_ptr<base::Value> result(
64 api_test_utils::RunFunctionAndReturnSingleResult( 64 api_test_utils::RunFunctionAndReturnSingleResult(
65 socket_create_function.get(), "[]", browser_context())); 65 socket_create_function.get(), "[]", browser_context()));
66 66
67 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 67 ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
68 scoped_ptr<base::DictionaryValue> value = 68 std::unique_ptr<base::DictionaryValue> value =
69 base::DictionaryValue::From(std::move(result)); 69 base::DictionaryValue::From(std::move(result));
70 int socketId = -1; 70 int socketId = -1;
71 EXPECT_TRUE(value->GetInteger("socketId", &socketId)); 71 EXPECT_TRUE(value->GetInteger("socketId", &socketId));
72 ASSERT_TRUE(socketId > 0); 72 ASSERT_TRUE(socketId > 0);
73 } 73 }
74 74
75 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) { 75 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) {
76 scoped_ptr<net::SpawnedTestServer> test_server(new net::SpawnedTestServer( 76 std::unique_ptr<net::SpawnedTestServer> test_server(
77 net::SpawnedTestServer::TYPE_TCP_ECHO, net::SpawnedTestServer::kLocalhost, 77 new net::SpawnedTestServer(
78 base::FilePath(FILE_PATH_LITERAL("net/data")))); 78 net::SpawnedTestServer::TYPE_TCP_ECHO,
79 net::SpawnedTestServer::kLocalhost,
80 base::FilePath(FILE_PATH_LITERAL("net/data"))));
79 EXPECT_TRUE(test_server->Start()); 81 EXPECT_TRUE(test_server->Start());
80 82
81 net::HostPortPair host_port_pair = test_server->host_port_pair(); 83 net::HostPortPair host_port_pair = test_server->host_port_pair();
82 int port = host_port_pair.port(); 84 int port = host_port_pair.port();
83 ASSERT_TRUE(port > 0); 85 ASSERT_TRUE(port > 0);
84 86
85 // Test that connect() is properly resolving hostnames. 87 // Test that connect() is properly resolving hostnames.
86 host_port_pair.set_host("lOcAlHoSt"); 88 host_port_pair.set_host("lOcAlHoSt");
87 89
88 ResultCatcher catcher; 90 ResultCatcher catcher;
89 catcher.RestrictToBrowserContext(browser_context()); 91 catcher.RestrictToBrowserContext(browser_context());
90 92
91 ExtensionTestMessageListener listener("info_please", true); 93 ExtensionTestMessageListener listener("info_please", true);
92 94
93 ASSERT_TRUE(LoadApp("sockets_tcp/api")); 95 ASSERT_TRUE(LoadApp("sockets_tcp/api"));
94 EXPECT_TRUE(listener.WaitUntilSatisfied()); 96 EXPECT_TRUE(listener.WaitUntilSatisfied());
95 listener.Reply( 97 listener.Reply(
96 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port)); 98 base::StringPrintf("tcp:%s:%d", host_port_pair.host().c_str(), port));
97 99
98 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 100 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
99 } 101 }
100 102
101 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) { 103 IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) {
102 scoped_ptr<net::SpawnedTestServer> test_https_server( 104 std::unique_ptr<net::SpawnedTestServer> test_https_server(
103 new net::SpawnedTestServer( 105 new net::SpawnedTestServer(
104 net::SpawnedTestServer::TYPE_HTTPS, net::BaseTestServer::SSLOptions(), 106 net::SpawnedTestServer::TYPE_HTTPS, net::BaseTestServer::SSLOptions(),
105 base::FilePath(FILE_PATH_LITERAL("net/data")))); 107 base::FilePath(FILE_PATH_LITERAL("net/data"))));
106 EXPECT_TRUE(test_https_server->Start()); 108 EXPECT_TRUE(test_https_server->Start());
107 109
108 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair(); 110 net::HostPortPair https_host_port_pair = test_https_server->host_port_pair();
109 int https_port = https_host_port_pair.port(); 111 int https_port = https_host_port_pair.port();
110 ASSERT_GT(https_port, 0); 112 ASSERT_GT(https_port, 0);
111 113
112 ResultCatcher catcher; 114 ResultCatcher catcher;
113 catcher.RestrictToBrowserContext(browser_context()); 115 catcher.RestrictToBrowserContext(browser_context());
114 116
115 ExtensionTestMessageListener listener("info_please", true); 117 ExtensionTestMessageListener listener("info_please", true);
116 118
117 ASSERT_TRUE(LoadApp("sockets_tcp/api")); 119 ASSERT_TRUE(LoadApp("sockets_tcp/api"));
118 EXPECT_TRUE(listener.WaitUntilSatisfied()); 120 EXPECT_TRUE(listener.WaitUntilSatisfied());
119 listener.Reply(base::StringPrintf( 121 listener.Reply(base::StringPrintf(
120 "https:%s:%d", https_host_port_pair.host().c_str(), https_port)); 122 "https:%s:%d", https_host_port_pair.host().c_str(), https_port));
121 123
122 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 124 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
123 } 125 }
124 126
125 } // namespace extensions 127 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698