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

Side by Side Diff: net/ftp/ftp_util_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
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 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 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_util.h" 5 #include "net/ftp/ftp_util.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i, 168 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s %s", i,
169 kTestCases[i].month, kTestCases[i].day, 169 kTestCases[i].month, kTestCases[i].day,
170 kTestCases[i].rest)); 170 kTestCases[i].rest));
171 171
172 base::Time time; 172 base::Time time;
173 ASSERT_TRUE(FtpUtil::LsDateListingToTime( 173 ASSERT_TRUE(FtpUtil::LsDateListingToTime(
174 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day), 174 UTF8ToUTF16(kTestCases[i].month), UTF8ToUTF16(kTestCases[i].day),
175 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time)); 175 UTF8ToUTF16(kTestCases[i].rest), mock_current_time, &time));
176 176
177 base::Time::Exploded time_exploded; 177 base::Time::Exploded time_exploded;
178 time.LocalExplode(&time_exploded); 178 time.UTCExplode(&time_exploded);
179 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year); 179 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year);
180 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month); 180 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month);
181 EXPECT_EQ(kTestCases[i].expected_day_of_month, time_exploded.day_of_month); 181 EXPECT_EQ(kTestCases[i].expected_day_of_month, time_exploded.day_of_month);
182 EXPECT_EQ(kTestCases[i].expected_hour, time_exploded.hour); 182 EXPECT_EQ(kTestCases[i].expected_hour, time_exploded.hour);
183 EXPECT_EQ(kTestCases[i].expected_minute, time_exploded.minute); 183 EXPECT_EQ(kTestCases[i].expected_minute, time_exploded.minute);
184 EXPECT_EQ(0, time_exploded.second); 184 EXPECT_EQ(0, time_exploded.second);
185 EXPECT_EQ(0, time_exploded.millisecond); 185 EXPECT_EQ(0, time_exploded.millisecond);
186 } 186 }
187 } 187 }
188 188
(...skipping 19 matching lines...) Expand all
208 for (size_t i = 0; i < arraysize(kTestCases); i++) { 208 for (size_t i = 0; i < arraysize(kTestCases); i++) {
209 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s", i, 209 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s %s", i,
210 kTestCases[i].date, kTestCases[i].time)); 210 kTestCases[i].date, kTestCases[i].time));
211 211
212 base::Time time; 212 base::Time time;
213 ASSERT_TRUE(FtpUtil::WindowsDateListingToTime( 213 ASSERT_TRUE(FtpUtil::WindowsDateListingToTime(
214 UTF8ToUTF16(kTestCases[i].date), UTF8ToUTF16(kTestCases[i].time), 214 UTF8ToUTF16(kTestCases[i].date), UTF8ToUTF16(kTestCases[i].time),
215 &time)); 215 &time));
216 216
217 base::Time::Exploded time_exploded; 217 base::Time::Exploded time_exploded;
218 time.LocalExplode(&time_exploded); 218 time.UTCExplode(&time_exploded);
219 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year); 219 EXPECT_EQ(kTestCases[i].expected_year, time_exploded.year);
220 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month); 220 EXPECT_EQ(kTestCases[i].expected_month, time_exploded.month);
221 EXPECT_EQ(kTestCases[i].expected_day_of_month, time_exploded.day_of_month); 221 EXPECT_EQ(kTestCases[i].expected_day_of_month, time_exploded.day_of_month);
222 EXPECT_EQ(kTestCases[i].expected_hour, time_exploded.hour); 222 EXPECT_EQ(kTestCases[i].expected_hour, time_exploded.hour);
223 EXPECT_EQ(kTestCases[i].expected_minute, time_exploded.minute); 223 EXPECT_EQ(kTestCases[i].expected_minute, time_exploded.minute);
224 EXPECT_EQ(0, time_exploded.second); 224 EXPECT_EQ(0, time_exploded.second);
225 EXPECT_EQ(0, time_exploded.millisecond); 225 EXPECT_EQ(0, time_exploded.millisecond);
226 } 226 }
227 } 227 }
228 228
(...skipping 20 matching lines...) Expand all
249 249
250 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result), 250 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_result),
251 FtpUtil::GetStringPartAfterColumns( 251 FtpUtil::GetStringPartAfterColumns(
252 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column)); 252 ASCIIToUTF16(kTestCases[i].text), kTestCases[i].column));
253 } 253 }
254 } 254 }
255 255
256 } // namespace 256 } // namespace
257 257
258 } // namespace net 258 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698