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

Side by Side Diff: content/browser/devtools/devtools_http_handler_unittest.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
11 #include "content/public/browser/devtools_http_handler.h" 11 #include "content/public/browser/devtools_http_handler.h"
12 #include "content/public/browser/devtools_http_handler_delegate.h" 12 #include "content/public/browser/devtools_http_handler_delegate.h"
13 #include "content/public/browser/devtools_target.h" 13 #include "content/public/browser/devtools_target.h"
14 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
15 #include "net/base/ip_endpoint.h" 15 #include "net/base/ip_endpoint.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/socket/server_socket.h" 17 #include "net/socket/server_socket.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace content { 20 namespace content {
21 namespace { 21 namespace {
22 22
23 const int kDummyPort = 4321; 23 const uint16 kDummyPort = 4321;
24 const base::FilePath::CharType kDevToolsActivePortFileName[] = 24 const base::FilePath::CharType kDevToolsActivePortFileName[] =
25 FILE_PATH_LITERAL("DevToolsActivePort"); 25 FILE_PATH_LITERAL("DevToolsActivePort");
26 26
27 class DummyServerSocket : public net::ServerSocket { 27 class DummyServerSocket : public net::ServerSocket {
28 public: 28 public:
29 DummyServerSocket() {} 29 DummyServerSocket() {}
30 30
31 // net::ServerSocket "implementation" 31 // net::ServerSocket "implementation"
32 int Listen(const net::IPEndPoint& address, int backlog) override { 32 int Listen(const net::IPEndPoint& address, int backlog) override {
33 return net::OK; 33 return net::OK;
34 } 34 }
35 35
36 int ListenWithAddressAndPort(const std::string& ip_address, 36 int ListenWithAddressAndPort(const std::string& ip_address,
37 int port, 37 uint16 port,
38 int backlog) override { 38 int backlog) override {
39 return net::OK; 39 return net::OK;
40 } 40 }
41 41
42 int GetLocalAddress(net::IPEndPoint* address) const override { 42 int GetLocalAddress(net::IPEndPoint* address) const override {
43 net::IPAddressNumber number; 43 net::IPAddressNumber number;
44 EXPECT_TRUE(net::ParseIPLiteralToNumber("127.0.0.1", &number)); 44 EXPECT_TRUE(net::ParseIPLiteralToNumber("127.0.0.1", &number));
45 *address = net::IPEndPoint(number, kDummyPort); 45 *address = net::IPEndPoint(number, kDummyPort);
46 return net::OK; 46 return net::OK;
47 } 47 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Now make sure the DevToolsActivePort was written into the 195 // Now make sure the DevToolsActivePort was written into the
196 // temporary directory and its contents are as expected. 196 // temporary directory and its contents are as expected.
197 base::FilePath active_port_file = temp_dir.path().Append( 197 base::FilePath active_port_file = temp_dir.path().Append(
198 kDevToolsActivePortFileName); 198 kDevToolsActivePortFileName);
199 EXPECT_TRUE(base::PathExists(active_port_file)); 199 EXPECT_TRUE(base::PathExists(active_port_file));
200 std::string file_contents; 200 std::string file_contents;
201 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); 201 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents));
202 int port = 0; 202 int port = 0;
203 EXPECT_TRUE(base::StringToInt(file_contents, &port)); 203 EXPECT_TRUE(base::StringToInt(file_contents, &port));
204 EXPECT_EQ(kDummyPort, port); 204 EXPECT_EQ(static_cast<int>(kDummyPort), port);
205 } 205 }
206 206
207 } // namespace content 207 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.cc ('k') | content/browser/devtools/protocol/tethering_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698