| 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 "chrome/test/webdriver/webdriver_util.h" | 5 #include "chrome/test/webdriver/webdriver_util.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 if (!second_file.empty()) { | 385 if (!second_file.empty()) { |
| 386 *error_msg = "Zip contained multiple files"; | 386 *error_msg = "Zip contained multiple files"; |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| 389 *file = first_file; | 389 *file = first_file; |
| 390 return true; | 390 return true; |
| 391 } | 391 } |
| 392 | 392 |
| 393 std::string JsonStringify(const Value* value) { | 393 std::string JsonStringify(const Value* value) { |
| 394 std::string json; | 394 std::string json; |
| 395 base::JSONWriter::Write(value, false, &json); | 395 base::JSONWriter::Write(value, &json); |
| 396 return json; | 396 return json; |
| 397 } | 397 } |
| 398 | 398 |
| 399 namespace { | 399 namespace { |
| 400 | 400 |
| 401 // Truncates the given string to 100 characters, adding an ellipsis if | 401 // Truncates the given string to 100 characters, adding an ellipsis if |
| 402 // truncation was necessary. | 402 // truncation was necessary. |
| 403 void TruncateString(std::string* data) { | 403 void TruncateString(std::string* data) { |
| 404 const size_t kMaxLength = 100; | 404 const size_t kMaxLength = 100; |
| 405 if (data->length() > kMaxLength) { | 405 if (data->length() > kMaxLength) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (value->IsType(Value::TYPE_STRING)) { | 449 if (value->IsType(Value::TYPE_STRING)) { |
| 450 std::string data; | 450 std::string data; |
| 451 value->GetAsString(&data); | 451 value->GetAsString(&data); |
| 452 TruncateString(&data); | 452 TruncateString(&data); |
| 453 copy.reset(Value::CreateStringValue(data)); | 453 copy.reset(Value::CreateStringValue(data)); |
| 454 } else { | 454 } else { |
| 455 copy.reset(value->DeepCopy()); | 455 copy.reset(value->DeepCopy()); |
| 456 TruncateContainedStrings(copy.get()); | 456 TruncateContainedStrings(copy.get()); |
| 457 } | 457 } |
| 458 std::string json; | 458 std::string json; |
| 459 base::JSONWriter::Write(copy.get(), true /* pretty_print */, &json); | 459 base::JSONWriter::WriteWithOptions(copy.get(), |
| 460 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 461 &json); |
| 460 return json; | 462 return json; |
| 461 } | 463 } |
| 462 | 464 |
| 463 const char* GetJsonTypeName(Value::Type type) { | 465 const char* GetJsonTypeName(Value::Type type) { |
| 464 switch (type) { | 466 switch (type) { |
| 465 case Value::TYPE_NULL: | 467 case Value::TYPE_NULL: |
| 466 return "null"; | 468 return "null"; |
| 467 case Value::TYPE_BOOLEAN: | 469 case Value::TYPE_BOOLEAN: |
| 468 return "boolean"; | 470 return "boolean"; |
| 469 case Value::TYPE_INTEGER: | 471 case Value::TYPE_INTEGER: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 551 |
| 550 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( | 552 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( |
| 551 const Value* value, const webdriver::SkipParsing* t) { | 553 const Value* value, const webdriver::SkipParsing* t) { |
| 552 return true; | 554 return true; |
| 553 } | 555 } |
| 554 | 556 |
| 555 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( | 557 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( |
| 556 const Value* value) { | 558 const Value* value) { |
| 557 return true; | 559 return true; |
| 558 } | 560 } |
| OLD | NEW |