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

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

Issue 2837083003: DevTools: create test infrastructure so devtools drives the test (Closed)
Patch Set: rebaseline Created 3 years, 6 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_bindings.h" 5 #include "content/shell/browser/layout_test/layout_test_devtools_bindings.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"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 GURL result = 51 GURL result =
52 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); 52 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html"));
53 std::string url_string = 53 std::string url_string =
54 base::StringPrintf("%s?experiments=true", result.spec().c_str()); 54 base::StringPrintf("%s?experiments=true", result.spec().c_str());
55 if (is_debug_dev_tools) 55 if (is_debug_dev_tools)
56 url_string += "&debugFrontend=true"; 56 url_string += "&debugFrontend=true";
57 return GURL(url_string); 57 return GURL(url_string);
58 } 58 }
59 59
60 // static. 60 // static.
61 GURL LayoutTestDevToolsBindings::MapJSTestURL(const GURL& test_url) { 61 GURL LayoutTestDevToolsBindings::MapTestURLIfNeeded(const GURL& test_url,
62 bool* is_devtools_js_test) {
63 std::string spec = test_url.spec();
64 *is_devtools_js_test = spec.find("/devtools-js/") != std::string::npos;
65 bool is_unit_test = spec.find("/inspector-unit/") != std::string::npos;
66 if (!*is_devtools_js_test && !is_unit_test)
67 return test_url;
68 return MapJSTestURL(test_url, is_unit_test ? "unit_test_runner.html"
69 : "integration_test_runner.html");
70 }
71
72 // static.
73 GURL LayoutTestDevToolsBindings::MapJSTestURL(
74 const GURL& test_url,
75 const std::string& entry_filename) {
62 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); 76 std::string url_string = GetDevToolsPathAsURL(std::string()).spec();
63 std::string inspector_file_name = "inspector.html"; 77 std::string inspector_file_name = "inspector.html";
64 size_t start_position = url_string.find(inspector_file_name); 78 size_t start_position = url_string.find(inspector_file_name);
65 url_string.replace(start_position, inspector_file_name.length(), 79 url_string.replace(start_position, inspector_file_name.length(),
66 "unit_test_runner.html"); 80 entry_filename);
67 url_string += "&test=" + test_url.spec(); 81 url_string += "&test=" + test_url.spec();
68 return GURL(url_string); 82 return GURL(url_string);
69 } 83 }
70 84
71 // static 85 // static
72 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools( 86 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools(
73 WebContents* devtools_contents_, 87 WebContents* devtools_contents_,
74 WebContents* inspected_contents_, 88 WebContents* inspected_contents_,
75 const std::string& settings, 89 const std::string& settings,
76 const std::string& frontend_url) { 90 const std::string& frontend_url) {
77 LayoutTestDevToolsBindings* bindings = 91 LayoutTestDevToolsBindings* bindings =
78 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_); 92 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_);
79 bindings->SetPreferences(settings); 93 bindings->SetPreferences(settings);
80 GURL devtools_url = 94 GURL devtools_url =
81 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url); 95 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url);
82 NavigationController::LoadURLParams params(devtools_url); 96 NavigationController::LoadURLParams params(devtools_url);
83 params.transition_type = ui::PageTransitionFromInt( 97 params.transition_type = ui::PageTransitionFromInt(
84 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); 98 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
85 bindings->web_contents()->GetController().LoadURLWithParams(params); 99 bindings->web_contents()->GetController().LoadURLWithParams(params);
86 bindings->web_contents()->Focus(); 100 bindings->web_contents()->Focus();
87 bindings->CreateFrontendHost();
88 return bindings; 101 return bindings;
89 } 102 }
90 103
91 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id, 104 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id,
92 const std::string& script) { 105 const std::string& script) {
93 if (!ready_for_test_) { 106 if (!ready_for_test_) {
94 pending_evaluations_.push_back(std::make_pair(call_id, script)); 107 pending_evaluations_.push_back(std::make_pair(call_id, script));
95 return; 108 return;
96 } 109 }
97 110
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::TerminationStatus status) { 146 base::TerminationStatus status) {
134 BlinkTestController::Get()->DevToolsProcessCrashed(); 147 BlinkTestController::Get()->DevToolsProcessCrashed();
135 } 148 }
136 149
137 void LayoutTestDevToolsBindings::RenderFrameCreated( 150 void LayoutTestDevToolsBindings::RenderFrameCreated(
138 RenderFrameHost* render_frame_host) { 151 RenderFrameHost* render_frame_host) {
139 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); 152 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host);
140 } 153 }
141 154
142 } // namespace content 155 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_devtools_bindings.h ('k') | content/shell/browser/shell_devtools_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698