| 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 "content/browser/devtools/devtools_http_handler.h" | 5 #include "content/browser/devtools/devtools_http_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) { | 170 TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) { |
| 171 base::RunLoop run_loop, run_loop_2; | 171 base::RunLoop run_loop, run_loop_2; |
| 172 base::ScopedTempDir temp_dir; | 172 base::ScopedTempDir temp_dir; |
| 173 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | 173 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 174 std::unique_ptr<DevToolsSocketFactory> factory( | 174 std::unique_ptr<DevToolsSocketFactory> factory( |
| 175 new DummyServerSocketFactory(run_loop.QuitClosure(), | 175 new DummyServerSocketFactory(run_loop.QuitClosure(), |
| 176 run_loop_2.QuitClosure())); | 176 run_loop_2.QuitClosure())); |
| 177 | 177 |
| 178 DevToolsAgentHost::StartRemoteDebuggingServer( | 178 DevToolsAgentHost::StartRemoteDebuggingServer( |
| 179 std::move(factory), std::string(), temp_dir.path(), base::FilePath(), | 179 std::move(factory), std::string(), temp_dir.GetPath(), base::FilePath(), |
| 180 std::string(), std::string()); | 180 std::string(), std::string()); |
| 181 // Our dummy socket factory will post a quit message once the server will | 181 // Our dummy socket factory will post a quit message once the server will |
| 182 // become ready. | 182 // become ready. |
| 183 run_loop.Run(); | 183 run_loop.Run(); |
| 184 DevToolsAgentHost::StopRemoteDebuggingServer(); | 184 DevToolsAgentHost::StopRemoteDebuggingServer(); |
| 185 // Make sure the handler actually stops. | 185 // Make sure the handler actually stops. |
| 186 run_loop_2.Run(); | 186 run_loop_2.Run(); |
| 187 | 187 |
| 188 // Now make sure the DevToolsActivePort was written into the | 188 // Now make sure the DevToolsActivePort was written into the |
| 189 // temporary directory and its contents are as expected. | 189 // temporary directory and its contents are as expected. |
| 190 base::FilePath active_port_file = temp_dir.path().Append( | 190 base::FilePath active_port_file = |
| 191 kDevToolsActivePortFileName); | 191 temp_dir.GetPath().Append(kDevToolsActivePortFileName); |
| 192 EXPECT_TRUE(base::PathExists(active_port_file)); | 192 EXPECT_TRUE(base::PathExists(active_port_file)); |
| 193 std::string file_contents; | 193 std::string file_contents; |
| 194 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); | 194 EXPECT_TRUE(base::ReadFileToString(active_port_file, &file_contents)); |
| 195 int port = 0; | 195 int port = 0; |
| 196 EXPECT_TRUE(base::StringToInt(file_contents, &port)); | 196 EXPECT_TRUE(base::StringToInt(file_contents, &port)); |
| 197 EXPECT_EQ(static_cast<int>(kDummyPort), port); | 197 EXPECT_EQ(static_cast<int>(kDummyPort), port); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace content | 200 } // namespace content |
| OLD | NEW |