| 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" | 29 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" |
| 31 #else | |
| 32 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceMock.h" | |
| 33 #endif | |
| 34 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
| 35 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 31 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
| 36 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" |
| 37 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" | 33 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" |
| 38 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" | 34 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
| 39 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputControllerMock
.h" | 35 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputControllerMock
.h" |
| 40 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 36 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 41 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 37 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
| 42 #include "webkit/glue/dom_operations.h" | 38 #include "webkit/glue/dom_operations.h" |
| 43 #include "webkit/glue/webkit_glue.h" | 39 #include "webkit/glue/webkit_glue.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 | 51 |
| 56 using WebKit::WebBindings; | 52 using WebKit::WebBindings; |
| 57 using WebKit::WebConsoleMessage; | 53 using WebKit::WebConsoleMessage; |
| 58 using WebKit::WebElement; | 54 using WebKit::WebElement; |
| 59 using WebKit::WebScriptSource; | 55 using WebKit::WebScriptSource; |
| 60 using WebKit::WebSecurityPolicy; | 56 using WebKit::WebSecurityPolicy; |
| 61 using WebKit::WebSize; | 57 using WebKit::WebSize; |
| 62 using WebKit::WebString; | 58 using WebKit::WebString; |
| 63 using WebKit::WebURL; | 59 using WebKit::WebURL; |
| 64 | 60 |
| 65 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 66 using WebKit::WebGeolocationServiceMock; | |
| 67 #endif | |
| 68 | |
| 69 TestShell* LayoutTestController::shell_ = NULL; | 61 TestShell* LayoutTestController::shell_ = NULL; |
| 70 // Most of these flags need to be cleared in Reset() so that they get turned | 62 // Most of these flags need to be cleared in Reset() so that they get turned |
| 71 // off between each test run. | 63 // off between each test run. |
| 72 bool LayoutTestController::generate_pixel_results_ = true; | 64 bool LayoutTestController::generate_pixel_results_ = true; |
| 73 bool LayoutTestController::dump_as_text_ = false; | 65 bool LayoutTestController::dump_as_text_ = false; |
| 74 bool LayoutTestController::dump_editing_callbacks_ = false; | 66 bool LayoutTestController::dump_editing_callbacks_ = false; |
| 75 bool LayoutTestController::dump_frame_load_callbacks_ = false; | 67 bool LayoutTestController::dump_frame_load_callbacks_ = false; |
| 76 bool LayoutTestController::dump_resource_load_callbacks_ = false; | 68 bool LayoutTestController::dump_resource_load_callbacks_ = false; |
| 77 bool LayoutTestController::dump_resource_response_mime_types_ = false; | 69 bool LayoutTestController::dump_resource_response_mime_types_ = false; |
| 78 bool LayoutTestController::dump_back_forward_list_ = false; | 70 bool LayoutTestController::dump_back_forward_list_ = false; |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1493 "Should be 'mac', 'win', or 'unix'."); | 1485 "Should be 'mac', 'win', or 'unix'."); |
| 1494 return; | 1486 return; |
| 1495 } | 1487 } |
| 1496 shell_->webView()->settings()->setEditingBehavior(behavior); | 1488 shell_->webView()->settings()->setEditingBehavior(behavior); |
| 1497 } | 1489 } |
| 1498 | 1490 |
| 1499 void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, | 1491 void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, |
| 1500 CppVariant* result) { | 1492 CppVariant* result) { |
| 1501 if (args.size() < 1 || !args[0].isBool()) | 1493 if (args.size() < 1 || !args[0].isBool()) |
| 1502 return; | 1494 return; |
| 1503 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 1504 shell_->geolocation_client_mock()->setPermission( | 1495 shell_->geolocation_client_mock()->setPermission( |
| 1505 args[0].ToBoolean()); | 1496 args[0].ToBoolean()); |
| 1506 #else | |
| 1507 shell_->delegate()->SetGeolocationPermission(args[0].ToBoolean()); | |
| 1508 #endif | |
| 1509 } | 1497 } |
| 1510 | 1498 |
| 1511 void LayoutTestController::setMockGeolocationPosition( | 1499 void LayoutTestController::setMockGeolocationPosition( |
| 1512 const CppArgumentList& args, CppVariant* result) { | 1500 const CppArgumentList& args, CppVariant* result) { |
| 1513 if (args.size() < 3 || | 1501 if (args.size() < 3 || |
| 1514 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) | 1502 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) |
| 1515 return; | 1503 return; |
| 1516 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 1517 shell_->geolocation_client_mock()->setPosition( | 1504 shell_->geolocation_client_mock()->setPosition( |
| 1518 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); | 1505 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); |
| 1519 #else | |
| 1520 WebGeolocationServiceMock::setMockGeolocationPosition( | |
| 1521 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); | |
| 1522 #endif | |
| 1523 } | 1506 } |
| 1524 | 1507 |
| 1525 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, | 1508 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, |
| 1526 CppVariant* result) { | 1509 CppVariant* result) { |
| 1527 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) | 1510 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) |
| 1528 return; | 1511 return; |
| 1529 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
| 1530 shell_->geolocation_client_mock()->setError( | 1512 shell_->geolocation_client_mock()->setError( |
| 1531 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); | 1513 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); |
| 1532 #else | |
| 1533 WebGeolocationServiceMock::setMockGeolocationError( | |
| 1534 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); | |
| 1535 #endif | |
| 1536 } | 1514 } |
| 1537 | 1515 |
| 1538 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, | 1516 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, |
| 1539 CppVariant* result) { | 1517 CppVariant* result) { |
| 1540 WebElement element; | 1518 WebElement element; |
| 1541 if (!WebBindings::getElement(args[0].value.objectValue, &element)) | 1519 if (!WebBindings::getElement(args[0].value.objectValue, &element)) |
| 1542 result->SetNull(); | 1520 result->SetNull(); |
| 1543 else | 1521 else |
| 1544 result->Set( | 1522 result->Set( |
| 1545 element.document().frame()->markerTextForListItem(element).utf8()); | 1523 element.document().frame()->markerTextForListItem(element).utf8()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1562 shell_->device_orientation_client_mock()->setOrientation(orientation); | 1540 shell_->device_orientation_client_mock()->setOrientation(orientation); |
| 1563 } | 1541 } |
| 1564 | 1542 |
| 1565 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, | 1543 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, |
| 1566 CppVariant* result) { | 1544 CppVariant* result) { |
| 1567 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) | 1545 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) |
| 1568 return; | 1546 return; |
| 1569 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( | 1547 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( |
| 1570 arguments[0].ToInt32(), arguments[1].ToInt32())); | 1548 arguments[0].ToInt32(), arguments[1].ToInt32())); |
| 1571 } | 1549 } |
| OLD | NEW |