Delete unused downloads page asset.
[chromium-blink-merge.git] / net / ftp / ftp_directory_listing_parser_unittest.h
blob22c2cf907402ba759bc43acd2411d6379de0b83b
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_
6 #define NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_
8 #include <vector>
10 #include "base/strings/utf_string_conversions.h"
11 #include "net/ftp/ftp_directory_listing_parser.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace net {
16 class FtpDirectoryListingParserTest : public testing::Test {
17 public:
18 struct SingleLineTestData {
19 const char* input;
20 FtpDirectoryListingEntry::Type type;
21 const char* filename;
22 int64 size;
23 int year;
24 int month;
25 int day_of_month;
26 int hour;
27 int minute;
30 protected:
31 FtpDirectoryListingParserTest() {}
33 std::vector<base::string16> GetSingleLineTestCase(const std::string& text) {
34 std::vector<base::string16> lines;
35 lines.push_back(base::UTF8ToUTF16(text));
36 return lines;
39 void VerifySingleLineTestCase(
40 const SingleLineTestData& test_case,
41 const std::vector<FtpDirectoryListingEntry>& entries) {
42 ASSERT_FALSE(entries.empty());
44 FtpDirectoryListingEntry entry = entries[0];
45 EXPECT_EQ(test_case.type, entry.type);
46 EXPECT_EQ(base::UTF8ToUTF16(test_case.filename), entry.name);
47 EXPECT_EQ(test_case.size, entry.size);
49 base::Time::Exploded time_exploded;
50 entry.last_modified.LocalExplode(&time_exploded);
52 // Only test members displayed on the directory listing.
53 EXPECT_EQ(test_case.year, time_exploded.year);
54 EXPECT_EQ(test_case.month, time_exploded.month);
55 EXPECT_EQ(test_case.day_of_month, time_exploded.day_of_month);
56 EXPECT_EQ(test_case.hour, time_exploded.hour);
57 EXPECT_EQ(test_case.minute, time_exploded.minute);
59 EXPECT_EQ(1U, entries.size());
62 base::Time GetMockCurrentTime() {
63 base::Time::Exploded mock_current_time_exploded = { 0 };
64 mock_current_time_exploded.year = 1994;
65 mock_current_time_exploded.month = 11;
66 mock_current_time_exploded.day_of_month = 15;
67 mock_current_time_exploded.hour = 12;
68 mock_current_time_exploded.minute = 45;
69 return base::Time::FromLocalExploded(mock_current_time_exploded);
73 } // namespace net
75 #endif // NET_FTP_FTP_DIRECTORY_LISTING_PARSER_UNITTEST_H_