Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / net / ftp / ftp_directory_listing_parser_windows_unittest.cc
blobd574fc9971a8a18cacdef5c5016f47d61ca49903
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 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
7 #include "base/format_macros.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h"
10 #include "net/ftp/ftp_directory_listing_parser_windows.h"
12 namespace net {
14 namespace {
16 typedef FtpDirectoryListingParserTest FtpDirectoryListingParserWindowsTest;
18 TEST_F(FtpDirectoryListingParserWindowsTest, Good) {
19 const struct SingleLineTestData good_cases[] = {
20 { "11-02-09 05:32PM <DIR> NT",
21 FtpDirectoryListingEntry::DIRECTORY, "NT", -1,
22 2009, 11, 2, 17, 32 },
23 { "01-06-09 02:42PM 458 Readme.txt",
24 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
25 2009, 1, 6, 14, 42 },
26 { "01-06-09 02:42AM 1 Readme.txt",
27 FtpDirectoryListingEntry::FILE, "Readme.txt", 1,
28 2009, 1, 6, 2, 42 },
29 { "01-06-01 02:42AM 458 Readme.txt",
30 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
31 2001, 1, 6, 2, 42 },
32 { "01-06-00 02:42AM 458 Corner1.txt",
33 FtpDirectoryListingEntry::FILE, "Corner1.txt", 458,
34 2000, 1, 6, 2, 42 },
35 { "01-06-99 02:42AM 458 Corner2.txt",
36 FtpDirectoryListingEntry::FILE, "Corner2.txt", 458,
37 1999, 1, 6, 2, 42 },
38 { "01-06-80 02:42AM 458 Corner3.txt",
39 FtpDirectoryListingEntry::FILE, "Corner3.txt", 458,
40 1980, 1, 6, 2, 42 },
41 #if !defined(OS_LINUX) && !defined(OS_ANDROID)
42 // TODO(phajdan.jr): https://crbug.com/28792: Re-enable when 2038-year
43 // problem is fixed on Linux.
44 { "01-06-79 02:42AM 458 Corner4",
45 FtpDirectoryListingEntry::FILE, "Corner4", 458,
46 2079, 1, 6, 2, 42 },
47 #endif // !defined (OS_LINUX) && !defined(OS_ANDROID)
48 { "01-06-1979 02:42AM 458 Readme.txt",
49 FtpDirectoryListingEntry::FILE, "Readme.txt", 458,
50 1979, 1, 6, 2, 42 },
51 { "11-02-09 05:32PM <DIR> My Directory",
52 FtpDirectoryListingEntry::DIRECTORY, "My Directory", -1,
53 2009, 11, 2, 17, 32 },
54 { "12-25-10 12:00AM <DIR> Christmas Midnight",
55 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midnight", -1,
56 2010, 12, 25, 0, 0 },
57 { "12-25-10 12:00PM <DIR> Christmas Midday",
58 FtpDirectoryListingEntry::DIRECTORY, "Christmas Midday", -1,
59 2010, 12, 25, 12, 0 },
61 for (size_t i = 0; i < arraysize(good_cases); i++) {
62 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
63 good_cases[i].input));
65 std::vector<FtpDirectoryListingEntry> entries;
66 EXPECT_TRUE(ParseFtpDirectoryListingWindows(
67 GetSingleLineTestCase(good_cases[i].input),
68 &entries));
69 VerifySingleLineTestCase(good_cases[i], entries);
73 TEST_F(FtpDirectoryListingParserWindowsTest, Ignored) {
74 const char* const ignored_cases[] = {
75 "12-07-10 12:05AM <DIR> ", // http://crbug.com/66097
76 "12-07-10 12:05AM 1234 ",
77 "11-02-09 05:32 <DIR>",
78 "11-02-09 05:32PM <DIR>",
80 for (size_t i = 0; i < arraysize(ignored_cases); i++) {
81 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
82 ignored_cases[i]));
84 std::vector<FtpDirectoryListingEntry> entries;
85 EXPECT_TRUE(ParseFtpDirectoryListingWindows(
86 GetSingleLineTestCase(ignored_cases[i]),
87 &entries));
88 EXPECT_EQ(0U, entries.size());
92 TEST_F(FtpDirectoryListingParserWindowsTest, Bad) {
93 const char* const bad_cases[] = {
94 "garbage",
95 "11-02-09 05:32PM <GARBAGE>",
96 "11-02-09 05:32PM <GARBAGE> NT",
97 "11-FEB-09 05:32PM <DIR>",
98 "11-02 05:32PM <DIR>",
99 "11-02-09 05:32PM -1",
100 "11-FEB-09 05:32PM <DIR> NT",
101 "11-02 05:32PM <DIR> NT",
102 "11-02-09 05:32PM -1 NT",
103 "99-25-10 12:00AM 0",
104 "12-99-10 12:00AM 0",
105 "12-25-10 99:00AM 0",
106 "12-25-10 12:99AM 0",
107 "12-25-10 12:00ZM 0",
108 "99-25-10 12:00AM 0 months out of range",
109 "12-99-10 12:00AM 0 days out of range",
110 "12-25-10 99:00AM 0 hours out of range",
111 "12-25-10 12:99AM 0 minutes out of range",
112 "12-25-10 12:00ZM 0 what does ZM mean",
114 for (size_t i = 0; i < arraysize(bad_cases); i++) {
115 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
116 bad_cases[i]));
118 std::vector<FtpDirectoryListingEntry> entries;
119 EXPECT_FALSE(ParseFtpDirectoryListingWindows(
120 GetSingleLineTestCase(bad_cases[i]),
121 &entries));
125 } // namespace
127 } // namespace net