diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 10:35:27 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 10:35:27 +0000 |
commit | b7394ff0fd9dc89187d40860e7e86386c373c9ab (patch) | |
tree | 3a3b37db268e304d9f867952486a07ce673c778a /net/ftp | |
parent | 8ba4973cfcfe2a6b8c0cacca76fabe8b66d41646 (diff) | |
download | chromium_src-b7394ff0fd9dc89187d40860e7e86386c373c9ab.zip chromium_src-b7394ff0fd9dc89187d40860e7e86386c373c9ab.tar.gz chromium_src-b7394ff0fd9dc89187d40860e7e86386c373c9ab.tar.bz2 |
Fix the "ls -l" style date parser to correctly guess the year if it is not provided.
Also provide an infrastructure to mock the current time in the tests.
BUG=36293
TEST=net_unittests
Review URL: http://codereview.chromium.org/1120012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer.cc | 7 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer.h | 6 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_buffer_unittest.cc | 15 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls.cc | 18 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls.h | 9 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_ls_unittest.cc | 23 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_netware.cc | 8 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_netware.h | 9 | ||||
-rw-r--r-- | net/ftp/ftp_directory_listing_parser_netware_unittest.cc | 15 | ||||
-rw-r--r-- | net/ftp/ftp_util.cc | 23 | ||||
-rw-r--r-- | net/ftp/ftp_util.h | 7 | ||||
-rw-r--r-- | net/ftp/ftp_util_unittest.cc | 21 |
12 files changed, 106 insertions, 55 deletions
diff --git a/net/ftp/ftp_directory_listing_buffer.cc b/net/ftp/ftp_directory_listing_buffer.cc index 2376b8f..bc2db9c 100644 --- a/net/ftp/ftp_directory_listing_buffer.cc +++ b/net/ftp/ftp_directory_listing_buffer.cc @@ -43,11 +43,12 @@ std::string DetectEncoding(const std::string& text) { namespace net { -FtpDirectoryListingBuffer::FtpDirectoryListingBuffer() +FtpDirectoryListingBuffer::FtpDirectoryListingBuffer( + const base::Time& current_time) : current_parser_(NULL) { - parsers_.insert(new FtpDirectoryListingParserLs()); + parsers_.insert(new FtpDirectoryListingParserLs(current_time)); parsers_.insert(new FtpDirectoryListingParserMlsd()); - parsers_.insert(new FtpDirectoryListingParserNetware()); + parsers_.insert(new FtpDirectoryListingParserNetware(current_time)); parsers_.insert(new FtpDirectoryListingParserVms()); parsers_.insert(new FtpDirectoryListingParserWindows()); } diff --git a/net/ftp/ftp_directory_listing_buffer.h b/net/ftp/ftp_directory_listing_buffer.h index f71685c..7aead49 100644 --- a/net/ftp/ftp_directory_listing_buffer.h +++ b/net/ftp/ftp_directory_listing_buffer.h @@ -21,8 +21,10 @@ class FtpDirectoryListingParser; class FtpDirectoryListingBuffer { public: - FtpDirectoryListingBuffer(); - + // Constructor. When the current time is needed to guess the year on partial + // date strings, |current_time| will be used. This allows passing a specific + // date during testing. + explicit FtpDirectoryListingBuffer(const base::Time& current_time); ~FtpDirectoryListingBuffer(); // Called when data is received from the data socket. Returns network diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_buffer_unittest.cc index 0d144f5..d9708d5 100644 --- a/net/ftp/ftp_directory_listing_buffer_unittest.cc +++ b/net/ftp/ftp_directory_listing_buffer_unittest.cc @@ -54,10 +54,14 @@ TEST(FtpDirectoryListingBufferTest, Parse) { test_dir = test_dir.AppendASCII("data"); test_dir = test_dir.AppendASCII("ftp"); + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); + for (size_t i = 0; i < arraysize(test_files); i++) { SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i])); - net::FtpDirectoryListingBuffer buffer; + net::FtpDirectoryListingBuffer buffer(mock_current_time); std::string test_listing; EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]), @@ -85,14 +89,7 @@ TEST(FtpDirectoryListingBufferTest, Parse) { SCOPED_TRACE(StringPrintf("Filename: %s", name.c_str())); - int year; - if (lines[8 * i + 3] == "current") { - base::Time::Exploded now_exploded; - base::Time::Now().LocalExplode(&now_exploded); - year = now_exploded.year; - } else { - year = StringToInt(lines[8 * i + 3]); - } + int year = StringToInt(lines[8 * i + 3]); int month = StringToInt(lines[8 * i + 4]); int day_of_month = StringToInt(lines[8 * i + 5]); int hour = StringToInt(lines[8 * i + 6]); diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc index 1098cda..55f7844 100644 --- a/net/ftp/ftp_directory_listing_parser_ls.cc +++ b/net/ftp/ftp_directory_listing_parser_ls.cc @@ -42,12 +42,13 @@ bool LooksLikeUnixPermissionsListing(const string16& text) { (text.substr(10).empty() || text.substr(10) == ASCIIToUTF16("+"))); } -bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) { +bool DetectColumnOffset(const std::vector<string16>& columns, + const base::Time& current_time, int* offset) { base::Time time; if (columns.size() >= 8 && net::FtpUtil::LsDateListingToTime(columns[5], columns[6], columns[7], - &time)) { + current_time, &time)) { // Standard listing, exactly like ls -l. *offset = 2; return true; @@ -55,7 +56,7 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) { if (columns.size() >= 7 && net::FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6], - &time)) { + current_time, &time)) { // wu-ftpd listing, no "number of links" column. *offset = 1; return true; @@ -63,7 +64,7 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) { if (columns.size() >= 6 && net::FtpUtil::LsDateListingToTime(columns[3], columns[4], columns[5], - &time)) { + current_time, &time)) { // Xplain FTP Server listing for folders, like this: // drwxr-xr-x folder 0 Jul 17 2006 online *offset = 0; @@ -78,9 +79,11 @@ bool DetectColumnOffset(const std::vector<string16>& columns, int* offset) { namespace net { -FtpDirectoryListingParserLs::FtpDirectoryListingParserLs() +FtpDirectoryListingParserLs::FtpDirectoryListingParserLs( + const base::Time& current_time) : received_nonempty_line_(false), - received_total_line_(false) { + received_total_line_(false), + current_time_(current_time) { } bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { @@ -113,7 +116,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { } int column_offset; - if (!DetectColumnOffset(columns, &column_offset)) + if (!DetectColumnOffset(columns, current_time_, &column_offset)) return false; // We may receive file names containing spaces, which can make the number of @@ -144,6 +147,7 @@ bool FtpDirectoryListingParserLs::ConsumeLine(const string16& line) { if (!FtpUtil::LsDateListingToTime(columns[3 + column_offset], columns[4 + column_offset], columns[5 + column_offset], + current_time_, &entry.last_modified)) { return false; } diff --git a/net/ftp/ftp_directory_listing_parser_ls.h b/net/ftp/ftp_directory_listing_parser_ls.h index 3fd0d32..0d52791 100644 --- a/net/ftp/ftp_directory_listing_parser_ls.h +++ b/net/ftp/ftp_directory_listing_parser_ls.h @@ -7,6 +7,7 @@ #include <queue> +#include "base/time.h" #include "net/ftp/ftp_directory_listing_parser.h" namespace net { @@ -14,7 +15,10 @@ namespace net { // Parser for "ls -l"-style directory listing. class FtpDirectoryListingParserLs : public FtpDirectoryListingParser { public: - FtpDirectoryListingParserLs(); + // Constructor. When the current time is needed to guess the year on partial + // date strings, |current_time| will be used. This allows passing a specific + // date during testing. + explicit FtpDirectoryListingParserLs(const base::Time& current_time); // FtpDirectoryListingParser methods: virtual FtpServerType GetServerType() const { return SERVER_LS; } @@ -30,6 +34,9 @@ class FtpDirectoryListingParserLs : public FtpDirectoryListingParser { // integer. Only one such header is allowed per listing. bool received_total_line_; + // Store the current time. We need it to correctly parse received dates. + const base::Time current_time_; + std::queue<FtpDirectoryListingEntry> entries_; DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserLs); diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc index bd18066..608e0e2 100644 --- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc @@ -13,8 +13,9 @@ namespace { typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest; TEST_F(FtpDirectoryListingParserLsTest, Good) { - base::Time::Exploded now_exploded; - base::Time::Now().LocalExplode(&now_exploded); + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); const struct SingleLineTestData good_cases[] = { { "-rw-r--r-- 1 ftp ftp 528 Nov 01 2007 README", @@ -22,13 +23,13 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { 2007, 11, 1, 0, 0 }, { "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 directory", net::FtpDirectoryListingEntry::DIRECTORY, "directory", -1, - now_exploded.year, 5, 15, 18, 11 }, + 1994, 5, 15, 18, 11 }, { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub", net::FtpDirectoryListingEntry::SYMLINK, "pub", -1, 2008, 9, 18, 0, 0 }, { "lrwxrwxrwx 1 0 0 3 Oct 12 13:37 mirror -> pub", net::FtpDirectoryListingEntry::SYMLINK, "mirror", -1, - now_exploded.year, 10, 12, 13, 37 }, + 1994, 10, 12, 13, 37 }, { "drwxrwsr-x 4 501 501 4096 Feb 20 2007 pub", net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, 2007, 2, 20, 0, 0 }, @@ -37,13 +38,13 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { 2007, 4, 8, 0, 0 }, { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, - now_exploded.year, 7, 1, 2, 15 }, + 1994, 7, 1, 2, 15 }, { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, 2009, 5, 18, 0, 0 }, { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, - now_exploded.year, 12, 8, 15, 54 }, + 1993, 12, 8, 15, 54 }, // Tests for the wu-ftpd variant: { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", @@ -65,7 +66,7 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { 2006, 3, 1, 0, 0 }, { "dr--r--r-- 1 ftp ----- 0 Nov 17 17:08 kernels", net::FtpDirectoryListingEntry::DIRECTORY, "kernels", -1, - now_exploded.year, 11, 17, 17, 8 }, + 1993, 11, 17, 17, 8 }, // Tests for "ls -l" style listing sent by Xplain FTP Server. { "drwxr-xr-x folder 0 Jul 17 2006 online", @@ -75,12 +76,16 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) { for (size_t i = 0; i < arraysize(good_cases); i++) { SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); - net::FtpDirectoryListingParserLs parser; + net::FtpDirectoryListingParserLs parser(mock_current_time); RunSingleLineTestCase(&parser, good_cases[i]); } } TEST_F(FtpDirectoryListingParserLsTest, Bad) { + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); + const char* bad_cases[] = { "garbage", "-rw-r--r-- ftp ftp", @@ -107,7 +112,7 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) { "drwxr-xr-x folder 0 May 15 18:11", }; for (size_t i = 0; i < arraysize(bad_cases); i++) { - net::FtpDirectoryListingParserLs parser; + net::FtpDirectoryListingParserLs parser(mock_current_time); EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; } } diff --git a/net/ftp/ftp_directory_listing_parser_netware.cc b/net/ftp/ftp_directory_listing_parser_netware.cc index 20d2b25..60c6c6a 100644 --- a/net/ftp/ftp_directory_listing_parser_netware.cc +++ b/net/ftp/ftp_directory_listing_parser_netware.cc @@ -31,8 +31,10 @@ bool LooksLikeNetwarePermissionsListing(const string16& text) { namespace net { -FtpDirectoryListingParserNetware::FtpDirectoryListingParserNetware() - : received_first_line_(false) { +FtpDirectoryListingParserNetware::FtpDirectoryListingParserNetware( + const base::Time& current_time) + : received_first_line_(false), + current_time_(current_time) { } bool FtpDirectoryListingParserNetware::ConsumeLine(const string16& line) { @@ -75,7 +77,7 @@ bool FtpDirectoryListingParserNetware::ConsumeLine(const string16& line) { // Netware uses the same date listing format as Unix "ls -l". if (!FtpUtil::LsDateListingToTime(columns[4], columns[5], columns[6], - &entry.last_modified)) { + current_time_, &entry.last_modified)) { return false; } diff --git a/net/ftp/ftp_directory_listing_parser_netware.h b/net/ftp/ftp_directory_listing_parser_netware.h index a3b2cef..aef490a 100644 --- a/net/ftp/ftp_directory_listing_parser_netware.h +++ b/net/ftp/ftp_directory_listing_parser_netware.h @@ -7,6 +7,7 @@ #include <queue> +#include "base/time.h" #include "net/ftp/ftp_directory_listing_parser.h" namespace net { @@ -14,7 +15,10 @@ namespace net { // Parser for Netware-style directory listing. class FtpDirectoryListingParserNetware : public FtpDirectoryListingParser { public: - FtpDirectoryListingParserNetware(); + // Constructor. When the current time is needed to guess the year on partial + // date strings, |current_time| will be used. This allows passing a specific + // date during testing. + explicit FtpDirectoryListingParserNetware(const base::Time& current_time); // FtpDirectoryListingParser methods: virtual FtpServerType GetServerType() const { return SERVER_NETWARE; } @@ -27,6 +31,9 @@ class FtpDirectoryListingParserNetware : public FtpDirectoryListingParser { // True after we have received the first line of input. bool received_first_line_; + // Store the current time. We need it to correctly parse received dates. + const base::Time current_time_; + std::queue<FtpDirectoryListingEntry> entries_; DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserNetware); diff --git a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc index 4417599..6570846 100644 --- a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc +++ b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc @@ -14,8 +14,9 @@ namespace { typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest; TEST_F(FtpDirectoryListingParserNetwareTest, Good) { - base::Time::Exploded now_exploded; - base::Time::Now().LocalExplode(&now_exploded); + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); const struct SingleLineTestData good_cases[] = { { "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub", @@ -23,12 +24,12 @@ TEST_F(FtpDirectoryListingParserNetwareTest, Good) { 2004, 1, 29, 0, 0 }, { "- [RW------] ftpadmin 123 Nov 11 18:25 afile", net::FtpDirectoryListingEntry::FILE, "afile", 123, - now_exploded.year, 11, 11, 18, 25 }, + 1994, 11, 11, 18, 25 }, }; for (size_t i = 0; i < arraysize(good_cases); i++) { SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); - net::FtpDirectoryListingParserNetware parser; + net::FtpDirectoryListingParserNetware parser(mock_current_time); // The parser requires a "total n" like before accepting regular input. ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); RunSingleLineTestCase(&parser, good_cases[i]); @@ -36,6 +37,10 @@ TEST_F(FtpDirectoryListingParserNetwareTest, Good) { } TEST_F(FtpDirectoryListingParserNetwareTest, Bad) { + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); + const char* bad_cases[] = { "garbage", "d [] ftpadmin 512 Jan 29 2004 pub", @@ -45,7 +50,7 @@ TEST_F(FtpDirectoryListingParserNetwareTest, Bad) { "l [RW------] ftpadmin 512 Jan 29 2004 pub", }; for (size_t i = 0; i < arraysize(bad_cases); i++) { - net::FtpDirectoryListingParserNetware parser; + net::FtpDirectoryListingParserNetware parser(mock_current_time); // The parser requires a "total n" like before accepting regular input. ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index 7fa25c3..ff9aaa9 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -147,7 +147,9 @@ bool FtpUtil::ThreeLetterMonthToNumber(const string16& text, int* number) { // static bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, - const string16& rest, base::Time* time) { + const string16& rest, + const base::Time& current_time, + base::Time* result) { base::Time::Exploded time_exploded = { 0 }; if (!ThreeLetterMonthToNumber(month, &time_exploded.month)) @@ -167,14 +169,23 @@ bool FtpUtil::LsDateListingToTime(const string16& month, const string16& day, if (!StringToInt(rest.substr(3, 2), &time_exploded.minute)) return false; - // Use current year. - base::Time::Exploded now_exploded; - base::Time::Now().LocalExplode(&now_exploded); - time_exploded.year = now_exploded.year; + // Guess the year. + base::Time::Exploded current_exploded; + current_time.LocalExplode(¤t_exploded); + + // If it's not possible for the parsed date to be in the current year, + // use the previous year. + if (time_exploded.month > current_exploded.month || + (time_exploded.month == current_exploded.month && + time_exploded.day_of_month > current_exploded.day_of_month)) { + time_exploded.year = current_exploded.year - 1; + } else { + time_exploded.year = current_exploded.year; + } } // We don't know the time zone of the listing, so just use local time. - *time = base::Time::FromLocalExploded(time_exploded); + *result = base::Time::FromLocalExploded(time_exploded); return true; } diff --git a/net/ftp/ftp_util.h b/net/ftp/ftp_util.h index 5643606..37a51c2 100644 --- a/net/ftp/ftp_util.h +++ b/net/ftp/ftp_util.h @@ -32,12 +32,13 @@ class FtpUtil { // Convert a "ls -l" date listing to time. The listing comes in three columns. // The first one contains month, the second one contains day of month. - // The first one is either a time (and then the current year is assumed), - // or is a year (and then we don't know the time). + // The first one is either a time (and then we guess the year based + // on |current_time|), or is a year (and then we don't know the time). static bool LsDateListingToTime(const string16& month, const string16& day, const string16& rest, - base::Time* time); + const base::Time& current_time, + base::Time* result); // Skip |columns| columns from |text| (whitespace-delimited), and return the // remaining part, without leading/trailing whitespace. diff --git a/net/ftp/ftp_util_unittest.cc b/net/ftp/ftp_util_unittest.cc index 834d86f..480c893 100644 --- a/net/ftp/ftp_util_unittest.cc +++ b/net/ftp/ftp_util_unittest.cc @@ -103,8 +103,9 @@ TEST(FtpUtilTest, VMSPathToUnix) { } TEST(FtpUtilTest, LsDateListingToTime) { - base::Time::Exploded now_exploded; - base::Time::Now().LocalExplode(&now_exploded); + base::Time mock_current_time; + ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", + &mock_current_time)); const struct { // Input. @@ -120,14 +121,22 @@ TEST(FtpUtilTest, LsDateListingToTime) { int expected_minute; } kTestCases[] = { { "Nov", "01", "2007", 2007, 11, 1, 0, 0 }, - { "Jul", "25", "13:37", now_exploded.year, 7, 25, 13, 37 }, + { "Jul", "25", "13:37", 1994, 7, 25, 13, 37 }, // Test date listings in German, we should support them for FTP servers // giving localized listings. { "M\xc3\xa4r", "13", "2009", 2009, 3, 13, 0, 0 }, - { "Mai", "1", "10:10", now_exploded.year, 5, 1, 10, 10 }, - { "Okt", "14", "21:18", now_exploded.year, 10, 14, 21, 18 }, + { "Mai", "1", "10:10", 1994, 5, 1, 10, 10 }, + { "Okt", "14", "21:18", 1994, 10, 14, 21, 18 }, { "Dez", "25", "2008", 2008, 12, 25, 0, 0 }, + + // Test current year detection. + { "Nov", "01", "12:00", 1994, 11, 1, 12, 0 }, + { "Nov", "15", "12:00", 1994, 11, 15, 12, 0 }, + { "Nov", "16", "12:00", 1993, 11, 16, 12, 0 }, + { "Jan", "01", "08:30", 1994, 1, 1, 8, 30 }, + { "Sep", "02", "09:00", 1994, 9, 2, 9, 0 }, + { "Dec", "06", "21:00", 1993, 12, 6, 21, 0 }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s %s %s", i, @@ -137,7 +146,7 @@ TEST(FtpUtilTest, LsDateListingToTime) { base::Time time; ASSERT_TRUE(net::FtpUtil::LsDateListingToTime( UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day), - UTF8ToUTF16(kTestCases[i].rest), &time)); + UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time)); base::Time::Exploded time_exploded; time.LocalExplode(&time_exploded); |