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> | |
8 #include <cctype> | |
7 #include <clocale> | 9 #include <clocale> |
8 #include <cmath> | 10 #include <cmath> |
9 | 11 |
10 #include "base/base64.h" | 12 #include "base/base64.h" |
11 #include "base/debug/debugger.h" | 13 #include "base/debug/debugger.h" |
12 #include "base/md5.h" | 14 #include "base/md5.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 16 #include "base/message_loop.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" |
(...skipping 280 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/")) { |
Nico
2013/02/19 16:02:53
.find("/tmp/") == 0?
(or indexof() instead of fin
jochen (gone - plz use gerrit)
2013/02/20 09:06:13
Done.
| |
309 return std::string(); | 311 // We want a temp file. |
312 const unsigned kTempPrefixLength = 5; | |
Nico
2013/02/19 16:02:53
strlen("/tmp") instead of 5
jochen (gone - plz use gerrit)
2013/02/20 09:06:13
Done.
| |
313 GURL base_url = net::FilePathToFileURL(temp_path_); | |
314 return base_url.Resolve(resource.substr(kTempPrefixLength)).spec(); | |
Nico
2013/02/19 15:51:50
Hm, is there code for this somewhere else already?
jochen (gone - plz use gerrit)
2013/02/20 09:06:13
nope
| |
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 lower_url = resource; | |
321 std::string result = resource; | |
322 std::transform( | |
323 lower_url.begin(), lower_url.end(), lower_url.begin(), tolower); | |
Nico
2013/02/19 16:02:53
StringToLowerASCII?
| |
324 while (!lower_url.find("file:////")) { | |
Nico
2013/02/19 16:02:53
Probably simpler if you create a new temporary eac
jochen (gone - plz use gerrit)
2013/02/20 09:06:13
Done.
| |
325 result = result.substr(0, 8) + result.substr(9); | |
326 lower_url = lower_url.substr(0, 8) + lower_url.substr(9); | |
327 } | |
328 return rewriteLayoutTestsURL(result).spec(); | |
310 } | 329 } |
311 | 330 |
312 void WebKitTestRunner::setLocale(const std::string& locale) { | 331 void WebKitTestRunner::setLocale(const std::string& locale) { |
313 setlocale(LC_ALL, locale.c_str()); | 332 setlocale(LC_ALL, locale.c_str()); |
314 } | 333 } |
315 | 334 |
316 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { | 335 void WebKitTestRunner::setDeviceOrientation(WebDeviceOrientation& orientation) { |
317 Send(new ShellViewHostMsg_NotImplemented( | 336 Send(new ShellViewHostMsg_NotImplemented( |
318 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); | 337 routing_id(), "WebKitTestRunner", "setDeviceOrientation")); |
319 } | 338 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 routing_id(), actual_pixel_hash, snapshot)); | 576 routing_id(), actual_pixel_hash, snapshot)); |
558 } | 577 } |
559 } | 578 } |
560 | 579 |
561 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); | 580 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); |
562 } | 581 } |
563 | 582 |
564 void WebKitTestRunner::OnSetTestConfiguration( | 583 void WebKitTestRunner::OnSetTestConfiguration( |
565 const ShellViewMsg_SetTestConfiguration_Params& params) { | 584 const ShellViewMsg_SetTestConfiguration_Params& params) { |
566 current_working_directory_ = params.current_working_directory; | 585 current_working_directory_ = params.current_working_directory; |
586 temp_path_ = params.temp_path; | |
567 enable_pixel_dumping_ = params.enable_pixel_dumping; | 587 enable_pixel_dumping_ = params.enable_pixel_dumping; |
568 layout_test_timeout_ = params.layout_test_timeout; | 588 layout_test_timeout_ = params.layout_test_timeout; |
569 allow_external_pages_ = params.allow_external_pages; | 589 allow_external_pages_ = params.allow_external_pages; |
570 expected_pixel_hash_ = params.expected_pixel_hash; | 590 expected_pixel_hash_ = params.expected_pixel_hash; |
571 is_main_window_ = true; | 591 is_main_window_ = true; |
572 | 592 |
573 WebTestInterfaces* interfaces = | 593 WebTestInterfaces* interfaces = |
574 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 594 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
575 interfaces->setTestIsRunning(true); | 595 interfaces->setTestIsRunning(true); |
576 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); | 596 interfaces->configureForTestWithURL(params.test_url, enable_pixel_dumping_); |
577 } | 597 } |
578 | 598 |
579 } // namespace content | 599 } // namespace content |
OLD | NEW |