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

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: all 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_integration_test) {
63 std::string spec = test_url.spec();
64 *is_integration_test = spec.find("/devtools-js/") != std::string::npos;
65 bool is_unit_test = spec.find("/inspector-unit/") != std::string::npos;
66 if (!*is_integration_test && !is_unit_test) {
dgozman 2017/06/19 22:55:51 nit: no need for {}
chenwilliam 2017/06/19 23:48:17 Done.
67 return test_url;
68 }
69 std::string test_page;
70 if (is_integration_test)
dgozman 2017/06/19 22:55:51 *is_integration_test
chenwilliam 2017/06/19 23:48:17 Done. Ah, so it was running the unit tests as inte
71 test_page = "integration_test_runner.html";
72 else
73 test_page = "unit_test_runner.html";
74 return MapJSTestURL(test_url, test_page);
dgozman 2017/06/19 22:55:51 MapJSTestURL(test_url, is_unit_test ? "unit_test_r
chenwilliam 2017/06/19 23:48:17 Done.
75 }
76
77 // static.
78 GURL LayoutTestDevToolsBindings::MapJSTestURL(
79 const GURL& test_url,
80 const std::string& entry_filename) {
62 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); 81 std::string url_string = GetDevToolsPathAsURL(std::string()).spec();
63 std::string inspector_file_name = "inspector.html"; 82 std::string inspector_file_name = "inspector.html";
64 size_t start_position = url_string.find(inspector_file_name); 83 size_t start_position = url_string.find(inspector_file_name);
65 url_string.replace(start_position, inspector_file_name.length(), 84 url_string.replace(start_position, inspector_file_name.length(),
66 "unit_test_runner.html"); 85 entry_filename);
67 url_string += "&test=" + test_url.spec(); 86 url_string += "&test=" + test_url.spec();
68 return GURL(url_string); 87 return GURL(url_string);
69 } 88 }
70 89
71 // static 90 // static
72 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools( 91 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools(
73 WebContents* devtools_contents_, 92 WebContents* devtools_contents_,
74 WebContents* inspected_contents_, 93 WebContents* inspected_contents_,
75 const std::string& settings, 94 const std::string& settings,
76 const std::string& frontend_url) { 95 const std::string& frontend_url) {
77 LayoutTestDevToolsBindings* bindings = 96 LayoutTestDevToolsBindings* bindings =
78 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_); 97 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_);
79 bindings->SetPreferences(settings); 98 bindings->SetPreferences(settings);
80 GURL devtools_url = 99 GURL devtools_url =
81 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url); 100 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url);
82 NavigationController::LoadURLParams params(devtools_url); 101 NavigationController::LoadURLParams params(devtools_url);
83 params.transition_type = ui::PageTransitionFromInt( 102 params.transition_type = ui::PageTransitionFromInt(
84 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); 103 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
85 bindings->web_contents()->GetController().LoadURLWithParams(params); 104 bindings->web_contents()->GetController().LoadURLWithParams(params);
86 bindings->web_contents()->Focus(); 105 bindings->web_contents()->Focus();
87 bindings->CreateFrontendHost();
88 return bindings; 106 return bindings;
89 } 107 }
90 108
91 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id, 109 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id,
92 const std::string& script) { 110 const std::string& script) {
93 if (!ready_for_test_) { 111 if (!ready_for_test_) {
94 pending_evaluations_.push_back(std::make_pair(call_id, script)); 112 pending_evaluations_.push_back(std::make_pair(call_id, script));
95 return; 113 return;
96 } 114 }
97 115
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::TerminationStatus status) { 151 base::TerminationStatus status) {
134 BlinkTestController::Get()->DevToolsProcessCrashed(); 152 BlinkTestController::Get()->DevToolsProcessCrashed();
135 } 153 }
136 154
137 void LayoutTestDevToolsBindings::RenderFrameCreated( 155 void LayoutTestDevToolsBindings::RenderFrameCreated(
138 RenderFrameHost* render_frame_host) { 156 RenderFrameHost* render_frame_host) {
139 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); 157 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host);
140 } 158 }
141 159
142 } // namespace content 160 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698