| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webkit_test_runner.h" | 5 #include "content/shell/webkit_test_runner.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 7 #include <clocale> | 8 #include <clocale> |
| 8 #include <cmath> | 9 #include <cmath> |
| 9 | 10 |
| 10 #include "base/base64.h" | 11 #include "base/base64.h" |
| 11 #include "base/debug/debugger.h" | 12 #include "base/debug/debugger.h" |
| 12 #include "base/md5.h" | 13 #include "base/md5.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 16 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
| 17 #include "base/time.h" | 19 #include "base/time.h" |
| 18 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 19 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
| 20 #include "content/public/test/layouttest_support.h" | 22 #include "content/public/test/layouttest_support.h" |
| 21 #include "content/shell/shell_messages.h" | 23 #include "content/shell/shell_messages.h" |
| 22 #include "content/shell/shell_render_process_observer.h" | 24 #include "content/shell/shell_render_process_observer.h" |
| 23 #include "content/shell/webkit_test_helpers.h" | 25 #include "content/shell/webkit_test_helpers.h" |
| 24 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 void WebKitTestRunner::setFocus(bool focus) { | 299 void WebKitTestRunner::setFocus(bool focus) { |
| 298 Send(new ShellViewHostMsg_NotImplemented( | 300 Send(new ShellViewHostMsg_NotImplemented( |
| 299 routing_id(), "WebKitTestRunner", "setFocus")); | 301 routing_id(), "WebKitTestRunner", "setFocus")); |
| 300 } | 302 } |
| 301 | 303 |
| 302 void WebKitTestRunner::setAcceptAllCookies(bool accept) { | 304 void WebKitTestRunner::setAcceptAllCookies(bool accept) { |
| 303 Send(new ShellViewHostMsg_AcceptAllCookies(routing_id(), accept)); | 305 Send(new ShellViewHostMsg_AcceptAllCookies(routing_id(), accept)); |
| 304 } | 306 } |
| 305 | 307 |
| 306 std::string WebKitTestRunner::pathToLocalResource(const std::string& resource) { | 308 std::string WebKitTestRunner::pathToLocalResource(const std::string& resource) { |
| 307 Send(new ShellViewHostMsg_NotImplemented( | 309 #if defined(OS_WIN) |
| 308 routing_id(), "WebKitTestRunner", "pathToLocalResource")); | 310 if (resource.find("/tmp/") == 0) { |
| 309 return std::string(); | 311 // We want a temp file. |
| 312 GURL base_url = net::FilePathToFileURL(temp_path_); |
| 313 return base_url.Resolve(resource.substr(strlen("/tmp/"))).spec(); |
| 314 } |
| 315 #endif |
| 316 |
| 317 // Some layout tests use file://// which we resolve as a UNC path. Normalize |
| 318 // them to just file:///. |
| 319 std::string result = resource; |
| 320 while (StringToLowerASCII(result).find("file:////") == 0) { |
| 321 result = result.substr(0, strlen("file:///")) + |
| 322 result.substr(strlen("file:////")); |
| 323 } |
| 324 return rewriteLayoutTestsURL(result).spec(); |
| 310 } | 325 } |
| 311 | 326 |
| 312 void WebKitTestRunner::setLocale(const std::string& locale) { | 327 void WebKitTestRunner::setLocale(const std::string& locale) { |
| 313 setlocale(LC_ALL, locale.c_str()); | 328 setlocale(LC_ALL, locale.c_str()); |
| 314 } | 329 } |
| 315 | 330 |
| 316 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { | 331 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { |
| 317 Send(new ShellViewHostMsg_NotImplemented( | 332 Send(new ShellViewHostMsg_NotImplemented( |
| 318 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); | 333 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); |
| 319 } | 334 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 routing_id(), actual_pixel_hash, snapshot)); | 570 routing_id(), actual_pixel_hash, snapshot)); |
| 556 } | 571 } |
| 557 } | 572 } |
| 558 | 573 |
| 559 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); | 574 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); |
| 560 } | 575 } |
| 561 | 576 |
| 562 void WebKitTestRunner::OnSetTestConfiguration( | 577 void WebKitTestRunner::OnSetTestConfiguration( |
| 563 const ShellViewMsg_SetTestConfiguration_Params& params) { | 578 const ShellViewMsg_SetTestConfiguration_Params& params) { |
| 564 current_working_directory_ = params.current_working_directory; | 579 current_working_directory_ = params.current_working_directory; |
| 580 temp_path_ = params.temp_path; |
| 565 enable_pixel_dumping_ = params.enable_pixel_dumping; | 581 enable_pixel_dumping_ = params.enable_pixel_dumping; |
| 566 layout_test_timeout_ = params.layout_test_timeout; | 582 layout_test_timeout_ = params.layout_test_timeout; |
| 567 allow_external_pages_ = params.allow_external_pages; | 583 allow_external_pages_ = params.allow_external_pages; |
| 568 expected_pixel_hash_ = params.expected_pixel_hash; | 584 expected_pixel_hash_ = params.expected_pixel_hash; |
| 569 is_main_window_ = true; | 585 is_main_window_ = true; |
| 570 | 586 |
| 571 WebTestInterfaces* interfaces = | 587 WebTestInterfaces* interfaces = |
| 572 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 588 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 573 interfaces->setTestIsRunning(true); | 589 interfaces->setTestIsRunning(true); |
| 574 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); | 590 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); |
| 575 } | 591 } |
| 576 | 592 |
| 577 } // namespace content | 593 } // namespace content |
| OLD | NEW |