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/file_util.h" | 7 #include "base/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 24 matching lines...) Expand all Loading... |
35 mock_current_time_exploded.month = 11; | 35 mock_current_time_exploded.month = 11; |
36 mock_current_time_exploded.day_of_month = 15; | 36 mock_current_time_exploded.day_of_month = 15; |
37 mock_current_time_exploded.hour = 12; | 37 mock_current_time_exploded.hour = 12; |
38 mock_current_time_exploded.minute = 45; | 38 mock_current_time_exploded.minute = 45; |
39 base::Time mock_current_time( | 39 base::Time mock_current_time( |
40 base::Time::FromLocalExploded(mock_current_time_exploded)); | 40 base::Time::FromLocalExploded(mock_current_time_exploded)); |
41 | 41 |
42 SCOPED_TRACE(base::StringPrintf("Test case: %s", GetParam())); | 42 SCOPED_TRACE(base::StringPrintf("Test case: %s", GetParam())); |
43 | 43 |
44 std::string test_listing; | 44 std::string test_listing; |
45 EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(GetParam()), | 45 EXPECT_TRUE(base::ReadFileToString(test_dir.AppendASCII(GetParam()), |
46 &test_listing)); | 46 &test_listing)); |
47 | 47 |
48 std::vector<FtpDirectoryListingEntry> entries; | 48 std::vector<FtpDirectoryListingEntry> entries; |
49 EXPECT_EQ(OK, ParseFtpDirectoryListing(test_listing, | 49 EXPECT_EQ(OK, ParseFtpDirectoryListing(test_listing, |
50 mock_current_time, | 50 mock_current_time, |
51 &entries)); | 51 &entries)); |
52 | 52 |
53 std::string expected_listing; | 53 std::string expected_listing; |
54 ASSERT_TRUE(file_util::ReadFileToString( | 54 ASSERT_TRUE(base::ReadFileToString( |
55 test_dir.AppendASCII(std::string(GetParam()) + ".expected"), | 55 test_dir.AppendASCII(std::string(GetParam()) + ".expected"), |
56 &expected_listing)); | 56 &expected_listing)); |
57 | 57 |
58 std::vector<std::string> lines; | 58 std::vector<std::string> lines; |
59 base::SplitStringUsingSubstr(expected_listing, "\r\n", &lines); | 59 base::SplitStringUsingSubstr(expected_listing, "\r\n", &lines); |
60 | 60 |
61 // Special case for empty listings. | 61 // Special case for empty listings. |
62 if (lines.size() == 1 && lines[0].empty()) | 62 if (lines.size() == 1 && lines[0].empty()) |
63 lines.clear(); | 63 lines.clear(); |
64 | 64 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 "dir-listing-windows-1", | 157 "dir-listing-windows-1", |
158 "dir-listing-windows-2", | 158 "dir-listing-windows-2", |
159 }; | 159 }; |
160 | 160 |
161 INSTANTIATE_TEST_CASE_P(, FtpDirectoryListingParserTest, | 161 INSTANTIATE_TEST_CASE_P(, FtpDirectoryListingParserTest, |
162 testing::ValuesIn(kTestFiles)); | 162 testing::ValuesIn(kTestFiles)); |
163 | 163 |
164 } // namespace | 164 } // namespace |
165 | 165 |
166 } // namespace net | 166 } // namespace net |
OLD | NEW |