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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 const int kDummyPort = 4321; | 22 const int 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 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE { | 31 virtual int Listen(const net::IPEndPoint& address, int backlog) override { |
32 return net::OK; | 32 return net::OK; |
33 } | 33 } |
34 | 34 |
35 virtual int ListenWithAddressAndPort(const std::string& ip_address, | 35 virtual int ListenWithAddressAndPort(const std::string& ip_address, |
36 int port, | 36 int port, |
37 int backlog) OVERRIDE { | 37 int backlog) override { |
38 return net::OK; | 38 return net::OK; |
39 } | 39 } |
40 | 40 |
41 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE { | 41 virtual 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 } |
47 | 47 |
48 virtual int Accept(scoped_ptr<net::StreamSocket>* socket, | 48 virtual int Accept(scoped_ptr<net::StreamSocket>* socket, |
49 const net::CompletionCallback& callback) OVERRIDE { | 49 const net::CompletionCallback& callback) override { |
50 return net::ERR_IO_PENDING; | 50 return net::ERR_IO_PENDING; |
51 } | 51 } |
52 }; | 52 }; |
53 | 53 |
54 class DummyServerSocketFactory | 54 class DummyServerSocketFactory |
55 : public DevToolsHttpHandler::ServerSocketFactory { | 55 : public DevToolsHttpHandler::ServerSocketFactory { |
56 public: | 56 public: |
57 DummyServerSocketFactory(base::Closure quit_closure_1, | 57 DummyServerSocketFactory(base::Closure quit_closure_1, |
58 base::Closure quit_closure_2) | 58 base::Closure quit_closure_2) |
59 : DevToolsHttpHandler::ServerSocketFactory("", 0, 0), | 59 : DevToolsHttpHandler::ServerSocketFactory("", 0, 0), |
60 quit_closure_1_(quit_closure_1), | 60 quit_closure_1_(quit_closure_1), |
61 quit_closure_2_(quit_closure_2) {} | 61 quit_closure_2_(quit_closure_2) {} |
62 | 62 |
63 virtual ~DummyServerSocketFactory() { | 63 virtual ~DummyServerSocketFactory() { |
64 BrowserThread::PostTask( | 64 BrowserThread::PostTask( |
65 BrowserThread::UI, FROM_HERE, quit_closure_2_); | 65 BrowserThread::UI, FROM_HERE, quit_closure_2_); |
66 } | 66 } |
67 | 67 |
68 private: | 68 private: |
69 virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE { | 69 virtual scoped_ptr<net::ServerSocket> Create() const override { |
70 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
71 BrowserThread::UI, FROM_HERE, quit_closure_1_); | 71 BrowserThread::UI, FROM_HERE, quit_closure_1_); |
72 return scoped_ptr<net::ServerSocket>(new DummyServerSocket()); | 72 return scoped_ptr<net::ServerSocket>(new DummyServerSocket()); |
73 } | 73 } |
74 | 74 |
75 base::Closure quit_closure_1_; | 75 base::Closure quit_closure_1_; |
76 base::Closure quit_closure_2_; | 76 base::Closure quit_closure_2_; |
77 }; | 77 }; |
78 | 78 |
79 class DummyDelegate : public DevToolsHttpHandlerDelegate { | 79 class DummyDelegate : public DevToolsHttpHandlerDelegate { |
80 public: | 80 public: |
81 virtual std::string GetDiscoveryPageHTML() OVERRIDE { return std::string(); } | 81 virtual std::string GetDiscoveryPageHTML() override { return std::string(); } |
82 | 82 |
83 virtual bool BundlesFrontendResources() OVERRIDE { return true; } | 83 virtual bool BundlesFrontendResources() override { return true; } |
84 | 84 |
85 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { | 85 virtual base::FilePath GetDebugFrontendDir() override { |
86 return base::FilePath(); | 86 return base::FilePath(); |
87 } | 87 } |
88 | 88 |
89 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( | 89 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( |
90 net::StreamListenSocket::Delegate* delegate, | 90 net::StreamListenSocket::Delegate* delegate, |
91 std::string* name) OVERRIDE { | 91 std::string* name) override { |
92 return scoped_ptr<net::StreamListenSocket>(); | 92 return scoped_ptr<net::StreamListenSocket>(); |
93 } | 93 } |
94 }; | 94 }; |
95 | 95 |
96 } | 96 } |
97 | 97 |
98 class DevToolsHttpHandlerTest : public testing::Test { | 98 class DevToolsHttpHandlerTest : public testing::Test { |
99 public: | 99 public: |
100 DevToolsHttpHandlerTest() | 100 DevToolsHttpHandlerTest() |
101 : ui_thread_(BrowserThread::UI, &message_loop_) { | 101 : ui_thread_(BrowserThread::UI, &message_loop_) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 kDevToolsActivePortFileName); | 160 kDevToolsActivePortFileName); |
161 EXPECT_TRUE(base::PathExists(active_port_file)); | 161 EXPECT_TRUE(base::PathExists(active_port_file)); |
162 std::string file_contents; | 162 std::string file_contents; |
163 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); | 163 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); |
164 int port = 0; | 164 int port = 0; |
165 EXPECT_TRUE(base::StringToInt(file_contents, &port)); | 165 EXPECT_TRUE(base::StringToInt(file_contents, &port)); |
166 EXPECT_EQ(kDummyPort, port); | 166 EXPECT_EQ(kDummyPort, port); |
167 } | 167 } |
168 | 168 |
169 } // namespace content | 169 } // namespace content |
OLD | NEW |