| OLD | NEW |
| 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 "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/socket/server_socket.h" | 16 #include "net/socket/server_socket.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const int kDummyPort = 4321; | 22 const uint16 kDummyPort = 4321; |
| 23 const base::FilePath::CharType kDevToolsActivePortFileName[] = | 23 const base::FilePath::CharType kDevToolsActivePortFileName[] = |
| 24 FILE_PATH_LITERAL("DevToolsActivePort"); | 24 FILE_PATH_LITERAL("DevToolsActivePort"); |
| 25 | 25 |
| 26 class DummyServerSocket : public net::ServerSocket { | 26 class DummyServerSocket : public net::ServerSocket { |
| 27 public: | 27 public: |
| 28 DummyServerSocket() {} | 28 DummyServerSocket() {} |
| 29 | 29 |
| 30 // net::ServerSocket "implementation" | 30 // net::ServerSocket "implementation" |
| 31 int Listen(const net::IPEndPoint& address, int backlog) override { | 31 int Listen(const net::IPEndPoint& address, int backlog) override { |
| 32 return net::OK; | 32 return net::OK; |
| 33 } | 33 } |
| 34 | 34 |
| 35 int ListenWithAddressAndPort(const std::string& ip_address, | 35 int ListenWithAddressAndPort(const std::string& ip_address, |
| 36 int port, | 36 uint16 port, |
| 37 int backlog) override { | 37 int backlog) override { |
| 38 return net::OK; | 38 return net::OK; |
| 39 } | 39 } |
| 40 | 40 |
| 41 int GetLocalAddress(net::IPEndPoint* address) const override { | 41 int GetLocalAddress(net::IPEndPoint* address) const override { |
| 42 net::IPAddressNumber number; | 42 net::IPAddressNumber number; |
| 43 EXPECT_TRUE(net::ParseIPLiteralToNumber("127.0.0.1", &number)); | 43 EXPECT_TRUE(net::ParseIPLiteralToNumber("127.0.0.1", &number)); |
| 44 *address = net::IPEndPoint(number, kDummyPort); | 44 *address = net::IPEndPoint(number, kDummyPort); |
| 45 return net::OK; | 45 return net::OK; |
| 46 } | 46 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Now make sure the DevToolsActivePort was written into the | 152 // Now make sure the DevToolsActivePort was written into the |
| 153 // temporary directory and its contents are as expected. | 153 // temporary directory and its contents are as expected. |
| 154 base::FilePath active_port_file = temp_dir.path().Append( | 154 base::FilePath active_port_file = temp_dir.path().Append( |
| 155 kDevToolsActivePortFileName); | 155 kDevToolsActivePortFileName); |
| 156 EXPECT_TRUE(base::PathExists(active_port_file)); | 156 EXPECT_TRUE(base::PathExists(active_port_file)); |
| 157 std::string file_contents; | 157 std::string file_contents; |
| 158 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); | 158 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); |
| 159 int port = 0; | 159 int port = 0; |
| 160 EXPECT_TRUE(base::StringToInt(file_contents, &port)); | 160 EXPECT_TRUE(base::StringToInt(file_contents, &port)); |
| 161 EXPECT_EQ(kDummyPort, port); | 161 EXPECT_EQ(static_cast<int>(kDummyPort), port); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace content | 164 } // namespace content |
| OLD | NEW |