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 |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 WebString::fromUTF8(args[1].ToString())); | 1141 WebString::fromUTF8(args[1].ToString())); |
1142 } | 1142 } |
1143 result->SetNull(); | 1143 result->SetNull(); |
1144 } | 1144 } |
1145 | 1145 |
1146 // Need these conversions because the format of the value for booleans | 1146 // Need these conversions because the format of the value for booleans |
1147 // may vary - for example, on mac "1" and "0" are used for boolean. | 1147 // may vary - for example, on mac "1" and "0" are used for boolean. |
1148 bool LayoutTestController::CppVariantToBool(const CppVariant& value) { | 1148 bool LayoutTestController::CppVariantToBool(const CppVariant& value) { |
1149 if (value.isBool()) | 1149 if (value.isBool()) |
1150 return value.ToBoolean(); | 1150 return value.ToBoolean(); |
1151 else if (value.isInt32()) | 1151 else if (value.isNumber()) |
1152 return 0 != value.ToInt32(); | 1152 return 0 != value.ToInt32(); |
1153 else if (value.isString()) { | 1153 else if (value.isString()) { |
1154 std::string valueString = value.ToString(); | 1154 std::string valueString = value.ToString(); |
1155 if (valueString == "true" || valueString == "1") | 1155 if (valueString == "true" || valueString == "1") |
1156 return true; | 1156 return true; |
1157 if (valueString == "false" || valueString == "0") | 1157 if (valueString == "false" || valueString == "0") |
1158 return false; | 1158 return false; |
1159 } | 1159 } |
1160 LogErrorToConsole("Invalid value. Expected boolean value."); | 1160 LogErrorToConsole("Invalid value. Expected boolean value."); |
1161 return false; | 1161 return false; |
1162 } | 1162 } |
1163 | 1163 |
1164 int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) { | 1164 int32 LayoutTestController::CppVariantToInt32(const CppVariant& value) { |
1165 if (value.isInt32()) | 1165 if (value.isNumber()) |
1166 return value.ToInt32(); | 1166 return value.ToInt32(); |
1167 else if (value.isString()) { | 1167 else if (value.isString()) { |
1168 int number; | 1168 int number; |
1169 if (base::StringToInt(value.ToString(), &number)) | 1169 if (base::StringToInt(value.ToString(), &number)) |
1170 return number; | 1170 return number; |
1171 } | 1171 } |
1172 LogErrorToConsole("Invalid value for preference. Expected integer value."); | 1172 LogErrorToConsole("Invalid value for preference. Expected integer value."); |
1173 return 0; | 1173 return 0; |
1174 } | 1174 } |
1175 | 1175 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1308 |
1309 void LayoutTestController::clearAllDatabases( | 1309 void LayoutTestController::clearAllDatabases( |
1310 const CppArgumentList& args, CppVariant* result) { | 1310 const CppArgumentList& args, CppVariant* result) { |
1311 result->SetNull(); | 1311 result->SetNull(); |
1312 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); | 1312 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); |
1313 } | 1313 } |
1314 | 1314 |
1315 void LayoutTestController::setDatabaseQuota( | 1315 void LayoutTestController::setDatabaseQuota( |
1316 const CppArgumentList& args, CppVariant* result) { | 1316 const CppArgumentList& args, CppVariant* result) { |
1317 result->SetNull(); | 1317 result->SetNull(); |
1318 if ((args.size() >= 1) && args[0].isInt32()) | 1318 if ((args.size() >= 1) && args[0].isNumber()) |
1319 SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(args[0].ToInt32()); | 1319 SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(args[0].ToInt32()); |
1320 } | 1320 } |
1321 | 1321 |
1322 void LayoutTestController::setPOSIXLocale(const CppArgumentList& args, | 1322 void LayoutTestController::setPOSIXLocale(const CppArgumentList& args, |
1323 CppVariant* result) { | 1323 CppVariant* result) { |
1324 result->SetNull(); | 1324 result->SetNull(); |
1325 if (args.size() == 1 && args[0].isString()) { | 1325 if (args.size() == 1 && args[0].isString()) { |
1326 std::string new_locale = args[0].ToString(); | 1326 std::string new_locale = args[0].ToString(); |
1327 setlocale(LC_ALL, new_locale.c_str()); | 1327 setlocale(LC_ALL, new_locale.c_str()); |
1328 } | 1328 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 const CppArgumentList& args, CppVariant* result) { | 1418 const CppArgumentList& args, CppVariant* result) { |
1419 result->SetNull(); | 1419 result->SetNull(); |
1420 if (args.size() < 1 || !args[0].isBool()) | 1420 if (args.size() < 1 || !args[0].isBool()) |
1421 return; | 1421 return; |
1422 shell_->dev_tools_agent()->setTimelineProfilingEnabled(args[0].ToBoolean()); | 1422 shell_->dev_tools_agent()->setTimelineProfilingEnabled(args[0].ToBoolean()); |
1423 } | 1423 } |
1424 | 1424 |
1425 void LayoutTestController::evaluateInWebInspector(const CppArgumentList& args, | 1425 void LayoutTestController::evaluateInWebInspector(const CppArgumentList& args, |
1426 CppVariant* result) { | 1426 CppVariant* result) { |
1427 result->SetNull(); | 1427 result->SetNull(); |
1428 if (args.size() < 2 || !args[0].isInt32() || !args[1].isString()) | 1428 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) |
1429 return; | 1429 return; |
1430 shell_->dev_tools_agent()->evaluateInWebInspector(args[0].ToInt32(), | 1430 shell_->dev_tools_agent()->evaluateInWebInspector(args[0].ToInt32(), |
1431 args[1].ToString()); | 1431 args[1].ToString()); |
1432 } | 1432 } |
1433 | 1433 |
1434 void LayoutTestController::forceRedSelectionColors(const CppArgumentList& args, | 1434 void LayoutTestController::forceRedSelectionColors(const CppArgumentList& args, |
1435 CppVariant* result) { | 1435 CppVariant* result) { |
1436 result->SetNull(); | 1436 result->SetNull(); |
1437 shell_->webView()->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, | 1437 shell_->webView()->setSelectionColors(0xffee0000, 0xff00ee00, 0xff000000, |
1438 0xffc0c0c0); | 1438 0xffc0c0c0); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 const CppArgumentList& args, CppVariant* result) { | 1499 const CppArgumentList& args, CppVariant* result) { |
1500 if (args.size() < 3 || | 1500 if (args.size() < 3 || |
1501 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) | 1501 !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) |
1502 return; | 1502 return; |
1503 WebGeolocationServiceMock::setMockGeolocationPosition( | 1503 WebGeolocationServiceMock::setMockGeolocationPosition( |
1504 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); | 1504 args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); |
1505 } | 1505 } |
1506 | 1506 |
1507 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, | 1507 void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, |
1508 CppVariant* result) { | 1508 CppVariant* result) { |
1509 if (args.size() < 2 || | 1509 if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) |
1510 !args[0].isInt32() || !args[1].isString()) | |
1511 return; | 1510 return; |
1512 WebGeolocationServiceMock::setMockGeolocationError( | 1511 WebGeolocationServiceMock::setMockGeolocationError( |
1513 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); | 1512 args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); |
1514 } | 1513 } |
1515 | 1514 |
1516 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, | 1515 void LayoutTestController::markerTextForListItem(const CppArgumentList& args, |
1517 CppVariant* result) { | 1516 CppVariant* result) { |
1518 WebElement element; | 1517 WebElement element; |
1519 if (!WebBindings::getElement(args[0].value.objectValue, &element)) | 1518 if (!WebBindings::getElement(args[0].value.objectValue, &element)) |
1520 result->SetNull(); | 1519 result->SetNull(); |
(...skipping 19 matching lines...) Expand all Loading... |
1540 shell_->device_orientation_client_mock()->setOrientation(orientation); | 1539 shell_->device_orientation_client_mock()->setOrientation(orientation); |
1541 } | 1540 } |
1542 | 1541 |
1543 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, | 1542 void LayoutTestController::hasSpellingMarker(const CppArgumentList& arguments, |
1544 CppVariant* result) { | 1543 CppVariant* result) { |
1545 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) | 1544 if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber
()) |
1546 return; | 1545 return; |
1547 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( | 1546 result->Set(shell_->webView()->mainFrame()->selectionStartHasSpellingMarkerFor
( |
1548 arguments[0].ToInt32(), arguments[1].ToInt32())); | 1547 arguments[0].ToInt32(), arguments[1].ToInt32())); |
1549 } | 1548 } |
OLD | NEW |