OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromedriver/element_commands.h" | 5 #include "chrome/test/chromedriver/element_commands.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // Compress array into a single string. | 327 // Compress array into a single string. |
328 base::FilePath::StringType paths_string; | 328 base::FilePath::StringType paths_string; |
329 for (size_t i = 0; i < key_list->GetSize(); ++i) { | 329 for (size_t i = 0; i < key_list->GetSize(); ++i) { |
330 base::FilePath::StringType path_part; | 330 base::FilePath::StringType path_part; |
331 if (!key_list->GetString(i, &path_part)) | 331 if (!key_list->GetString(i, &path_part)) |
332 return Status(kUnknownError, "'value' is invalid"); | 332 return Status(kUnknownError, "'value' is invalid"); |
333 paths_string.append(path_part); | 333 paths_string.append(path_part); |
334 } | 334 } |
335 | 335 |
336 // Separate the string into separate paths, delimited by '\n'. | 336 // Separate the string into separate paths, delimited by '\n'. |
337 std::vector<base::FilePath::StringType> path_strings; | |
338 base::SplitString(paths_string, '\n', &path_strings); | |
339 std::vector<base::FilePath> paths; | 337 std::vector<base::FilePath> paths; |
340 for (size_t i = 0; i < path_strings.size(); ++i) | 338 for (const auto& path_piece : base::SplitStringPiece( |
341 paths.push_back(base::FilePath(path_strings[i])); | 339 paths_string, base::FilePath::StringType(1, '\n'), |
| 340 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) |
| 341 paths.push_back(base::FilePath(path_piece)); |
342 | 342 |
343 bool multiple = false; | 343 bool multiple = false; |
344 status = IsElementAttributeEqualToIgnoreCase( | 344 status = IsElementAttributeEqualToIgnoreCase( |
345 session, web_view, element_id, "multiple", "true", &multiple); | 345 session, web_view, element_id, "multiple", "true", &multiple); |
346 if (status.IsError()) | 346 if (status.IsError()) |
347 return status; | 347 return status; |
348 if (!multiple && paths.size() > 1) | 348 if (!multiple && paths.size() > 1) |
349 return Status(kUnknownError, "the element can not hold multiple files"); | 349 return Status(kUnknownError, "the element can not hold multiple files"); |
350 | 350 |
351 scoped_ptr<base::DictionaryValue> element(CreateElement(element_id)); | 351 scoped_ptr<base::DictionaryValue> element(CreateElement(element_id)); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 WebView* web_view, | 542 WebView* web_view, |
543 const std::string& element_id, | 543 const std::string& element_id, |
544 const base::DictionaryValue& params, | 544 const base::DictionaryValue& params, |
545 scoped_ptr<base::Value>* value) { | 545 scoped_ptr<base::Value>* value) { |
546 std::string other_element_id; | 546 std::string other_element_id; |
547 if (!params.GetString("other", &other_element_id)) | 547 if (!params.GetString("other", &other_element_id)) |
548 return Status(kUnknownError, "'other' must be a string"); | 548 return Status(kUnknownError, "'other' must be a string"); |
549 value->reset(new base::FundamentalValue(element_id == other_element_id)); | 549 value->reset(new base::FundamentalValue(element_id == other_element_id)); |
550 return Status(kOk); | 550 return Status(kOk); |
551 } | 551 } |
OLD | NEW |