| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ | 5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ |
| 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ | 6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "net/ftp/ftp_directory_listing_parser.h" | 10 #include "net/ftp/ftp_directory_listing_parser.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class FtpDirectoryListingParserTest : public testing::Test { | 15 class FtpDirectoryListingParserTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 struct SingleLineTestData { | 17 struct SingleLineTestData { |
| 18 const char* input; | 18 const char* input; |
| 19 FtpDirectoryListingEntry::Type type; | 19 FtpDirectoryListingEntry::Type type; |
| 20 const char* filename; | 20 const char* filename; |
| 21 int64 size; | 21 int64 size; |
| 22 int year; | 22 int year; |
| 23 int month; | 23 int month; |
| 24 int day_of_month; | 24 int day_of_month; |
| 25 int hour; | 25 int hour; |
| 26 int minute; | 26 int minute; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 FtpDirectoryListingParserTest() { | 30 FtpDirectoryListingParserTest() {} |
| 31 } | |
| 32 | 31 |
| 33 void RunSingleLineTestCase(FtpDirectoryListingParser* parser, | 32 void RunSingleLineTestCase(FtpDirectoryListingParser* parser, |
| 34 const SingleLineTestData& test_case) { | 33 const SingleLineTestData& test_case) { |
| 35 ASSERT_TRUE(parser->ConsumeLine(UTF8ToUTF16(test_case.input))); | 34 ASSERT_TRUE(parser->ConsumeLine(UTF8ToUTF16(test_case.input))); |
| 36 ASSERT_TRUE(parser->EntryAvailable()); | 35 ASSERT_TRUE(parser->EntryAvailable()); |
| 37 FtpDirectoryListingEntry entry = parser->PopEntry(); | 36 FtpDirectoryListingEntry entry = parser->PopEntry(); |
| 38 EXPECT_EQ(test_case.type, entry.type); | 37 EXPECT_EQ(test_case.type, entry.type); |
| 39 EXPECT_EQ(UTF8ToUTF16(test_case.filename), entry.name); | 38 EXPECT_EQ(UTF8ToUTF16(test_case.filename), entry.name); |
| 40 EXPECT_EQ(test_case.size, entry.size); | 39 EXPECT_EQ(test_case.size, entry.size); |
| 41 | 40 |
| 42 base::Time::Exploded time_exploded; | 41 base::Time::Exploded time_exploded; |
| 43 entry.last_modified.LocalExplode(&time_exploded); | 42 entry.last_modified.LocalExplode(&time_exploded); |
| 44 EXPECT_EQ(test_case.year, time_exploded.year); | 43 EXPECT_EQ(test_case.year, time_exploded.year); |
| 45 EXPECT_EQ(test_case.month, time_exploded.month); | 44 EXPECT_EQ(test_case.month, time_exploded.month); |
| 46 EXPECT_EQ(test_case.day_of_month, time_exploded.day_of_month); | 45 EXPECT_EQ(test_case.day_of_month, time_exploded.day_of_month); |
| 47 EXPECT_EQ(test_case.hour, time_exploded.hour); | 46 EXPECT_EQ(test_case.hour, time_exploded.hour); |
| 48 EXPECT_EQ(test_case.minute, time_exploded.minute); | 47 EXPECT_EQ(test_case.minute, time_exploded.minute); |
| 49 EXPECT_EQ(0, time_exploded.second); | 48 EXPECT_EQ(0, time_exploded.second); |
| 50 EXPECT_EQ(0, time_exploded.millisecond); | 49 EXPECT_EQ(0, time_exploded.millisecond); |
| 51 } | 50 } |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserTest); | 53 DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingParserTest); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 } // namespace net | 56 } // namespace net |
| 58 | 57 |
| 59 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ | 58 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_ |
| 60 | 59 |
| OLD | NEW |