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

Side by Side Diff: content/shell/browser/layout_test/blink_test_controller.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/blink_test_controller.h" 5 #include "content/shell/browser/layout_test/blink_test_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool BlinkTestController::PrepareForLayoutTest( 263 bool BlinkTestController::PrepareForLayoutTest(
264 const GURL& test_url, 264 const GURL& test_url,
265 const base::FilePath& current_working_directory, 265 const base::FilePath& current_working_directory,
266 bool enable_pixel_dumping, 266 bool enable_pixel_dumping,
267 const std::string& expected_pixel_hash) { 267 const std::string& expected_pixel_hash) {
268 DCHECK(CalledOnValidThread()); 268 DCHECK(CalledOnValidThread());
269 test_phase_ = DURING_TEST; 269 test_phase_ = DURING_TEST;
270 current_working_directory_ = current_working_directory; 270 current_working_directory_ = current_working_directory;
271 enable_pixel_dumping_ = enable_pixel_dumping; 271 enable_pixel_dumping_ = enable_pixel_dumping;
272 expected_pixel_hash_ = expected_pixel_hash; 272 expected_pixel_hash_ = expected_pixel_hash;
273 if (test_url.spec().find("/inspector-unit/") == std::string::npos) 273 bool is_devtools_js_test =
274 test_url.spec().find("/devtools-js/") != std::string::npos;
275 if (test_url.spec().find("/inspector-unit/") != std::string::npos)
276 test_url_ = LayoutTestDevToolsFrontend::MapUnitTestURL(test_url);
277 else if (is_devtools_js_test)
278 test_url_ = LayoutTestDevToolsFrontend::MapIntegrationTestURL(test_url);
279 else
274 test_url_ = test_url; 280 test_url_ = test_url;
275 else
276 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url);
277 did_send_initial_test_configuration_ = false; 281 did_send_initial_test_configuration_ = false;
278 printer_->reset(); 282 printer_->reset();
279 frame_to_layout_dump_map_.clear(); 283 frame_to_layout_dump_map_.clear();
280 render_process_host_observer_.RemoveAll(); 284 render_process_host_observer_.RemoveAll();
281 all_observed_render_process_hosts_.clear(); 285 all_observed_render_process_hosts_.clear();
282 main_window_render_process_hosts_.clear(); 286 main_window_render_process_hosts_.clear();
283 accumulated_layout_test_runtime_flags_changes_.Clear(); 287 accumulated_layout_test_runtime_flags_changes_.Clear();
284 layout_test_control_map_.clear(); 288 layout_test_control_map_.clear();
285 ShellBrowserContext* browser_context = 289 ShellBrowserContext* browser_context =
286 ShellContentBrowserClient::Get()->browser_context(); 290 ShellContentBrowserClient::Get()->browser_context();
287 is_compositing_test_ = 291 is_compositing_test_ =
288 test_url_.spec().find("compositing/") != std::string::npos; 292 test_url_.spec().find("compositing/") != std::string::npos;
289 initial_size_ = Shell::GetShellDefaultSize(); 293 initial_size_ = Shell::GetShellDefaultSize();
290 // The W3C SVG layout tests use a different size than the other layout tests. 294 // The W3C SVG layout tests use a different size than the other layout tests.
291 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) 295 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos)
292 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); 296 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip);
293 if (!main_window_) { 297 if (is_devtools_js_test) {
294 main_window_ = content::Shell::CreateNewWindow( 298 if (devtools_frontend_ && inspected_window_) {
295 browser_context, 299 devtools_frontend_->ReuseFrontend(std::string(), test_url_.spec());
296 GURL(), 300 inspected_window_->LoadURL(GURL(url::kAboutBlankURL));
297 NULL, 301 DevToolsAgentHost::GetOrCreateFor(inspected_window_->web_contents())
298 initial_size_); 302 ->AttachClient(devtools_frontend_);
303 } else {
304 inspected_window_.reset(content::Shell::CreateNewWindow(
305 browser_context, GURL(), NULL, initial_size_));
306 inspected_window_->LoadURL(GURL(url::kAboutBlankURL));
307 if (devtools_frontend_)
308 devtools_frontend_->Close();
309 devtools_frontend_ = LayoutTestDevToolsFrontend::CreateDevToolsMainWindow(
310 *inspected_window_);
311 main_window_ = devtools_frontend_->frontend_shell();
312 WebContentsObserver::Observe(main_window_->web_contents());
313 current_pid_ = base::kNullProcessId;
314 default_prefs_ = main_window_->web_contents()
315 ->GetRenderViewHost()
316 ->GetWebkitPreferences();
317 main_window_->LoadURL(test_url_);
318 }
319 } else if (!main_window_) {
320 main_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
321 NULL, initial_size_);
299 WebContentsObserver::Observe(main_window_->web_contents()); 322 WebContentsObserver::Observe(main_window_->web_contents());
300 current_pid_ = base::kNullProcessId; 323 current_pid_ = base::kNullProcessId;
301 default_prefs_ = 324 default_prefs_ =
302 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences(); 325 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
303 main_window_->LoadURL(test_url_); 326 main_window_->LoadURL(test_url_);
304 } else { 327 } else {
305 #if defined(OS_MACOSX) 328 #if defined(OS_MACOSX)
306 // Shell::SizeTo is not implemented on all platforms. 329 // Shell::SizeTo is not implemented on all platforms.
307 main_window_->SizeTo(initial_size_); 330 main_window_->SizeTo(initial_size_);
308 #endif 331 #endif
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 session_histories, 899 session_histories,
877 current_entry_indexes)); 900 current_entry_indexes));
878 } 901 }
879 902
880 void BlinkTestController::OnCloseRemainingWindows() { 903 void BlinkTestController::OnCloseRemainingWindows() {
881 DevToolsAgentHost::DetachAllClients(); 904 DevToolsAgentHost::DetachAllClients();
882 std::vector<Shell*> open_windows(Shell::windows()); 905 std::vector<Shell*> open_windows(Shell::windows());
883 Shell* devtools_shell = devtools_frontend_ ? 906 Shell* devtools_shell = devtools_frontend_ ?
884 devtools_frontend_->frontend_shell() : NULL; 907 devtools_frontend_->frontend_shell() : NULL;
885 for (size_t i = 0; i < open_windows.size(); ++i) { 908 for (size_t i = 0; i < open_windows.size(); ++i) {
886 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) 909 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell &&
910 open_windows[i] != inspected_window_.get())
887 open_windows[i]->Close(); 911 open_windows[i]->Close();
888 } 912 }
889 base::RunLoop().RunUntilIdle(); 913 base::RunLoop().RunUntilIdle();
890 } 914 }
891 915
892 void BlinkTestController::OnResetDone() { 916 void BlinkTestController::OnResetDone() {
893 if (is_leak_detection_enabled_) { 917 if (is_leak_detection_enabled_) {
894 if (main_window_ && main_window_->web_contents()) { 918 if (main_window_ && main_window_->web_contents()) {
895 RenderViewHost* render_view_host = 919 RenderViewHost* render_view_host =
896 main_window_->web_contents()->GetRenderViewHost(); 920 main_window_->web_contents()->GetRenderViewHost();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 999 }
976 DCHECK(layout_test_control_map_[frame].get()); 1000 DCHECK(layout_test_control_map_[frame].get());
977 return layout_test_control_map_[frame].get(); 1001 return layout_test_control_map_[frame].get();
978 } 1002 }
979 1003
980 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { 1004 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) {
981 layout_test_control_map_.erase(frame); 1005 layout_test_control_map_.erase(frame);
982 } 1006 }
983 1007
984 } // namespace content 1008 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698