| 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 "net/ftp/ftp_directory_listing_parser.h" | 5 #include "net/ftp/ftp_directory_listing_parser.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 param.expected_result, | 62 param.expected_result, |
| 63 ParseFtpDirectoryListing(test_listing, mock_current_time, &entries)); | 63 ParseFtpDirectoryListing(test_listing, mock_current_time, &entries)); |
| 64 if (param.expected_result != OK) | 64 if (param.expected_result != OK) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 std::string expected_listing; | 67 std::string expected_listing; |
| 68 ASSERT_TRUE(base::ReadFileToString( | 68 ASSERT_TRUE(base::ReadFileToString( |
| 69 test_dir.AppendASCII(std::string(param.name) + ".expected"), | 69 test_dir.AppendASCII(std::string(param.name) + ".expected"), |
| 70 &expected_listing)); | 70 &expected_listing)); |
| 71 | 71 |
| 72 std::vector<std::string> lines; | 72 std::vector<std::string> lines = base::SplitStringUsingSubstr( |
| 73 base::SplitStringUsingSubstr(expected_listing, "\r\n", &lines); | 73 expected_listing, "\r\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 74 | 74 |
| 75 // Special case for empty listings. | 75 // Special case for empty listings. |
| 76 if (lines.size() == 1 && lines[0].empty()) | 76 if (lines.size() == 1 && lines[0].empty()) |
| 77 lines.clear(); | 77 lines.clear(); |
| 78 | 78 |
| 79 ASSERT_EQ(9 * entries.size(), lines.size()); | 79 ASSERT_EQ(9 * entries.size(), lines.size()); |
| 80 | 80 |
| 81 for (size_t i = 0; i < lines.size() / 9; i++) { | 81 for (size_t i = 0; i < lines.size() / 9; i++) { |
| 82 std::string type(lines[9 * i]); | 82 std::string type(lines[9 * i]); |
| 83 std::string name(lines[9 * i + 1]); | 83 std::string name(lines[9 * i + 1]); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 INSTANTIATE_TEST_CASE_P(, | 177 INSTANTIATE_TEST_CASE_P(, |
| 178 FtpDirectoryListingParserTest, | 178 FtpDirectoryListingParserTest, |
| 179 testing::ValuesIn(kTestParams), | 179 testing::ValuesIn(kTestParams), |
| 180 TestName); | 180 TestName); |
| 181 | 181 |
| 182 } // namespace | 182 } // namespace |
| 183 | 183 |
| 184 } // namespace net | 184 } // namespace net |
| OLD | NEW |