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

Side by Side Diff: content/shell/browser/layout_test/layout_test_devtools_frontend.cc

Issue 2742623002: DevTools: improve test infrastructure w/ devtools driving the test (Closed)
Patch Set: fixup Created 3 years, 9 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shell/browser/layout_test/layout_test_devtools_frontend.h" 5 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/shell/browser/layout_test/blink_test_controller.h" 16 #include "content/shell/browser/layout_test/blink_test_controller.h"
17 #include "content/shell/browser/shell.h" 17 #include "content/shell/browser/shell.h"
18 //#include "content/shell/browser/shell_devtools_frontend.h"
18 #include "content/shell/common/layout_test/layout_test_switches.h" 19 #include "content/shell/common/layout_test/layout_test_switches.h"
19 #include "net/base/filename_util.h" 20 #include "net/base/filename_util.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 // static 24 // static
25 LayoutTestDevToolsFrontend*
26 LayoutTestDevToolsFrontend::CreateDevToolsMainWindow(
27 const Shell& inspected_window,
28 const std::string& test_url_spec) {
29 Shell* devtools_shell = Shell::CreateNewWindow(
30 inspected_window.web_contents()->GetBrowserContext(), GURL(), NULL,
31 gfx::Size());
32 LayoutTestDevToolsFrontend* devtools_frontend =
33 new LayoutTestDevToolsFrontend(devtools_shell,
34 inspected_window.web_contents());
35 devtools_frontend->Activate();
36 devtools_frontend->Focus();
37 return devtools_frontend;
38 }
39
40 // static
24 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show( 41 LayoutTestDevToolsFrontend* LayoutTestDevToolsFrontend::Show(
25 WebContents* inspected_contents, 42 WebContents* inspected_contents,
26 const std::string& settings, 43 const std::string& settings,
27 const std::string& frontend_url) { 44 const std::string& frontend_url) {
28 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(), 45 Shell* shell = Shell::CreateNewWindow(inspected_contents->GetBrowserContext(),
29 GURL(), 46 GURL(),
30 NULL, 47 NULL,
31 gfx::Size()); 48 gfx::Size());
32 LayoutTestDevToolsFrontend* devtools_frontend = 49 LayoutTestDevToolsFrontend* devtools_frontend =
33 new LayoutTestDevToolsFrontend(shell, inspected_contents); 50 new LayoutTestDevToolsFrontend(shell, inspected_contents);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 GURL result = 84 GURL result =
68 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); 85 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html"));
69 std::string url_string = 86 std::string url_string =
70 base::StringPrintf("%s?experiments=true", result.spec().c_str()); 87 base::StringPrintf("%s?experiments=true", result.spec().c_str());
71 if (is_debug_dev_tools) 88 if (is_debug_dev_tools)
72 url_string += "&debugFrontend=true"; 89 url_string += "&debugFrontend=true";
73 return GURL(url_string); 90 return GURL(url_string);
74 } 91 }
75 92
76 // static. 93 // static.
77 GURL LayoutTestDevToolsFrontend::MapJSTestURL(const GURL& test_url) { 94 GURL LayoutTestDevToolsFrontend::MapIntegrationTestURL(const GURL& test_url) {
78 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); 95 std::string url_string = GetDevToolsPathAsURL(std::string()).spec();
79 std::string inspector_file_name = "inspector.html"; 96 std::string inspector_file_name = "inspector.html";
80 size_t start_position = url_string.find(inspector_file_name); 97 size_t start_position = url_string.find(inspector_file_name);
98 url_string.replace(start_position, inspector_file_name.length(),
99 "integration_test_runner.html");
100 url_string += "&test=" + test_url.spec();
101 return GURL(url_string);
102 }
103
104 // static.
105 GURL LayoutTestDevToolsFrontend::MapUnitTestURL(const GURL& test_url) {
106 std::string url_string = GetDevToolsPathAsURL(std::string()).spec();
107 std::string inspector_file_name = "inspector.html";
108 size_t start_position = url_string.find(inspector_file_name);
81 url_string.replace(start_position, inspector_file_name.length(), 109 url_string.replace(start_position, inspector_file_name.length(),
82 "unit_test_runner.html"); 110 "unit_test_runner.html");
83 url_string += "&test=" + test_url.spec(); 111 url_string += "&test=" + test_url.spec();
84 return GURL(url_string); 112 return GURL(url_string);
85 } 113 }
86 114
87 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings, 115 void LayoutTestDevToolsFrontend::ReuseFrontend(const std::string& settings,
88 const std::string frontend_url) { 116 const std::string frontend_url) {
89 DisconnectFromTarget(); 117 DisconnectFromTarget();
90 SetPreferences(settings); 118 SetPreferences(settings);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 base::TerminationStatus status) { 177 base::TerminationStatus status) {
150 BlinkTestController::Get()->DevToolsProcessCrashed(); 178 BlinkTestController::Get()->DevToolsProcessCrashed();
151 } 179 }
152 180
153 void LayoutTestDevToolsFrontend::RenderFrameCreated( 181 void LayoutTestDevToolsFrontend::RenderFrameCreated(
154 RenderFrameHost* render_frame_host) { 182 RenderFrameHost* render_frame_host) {
155 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); 183 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host);
156 } 184 }
157 185
158 } // namespace content 186 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698