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

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

Issue 2558143003: Use UTC rather than local time for interpreting FTP listing dates. (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "net/ftp/ftp_directory_listing_parser.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 test_dir = test_dir.AppendASCII("data"); 42 test_dir = test_dir.AppendASCII("data");
43 test_dir = test_dir.AppendASCII("ftp"); 43 test_dir = test_dir.AppendASCII("ftp");
44 44
45 base::Time::Exploded mock_current_time_exploded = { 0 }; 45 base::Time::Exploded mock_current_time_exploded = { 0 };
46 mock_current_time_exploded.year = 1994; 46 mock_current_time_exploded.year = 1994;
47 mock_current_time_exploded.month = 11; 47 mock_current_time_exploded.month = 11;
48 mock_current_time_exploded.day_of_month = 15; 48 mock_current_time_exploded.day_of_month = 15;
49 mock_current_time_exploded.hour = 12; 49 mock_current_time_exploded.hour = 12;
50 mock_current_time_exploded.minute = 45; 50 mock_current_time_exploded.minute = 45;
51 base::Time mock_current_time( 51 base::Time mock_current_time(
52 base::Time::FromLocalExploded(mock_current_time_exploded)); 52 base::Time::FromUTCExploded(mock_current_time_exploded));
53 53
54 SCOPED_TRACE(base::StringPrintf("Test case: %s", param.name)); 54 SCOPED_TRACE(base::StringPrintf("Test case: %s", param.name));
55 55
56 std::string test_listing; 56 std::string test_listing;
57 EXPECT_TRUE( 57 EXPECT_TRUE(
58 base::ReadFileToString(test_dir.AppendASCII(param.name), &test_listing)); 58 base::ReadFileToString(test_dir.AppendASCII(param.name), &test_listing));
59 59
60 std::vector<FtpDirectoryListingEntry> entries; 60 std::vector<FtpDirectoryListingEntry> entries;
61 EXPECT_EQ( 61 EXPECT_EQ(
62 param.expected_result, 62 param.expected_result,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } else if (type == "l") { 102 } else if (type == "l") {
103 EXPECT_EQ(FtpDirectoryListingEntry::SYMLINK, entry.type); 103 EXPECT_EQ(FtpDirectoryListingEntry::SYMLINK, entry.type);
104 } else { 104 } else {
105 ADD_FAILURE() << "invalid gold test data: " << type; 105 ADD_FAILURE() << "invalid gold test data: " << type;
106 } 106 }
107 107
108 EXPECT_EQ(base::UTF8ToUTF16(name), entry.name); 108 EXPECT_EQ(base::UTF8ToUTF16(name), entry.name);
109 EXPECT_EQ(size, entry.size); 109 EXPECT_EQ(size, entry.size);
110 110
111 base::Time::Exploded time_exploded; 111 base::Time::Exploded time_exploded;
112 entry.last_modified.LocalExplode(&time_exploded); 112 entry.last_modified.UTCExplode(&time_exploded);
113 EXPECT_EQ(year, time_exploded.year); 113 EXPECT_EQ(year, time_exploded.year);
114 EXPECT_EQ(month, time_exploded.month); 114 EXPECT_EQ(month, time_exploded.month);
115 EXPECT_EQ(day_of_month, time_exploded.day_of_month); 115 EXPECT_EQ(day_of_month, time_exploded.day_of_month);
116 EXPECT_EQ(hour, time_exploded.hour); 116 EXPECT_EQ(hour, time_exploded.hour);
117 EXPECT_EQ(minute, time_exploded.minute); 117 EXPECT_EQ(minute, time_exploded.minute);
118 } 118 }
119 } 119 }
120 120
121 const FtpTestParam kTestParams[] = { 121 const FtpTestParam kTestParams[] = {
122 {"dir-listing-ls-1", OK}, 122 {"dir-listing-ls-1", OK},
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 }; 175 };
176 176
177 INSTANTIATE_TEST_CASE_P(, 177 INSTANTIATE_TEST_CASE_P(,
178 FtpDirectoryListingParserTest, 178 FtpDirectoryListingParserTest,
179 testing::ValuesIn(kTestParams), 179 testing::ValuesIn(kTestParams),
180 TestName); 180 TestName);
181 181
182 } // namespace 182 } // namespace
183 183
184 } // namespace net 184 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_unittest.h ('k') | net/ftp/ftp_directory_listing_parser_vms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698