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 const unsigned kTempPrefixLength = strlen("/tmp/"); | |
313 GURL base_url = net::FilePathToFileURL(temp_path_); | |
314 return base_url.Resolve(resource.substr(kTempPrefixLength)).spec(); | |
315 } | |
316 #endif | |
317 | |
318 // Some layout tests use file://// which we resolve as a UNC path. Normalize | |
319 // them to just file:///. | |
320 std::string result = resource; | |
321 while (StringToLowerASCII(result).find("file:////") == 0) | |
322 result = result.substr(0, 8) + result.substr(9); | |
Nico
2013/02/20 09:10:37
nit: maybe strlen("file:///") instead of 8 and str
| |
323 return rewriteLayoutTestsURL(result).spec(); | |
310 } | 324 } |
311 | 325 |
312 void WebKitTestRunner::setLocale(const std::string& locale) { | 326 void WebKitTestRunner::setLocale(const std::string& locale) { |
313 setlocale(LC_ALL, locale.c_str()); | 327 setlocale(LC_ALL, locale.c_str()); |
314 } | 328 } |
315 | 329 |
316 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { | 330 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { |
317 Send(new ShellViewHostMsg_NotImplemented( | 331 Send(new ShellViewHostMsg_NotImplemented( |
318 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); | 332 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); |
319 } | 333 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 routing_id(), actual_pixel_hash, snapshot)); | 569 routing_id(), actual_pixel_hash, snapshot)); |
556 } | 570 } |
557 } | 571 } |
558 | 572 |
559 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); | 573 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); |
560 } | 574 } |
561 | 575 |
562 void WebKitTestRunner::OnSetTestConfiguration( | 576 void WebKitTestRunner::OnSetTestConfiguration( |
563 const ShellViewMsg_SetTestConfiguration_Params& params) { | 577 const ShellViewMsg_SetTestConfiguration_Params& params) { |
564 current_working_directory_ = params.current_working_directory; | 578 current_working_directory_ = params.current_working_directory; |
579 temp_path_ = params.temp_path; | |
565 enable_pixel_dumping_ = params.enable_pixel_dumping; | 580 enable_pixel_dumping_ = params.enable_pixel_dumping; |
566 layout_test_timeout_ = params.layout_test_timeout; | 581 layout_test_timeout_ = params.layout_test_timeout; |
567 allow_external_pages_ = params.allow_external_pages; | 582 allow_external_pages_ = params.allow_external_pages; |
568 expected_pixel_hash_ = params.expected_pixel_hash; | 583 expected_pixel_hash_ = params.expected_pixel_hash; |
569 is_main_window_ = true; | 584 is_main_window_ = true; |
570 | 585 |
571 WebTestInterfaces* interfaces = | 586 WebTestInterfaces* interfaces = |
572 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 587 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
573 interfaces->setTestIsRunning(true); | 588 interfaces->setTestIsRunning(true); |
574 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); | 589 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); |
575 } | 590 } |
576 | 591 |
577 } // namespace content | 592 } // namespace content |
OLD | NEW |