| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file contains the definition for LayoutTestController. | 5 // This file contains the definition for LayoutTestController. |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/layout_test_controller.h" | 9 #include "webkit/tools/test_shell/layout_test_controller.h" |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "third_party/WebKit/WebKit/chromium/public/WebAnimationController.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebAnimationController.h" |
| 22 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
| 23 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
| 24 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientation.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientation.h" |
| 25 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationClientMo
ck.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationClientMo
ck.h" |
| 26 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
| 27 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
| 28 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 28 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 29 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 30 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" |
| 31 #else |
| 29 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceMock.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceMock.h" |
| 33 #endif |
| 30 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 34 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
| 31 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 35 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
| 32 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" | 36 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" |
| 33 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" | 37 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" |
| 34 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" | 38 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
| 35 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputControllerMock
.h" | 39 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputControllerMock
.h" |
| 36 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 40 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 37 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 41 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
| 38 #include "webkit/glue/dom_operations.h" | 42 #include "webkit/glue/dom_operations.h" |
| 39 #include "webkit/glue/webkit_glue.h" | 43 #include "webkit/glue/webkit_glue.h" |
| 40 #include "webkit/glue/webpreferences.h" | 44 #include "webkit/glue/webpreferences.h" |
| 41 #include "webkit/tools/test_shell/notification_presenter.h" | 45 #include "webkit/tools/test_shell/notification_presenter.h" |
| 42 #include "webkit/tools/test_shell/simple_database_system.h" | 46 #include "webkit/tools/test_shell/simple_database_system.h" |
| 43 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 47 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 44 #include "webkit/tools/test_shell/test_navigation_controller.h" | 48 #include "webkit/tools/test_shell/test_navigation_controller.h" |
| 45 #include "webkit/tools/test_shell/test_shell.h" | 49 #include "webkit/tools/test_shell/test_shell.h" |
| 46 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" | 50 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" |
| 47 #include "webkit/tools/test_shell/test_webview_delegate.h" | 51 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 48 | 52 |
| 49 using std::string; | 53 using std::string; |
| 50 using std::wstring; | 54 using std::wstring; |
| 51 | 55 |
| 52 using WebKit::WebBindings; | 56 using WebKit::WebBindings; |
| 53 using WebKit::WebConsoleMessage; | 57 using WebKit::WebConsoleMessage; |
| 54 using WebKit::WebElement; | 58 using WebKit::WebElement; |
| 55 using WebKit::WebGeolocationServiceMock; | |
| 56 using WebKit::WebScriptSource; | 59 using WebKit::WebScriptSource; |
| 57 using WebKit::WebSecurityPolicy; | 60 using WebKit::WebSecurityPolicy; |
| 58 using WebKit::WebSize; | 61 using WebKit::WebSize; |
| 59 using WebKit::WebString; | 62 using WebKit::WebString; |
| 60 using WebKit::WebURL; | 63 using WebKit::WebURL; |
| 61 | 64 |
| 65 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 66 using WebKit::WebGeolocationServiceMock; |
| 67 #endif |
| 68 |
| 62 TestShell* LayoutTestController::shell_ = NULL; | 69 TestShell* LayoutTestController::shell_ = NULL; |
| 63 // Most of these flags need to be cleared in Reset() so that they get turned | 70 // Most of these flags need to be cleared in Reset() so that they get turned |
| 64 // off between each test run. | 71 // off between each test run. |
| 65 bool LayoutTestController::generate_pixel_results_ = true; | 72 bool LayoutTestController::generate_pixel_results_ = true; |
| 66 bool LayoutTestController::dump_as_text_ = false; | 73 bool LayoutTestController::dump_as_text_ = false; |
| 67 bool LayoutTestController::dump_editing_callbacks_ = false; | 74 bool LayoutTestController::dump_editing_callbacks_ = false; |
| 68 bool LayoutTestController::dump_frame_load_callbacks_ = false; | 75 bool LayoutTestController::dump_frame_load_callbacks_ = false; |
| 69 bool LayoutTestController::dump_resource_load_callbacks_ = false; | 76 bool LayoutTestController::dump_resource_load_callbacks_ = false; |
| 70 bool LayoutTestController::dump_resource_response_mime_types_ = false; | 77 bool LayoutTestController::dump_resource_response_mime_types_ = false; |
| 71 bool LayoutTestController::dump_back_forward_list_ = false; | 78 bool LayoutTestController::dump_back_forward_list_ = false; |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 "Should be 'mac', 'win', or 'unix'."); | 1493 "Should be 'mac', 'win', or 'unix'."); |
| 1487 return; | 1494 return; |
| 1488 } | 1495 } |
| 1489 shell_->webView()->settings()->setEditingBehavior(behavior); | 1496 shell_->webView()->settings()->setEditingBehavior(behavior); |
| 1490 } | 1497 } |
| 1491 | 1498 |
| 1492 void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, | 1499 void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, |
| 1493 CppVariant* result) { | 1500 CppVariant* result) { |
| 1494 if (args.size() < 1 || !args[0].isBool()) | 1501 if (args.size() < 1 || !args[0].isBool()) |
| 1495 return; | 1502 return; |
| 1503 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 1504 shell_->geolocation_client_mock()->setPermission( |
| 1505 args[0].ToBoolean()); |
| 1506 #else |
| 1496 shell_->delegate()->SetGeolocationPermission(args[0].ToBoolean()); | 1507 shell_->delegate()->SetGeolocationPermission(args[0].ToBoolean()); |
| 1508 #endif |
| 1497 } | 1509 } |
| 1498 | 1510 |
| 1499 void LayoutTestController::setMockGeolocationPosition( | 1511 void LayoutTestController::setMockGeolocationPosition( |
| 1500 const CppArgumentList& args, CppVariant* result) { | 1512 const CppArgumentList& args, CppVariant* result) { |
| 1501 if (args.size() < 3 || | 1513 if (args.size() < 3 || |
| 1502 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) | 1514 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) |
| 1503 return; | 1515 return; |
| 1516 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 1517 shell_->geolocation_client_mock()->setPosition( |
| 1518 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); |
| 1519 #else |
| 1504 WebGeolocationServiceMock::setMockGeolocationPosition( | 1520 WebGeolocationServiceMock::setMockGeolocationPosition( |
| 1505 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); | 1521 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); |
| 1522 #endif |
| 1506 } | 1523 } |
| 1507 | 1524 |
| 1508 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, | 1525 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, |
| 1509 CppVariant* result) { | 1526 CppVariant* result) { |
| 1510 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) | 1527 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) |
| 1511 return; | 1528 return; |
| 1529 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) |
| 1530 shell_->geolocation_client_mock()->setError( |
| 1531 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); |
| 1532 #else |
| 1512 WebGeolocationServiceMock::setMockGeolocationError( | 1533 WebGeolocationServiceMock::setMockGeolocationError( |
| 1513 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); | 1534 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); |
| 1535 #endif |
| 1514 } | 1536 } |
| 1515 | 1537 |
| 1516 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, | 1538 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, |
| 1517 CppVariant* result) { | 1539 CppVariant* result) { |
| 1518 WebElement element; | 1540 WebElement element; |
| 1519 if (!WebBindings::getElement(args[0].value.objectValue, &element)) | 1541 if (!WebBindings::getElement(args[0].value.objectValue, &element)) |
| 1520 result->SetNull(); | 1542 result->SetNull(); |
| 1521 else | 1543 else |
| 1522 result->Set( | 1544 result->Set( |
| 1523 element.document().frame()->markerTextForListItem(element).utf8()); | 1545 element.document().frame()->markerTextForListItem(element).utf8()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1540 shell_->device_orientation_client_mock()->setOrientation(orientation); | 1562 shell_->device_orientation_client_mock()->setOrientation(orientation); |
| 1541 } | 1563 } |
| 1542 | 1564 |
| 1543 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, | 1565 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, |
| 1544 CppVariant* result) { | 1566 CppVariant* result) { |
| 1545 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) | 1567 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) |
| 1546 return; | 1568 return; |
| 1547 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( | 1569 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( |
| 1548 arguments[0].ToInt32(), arguments[1].ToInt32())); | 1570 arguments[0].ToInt32(), arguments[1].ToInt32())); |
| 1549 } | 1571 } |
| OLD | NEW |