| 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 "net/ftp/ftp_directory_listing_parser_ls.h" | 10 #include "net/ftp/ftp_directory_listing_parser_ls.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest; | 14 typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest; |
| 14 | 15 |
| 15 TEST_F(FtpDirectoryListingParserLsTest, Good) { | 16 TEST_F(FtpDirectoryListingParserLsTest, Good) { |
| 16 base::Time mock_current_time; | 17 base::Time mock_current_time; |
| 17 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", | 18 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", |
| 18 &mock_current_time)); | 19 &mock_current_time)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 { "dr--r--r-- 1 ftp ----- 0 Nov 17 17:08 kernels", | 71 { "dr--r--r-- 1 ftp ----- 0 Nov 17 17:08 kernels", |
| 71 net::FtpDirectoryListingEntry::DIRECTORY, "kernels", -1, | 72 net::FtpDirectoryListingEntry::DIRECTORY, "kernels", -1, |
| 72 1993, 11, 17, 17, 8 }, | 73 1993, 11, 17, 17, 8 }, |
| 73 | 74 |
| 74 // Tests for "ls -l" style listing sent by Xplain FTP Server. | 75 // Tests for "ls -l" style listing sent by Xplain FTP Server. |
| 75 { "drwxr-xr-x folder 0 Jul 17 2006 online", | 76 { "drwxr-xr-x folder 0 Jul 17 2006 online", |
| 76 net::FtpDirectoryListingEntry::DIRECTORY, "online", -1, | 77 net::FtpDirectoryListingEntry::DIRECTORY, "online", -1, |
| 77 2006, 7, 17, 0, 0 }, | 78 2006, 7, 17, 0, 0 }, |
| 78 }; | 79 }; |
| 79 for (size_t i = 0; i < arraysize(good_cases); i++) { | 80 for (size_t i = 0; i < arraysize(good_cases); i++) { |
| 80 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, good_cases[i].input)); | 81 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, |
| 82 good_cases[i].input)); |
| 81 | 83 |
| 82 net::FtpDirectoryListingParserLs parser(mock_current_time); | 84 net::FtpDirectoryListingParserLs parser(mock_current_time); |
| 83 RunSingleLineTestCase(&parser, good_cases[i]); | 85 RunSingleLineTestCase(&parser, good_cases[i]); |
| 84 } | 86 } |
| 85 } | 87 } |
| 86 | 88 |
| 87 TEST_F(FtpDirectoryListingParserLsTest, Bad) { | 89 TEST_F(FtpDirectoryListingParserLsTest, Bad) { |
| 88 base::Time mock_current_time; | 90 base::Time mock_current_time; |
| 89 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", | 91 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", |
| 90 &mock_current_time)); | 92 &mock_current_time)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 115 "drwxr-xr-x 3 ftp 4096 May 15 18:11", | 117 "drwxr-xr-x 3 ftp 4096 May 15 18:11", |
| 116 "drwxr-xr-x folder 0 May 15 18:11", | 118 "drwxr-xr-x folder 0 May 15 18:11", |
| 117 }; | 119 }; |
| 118 for (size_t i = 0; i < arraysize(bad_cases); i++) { | 120 for (size_t i = 0; i < arraysize(bad_cases); i++) { |
| 119 net::FtpDirectoryListingParserLs parser(mock_current_time); | 121 net::FtpDirectoryListingParserLs parser(mock_current_time); |
| 120 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; | 122 EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i]; |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 } // namespace | 126 } // namespace |
| OLD | NEW |