| Index: content/browser/devtools/devtools_http_handler_unittest.cc
|
| diff --git a/components/devtools_http_handler/devtools_http_handler_unittest.cc b/content/browser/devtools/devtools_http_handler_unittest.cc
|
| similarity index 75%
|
| rename from components/devtools_http_handler/devtools_http_handler_unittest.cc
|
| rename to content/browser/devtools/devtools_http_handler_unittest.cc
|
| index d82cdb2987ac84eb6a5c37060153ddd4e2604bbf..e9fea882943c1baa39a2ad6d7d589e1d45712e54 100644
|
| --- a/components/devtools_http_handler/devtools_http_handler_unittest.cc
|
| +++ b/content/browser/devtools/devtools_http_handler_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/devtools_http_handler/devtools_http_handler.h"
|
| +#include "content/browser/devtools/devtools_http_handler.h"
|
|
|
| #include <stdint.h>
|
|
|
| @@ -18,7 +18,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "base/values.h"
|
| -#include "components/devtools_http_handler/devtools_http_handler_delegate.h"
|
| +#include "content/public/browser/devtools_manager_delegate.h"
|
| #include "content/public/browser/devtools_socket_factory.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| #include "content/public/test/test_utils.h"
|
| @@ -28,9 +28,7 @@
|
| #include "net/socket/server_socket.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -using content::BrowserThread;
|
| -
|
| -namespace devtools_http_handler {
|
| +namespace content {
|
| namespace {
|
|
|
| const uint16_t kDummyPort = 4321;
|
| @@ -61,7 +59,7 @@ void QuitFromHandlerThread(const base::Closure& quit_closure) {
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_closure);
|
| }
|
|
|
| -class DummyServerSocketFactory : public content::DevToolsSocketFactory {
|
| +class DummyServerSocketFactory : public DevToolsSocketFactory {
|
| public:
|
| DummyServerSocketFactory(base::Closure quit_closure_1,
|
| base::Closure quit_closure_2)
|
| @@ -104,12 +102,22 @@ class FailingServerSocketFactory : public DummyServerSocketFactory {
|
| }
|
| };
|
|
|
| -class DummyDelegate : public DevToolsHttpHandlerDelegate {
|
| +class DummyDelegate : public DevToolsManagerDelegate {
|
| public:
|
| - std::string GetDiscoveryPageHTML() override { return std::string(); }
|
| -
|
| + void Inspect(DevToolsAgentHost* agent_host) override {}
|
| + void DevToolsAgentStateChanged(DevToolsAgentHost* agent_host,
|
| + bool attached) override {}
|
| + std::string GetTargetType(RenderFrameHost* host) override { return ""; }
|
| + std::string GetTargetTitle(RenderFrameHost* host) override { return ""; }
|
| + scoped_refptr<DevToolsAgentHost> CreateNewTarget(const GURL& url) override {
|
| + return nullptr;
|
| + }
|
| + base::DictionaryValue* HandleCommand(
|
| + DevToolsAgentHost* agent_host,
|
| + base::DictionaryValue* command) override { return nullptr; }
|
| + std::string GetDiscoveryPageHTML() override { return ""; }
|
| std::string GetFrontendResource(const std::string& path) override {
|
| - return std::string();
|
| + return "";
|
| }
|
| };
|
|
|
| @@ -125,30 +133,28 @@ class DevToolsHttpHandlerTest : public testing::Test {
|
|
|
| TEST_F(DevToolsHttpHandlerTest, TestStartStop) {
|
| base::RunLoop run_loop, run_loop_2;
|
| - std::unique_ptr<content::DevToolsSocketFactory> factory(
|
| + std::unique_ptr<DevToolsSocketFactory> factory(
|
| new DummyServerSocketFactory(run_loop.QuitClosure(),
|
| run_loop_2.QuitClosure()));
|
| - std::unique_ptr<DevToolsHttpHandler> devtools_http_handler(
|
| - new DevToolsHttpHandler(std::move(factory), std::string(),
|
| - new DummyDelegate(), base::FilePath(),
|
| - base::FilePath(), std::string(), std::string()));
|
| + DevToolsAgentHost::StartRemoteDebuggingServer(
|
| + std::move(factory), std::string(), base::FilePath(), base::FilePath(),
|
| + std::string(), std::string());
|
| // Our dummy socket factory will post a quit message once the server will
|
| // become ready.
|
| run_loop.Run();
|
| - devtools_http_handler.reset();
|
| + DevToolsAgentHost::StopRemoteDebuggingServer();
|
| // Make sure the handler actually stops.
|
| run_loop_2.Run();
|
| }
|
|
|
| TEST_F(DevToolsHttpHandlerTest, TestServerSocketFailed) {
|
| base::RunLoop run_loop, run_loop_2;
|
| - std::unique_ptr<content::DevToolsSocketFactory> factory(
|
| + std::unique_ptr<DevToolsSocketFactory> factory(
|
| new FailingServerSocketFactory(run_loop.QuitClosure(),
|
| run_loop_2.QuitClosure()));
|
| - std::unique_ptr<DevToolsHttpHandler> devtools_http_handler(
|
| - new DevToolsHttpHandler(std::move(factory), std::string(),
|
| - new DummyDelegate(), base::FilePath(),
|
| - base::FilePath(), std::string(), std::string()));
|
| + DevToolsAgentHost::StartRemoteDebuggingServer(
|
| + std::move(factory), std::string(), base::FilePath(), base::FilePath(),
|
| + std::string(), std::string());
|
| // Our dummy socket factory will post a quit message once the server will
|
| // become ready.
|
| run_loop.Run();
|
| @@ -156,7 +162,7 @@ TEST_F(DevToolsHttpHandlerTest, TestServerSocketFailed) {
|
| RunAllPendingInMessageLoop(BrowserThread::UI);
|
| RunAllPendingInMessageLoop(BrowserThread::FILE);
|
| }
|
| - devtools_http_handler.reset();
|
| + DevToolsAgentHost::StopRemoteDebuggingServer();
|
| // Make sure the handler actually stops.
|
| run_loop_2.Run();
|
| }
|
| @@ -166,17 +172,17 @@ TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) {
|
| base::RunLoop run_loop, run_loop_2;
|
| base::ScopedTempDir temp_dir;
|
| EXPECT_TRUE(temp_dir.CreateUniqueTempDir());
|
| - std::unique_ptr<content::DevToolsSocketFactory> factory(
|
| + std::unique_ptr<DevToolsSocketFactory> factory(
|
| new DummyServerSocketFactory(run_loop.QuitClosure(),
|
| run_loop_2.QuitClosure()));
|
| - std::unique_ptr<DevToolsHttpHandler> devtools_http_handler(
|
| - new DevToolsHttpHandler(std::move(factory), std::string(),
|
| - new DummyDelegate(), temp_dir.path(),
|
| - base::FilePath(), std::string(), std::string()));
|
| +
|
| + DevToolsAgentHost::StartRemoteDebuggingServer(
|
| + std::move(factory), std::string(), base::FilePath(), base::FilePath(),
|
| + std::string(), std::string());
|
| // Our dummy socket factory will post a quit message once the server will
|
| // become ready.
|
| run_loop.Run();
|
| - devtools_http_handler.reset();
|
| + DevToolsAgentHost::StopRemoteDebuggingServer();
|
| // Make sure the handler actually stops.
|
| run_loop_2.Run();
|
|
|
| @@ -192,4 +198,4 @@ TEST_F(DevToolsHttpHandlerTest, TestDevToolsActivePort) {
|
| EXPECT_EQ(static_cast<int>(kDummyPort), port);
|
| }
|
|
|
| -} // namespace devtools_http_handler
|
| +} // namespace content
|
|
|