Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: net/ftp/ftp_directory_listing_buffer_unittest.cc

Issue 3448029: FTP: fix directory listing parser for ftp.usa.hp.com (Closed)
Patch Set: attempt to fix Windows trybots Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser_hprc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_buffer.h" 5 #include "net/ftp/ftp_directory_listing_buffer.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_tokenizer.h" 11 #include "base/string_tokenizer.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/ftp/ftp_directory_listing_parser.h" 15 #include "net/ftp/ftp_directory_listing_parser.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace { 18 namespace {
19 19
20 TEST(FtpDirectoryListingBufferTest, Parse) { 20 TEST(FtpDirectoryListingBufferTest, Parse) {
21 const char* test_files[] = { 21 const char* test_files[] = {
22 "dir-listing-hprc-1",
23 "dir-listing-hprc-2",
24 "dir-listing-hprc-3",
22 "dir-listing-ls-1", 25 "dir-listing-ls-1",
23 "dir-listing-ls-1-utf8", 26 "dir-listing-ls-1-utf8",
24 "dir-listing-ls-2", 27 "dir-listing-ls-2",
25 "dir-listing-ls-3", 28 "dir-listing-ls-3",
26 "dir-listing-ls-4", 29 "dir-listing-ls-4",
27 "dir-listing-ls-5", 30 "dir-listing-ls-5",
28 "dir-listing-ls-6", 31 "dir-listing-ls-6",
29 "dir-listing-ls-7", 32 "dir-listing-ls-7",
30 "dir-listing-ls-8", 33 "dir-listing-ls-8",
31 "dir-listing-ls-9", 34 "dir-listing-ls-9",
(...skipping 17 matching lines...) Expand all
49 "dir-listing-windows-1", 52 "dir-listing-windows-1",
50 "dir-listing-windows-2", 53 "dir-listing-windows-2",
51 }; 54 };
52 55
53 FilePath test_dir; 56 FilePath test_dir;
54 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); 57 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir);
55 test_dir = test_dir.AppendASCII("net"); 58 test_dir = test_dir.AppendASCII("net");
56 test_dir = test_dir.AppendASCII("data"); 59 test_dir = test_dir.AppendASCII("data");
57 test_dir = test_dir.AppendASCII("ftp"); 60 test_dir = test_dir.AppendASCII("ftp");
58 61
59 base::Time mock_current_time; 62 base::Time::Exploded mock_current_time_exploded = { 0 };
60 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994 12:45:26 GMT", 63 mock_current_time_exploded.year = 1994;
61 &mock_current_time)); 64 mock_current_time_exploded.month = 11;
65 mock_current_time_exploded.day_of_month = 15;
66 mock_current_time_exploded.hour = 12;
67 mock_current_time_exploded.minute = 45;
68 base::Time mock_current_time(
69 base::Time::FromLocalExploded(mock_current_time_exploded));
62 70
63 for (size_t i = 0; i < arraysize(test_files); i++) { 71 for (size_t i = 0; i < arraysize(test_files); i++) {
64 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i])); 72 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i]));
65 73
66 net::FtpDirectoryListingBuffer buffer(mock_current_time); 74 net::FtpDirectoryListingBuffer buffer(mock_current_time);
67 75
68 std::string test_listing; 76 std::string test_listing;
69 EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]), 77 EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]),
70 &test_listing)); 78 &test_listing));
71 79
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 EXPECT_EQ(UTF8ToUTF16(name), entry.name); 123 EXPECT_EQ(UTF8ToUTF16(name), entry.name);
116 EXPECT_EQ(size, entry.size); 124 EXPECT_EQ(size, entry.size);
117 125
118 base::Time::Exploded time_exploded; 126 base::Time::Exploded time_exploded;
119 entry.last_modified.LocalExplode(&time_exploded); 127 entry.last_modified.LocalExplode(&time_exploded);
120 EXPECT_EQ(year, time_exploded.year); 128 EXPECT_EQ(year, time_exploded.year);
121 EXPECT_EQ(month, time_exploded.month); 129 EXPECT_EQ(month, time_exploded.month);
122 EXPECT_EQ(day_of_month, time_exploded.day_of_month); 130 EXPECT_EQ(day_of_month, time_exploded.day_of_month);
123 EXPECT_EQ(hour, time_exploded.hour); 131 EXPECT_EQ(hour, time_exploded.hour);
124 EXPECT_EQ(minute, time_exploded.minute); 132 EXPECT_EQ(minute, time_exploded.minute);
125 EXPECT_EQ(0, time_exploded.second);
126 EXPECT_EQ(0, time_exploded.millisecond);
127 } 133 }
128 EXPECT_FALSE(buffer.EntryAvailable()); 134 EXPECT_FALSE(buffer.EntryAvailable());
129 } 135 }
130 } 136 }
131 137
132 } // namespace 138 } // namespace
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer.cc ('k') | net/ftp/ftp_directory_listing_parser_hprc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698