| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_unittest.h" | 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "net/ftp/ftp_directory_listing_parser_netware.h" | 11 #include "net/ftp/ftp_directory_listing_parser_netware.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest; | 15 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest; |
| 15 | 16 |
| 16 TEST_F(FtpDirectoryListingParserNetwareTest, Good) { | 17 TEST_F(FtpDirectoryListingParserNetwareTest, Good) { |
| 17 base::Time mock_current_time; | 18 base::Time mock_current_time; |
| 18 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", | 19 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", |
| 19 &mock_current_time)); | 20 &mock_current_time)); |
| 20 | 21 |
| 21 const struct SingleLineTestData good_cases[] = { | 22 const struct SingleLineTestData good_cases[] = { |
| 22 { "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub", | 23 { "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub", |
| 23 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, | 24 net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1, |
| 24 2004, 1, 29, 0, 0 }, | 25 2004, 1, 29, 0, 0 }, |
| 25 { "- [RW------] ftpadmin 123 Nov 11 18:25 afile", | 26 { "- [RW------] ftpadmin 123 Nov 11 18:25 afile", |
| 26 net::FtpDirectoryListingEntry::FILE, "afile", 123, | 27 net::FtpDirectoryListingEntry::FILE, "afile", 123, |
| 27 1994, 11, 11, 18, 25 }, | 28 1994, 11, 11, 18, 25 }, |
| 28 }; | 29 }; |
| 29 for (size_t i = 0; i < arraysize(good_cases); i++) { | 30 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 30 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 31 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, |
| 32 good_cases[i].input)); |
| 31 | 33 |
| 32 net::FtpDirectoryListingParserNetware parser(mock_current_time); | 34 net::FtpDirectoryListingParserNetware parser(mock_current_time); |
| 33 // The parser requires a "total n" like before accepting regular input. | 35 // The parser requires a "total n" like before accepting regular input. |
| 34 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); | 36 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); |
| 35 RunSingleLineTestCase(&parser, good_cases[i]); | 37 RunSingleLineTestCase(&parser, good_cases[i]); |
| 36 } | 38 } |
| 37 } | 39 } |
| 38 | 40 |
| 39 TEST_F(FtpDirectoryListingParserNetwareTest, Bad) { | 41 TEST_F(FtpDirectoryListingParserNetwareTest, Bad) { |
| 40 base::Time mock_current_time; | 42 base::Time mock_current_time; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 51 }; | 53 }; |
| 52 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 54 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 53 net::FtpDirectoryListingParserNetware parser(mock_current_time); | 55 net::FtpDirectoryListingParserNetware parser(mock_current_time); |
| 54 // The parser requires a "total n" like before accepting regular input. | 56 // The parser requires a "total n" like before accepting regular input. |
| 55 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); | 57 ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1"))); |
| 56 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 58 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 | 61 |
| 60 } // namespace | 62 } // namespace |
| OLD | NEW |