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

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

Issue 6718043: FTP: Multiple fixes for localized directory listings: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: polish Created 9 years, 8 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 | Annotate | Revision Log
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_directory_listing_parser_unittest.h" 5 #include "net/ftp/ftp_directory_listing_parser_unittest.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "net/ftp/ftp_directory_listing_parser_ls.h" 10 #include "net/ftp/ftp_directory_listing_parser_ls.h"
(...skipping 26 matching lines...) Expand all
37 2007, 4, 8, 0, 0 }, 37 2007, 4, 8, 0, 0 },
38 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming", 38 { "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming",
39 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, 39 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
40 1994, 7, 1, 2, 15 }, 40 1994, 7, 1, 2, 15 },
41 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf", 41 { "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf",
42 FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432, 42 FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
43 2009, 5, 18, 0, 0 }, 43 2009, 5, 18, 0, 0 },
44 { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming", 44 { "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming",
45 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1, 45 FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
46 1993, 12, 8, 15, 54 }, 46 1993, 12, 8, 15, 54 },
47 { "drwxrwxrwx 1 owner group 0 Sep 13 0:30 audio", 47 { "drwxrwxrwx 1 owner group 1024 Sep 13 0:30 audio",
gavinp 2011/03/30 17:14:23 What's going on with 0 length files?
Paweł Hajdan Jr. 2011/04/01 15:55:27 I've changed the 0 to 1024 because 0 could be conf
48 FtpDirectoryListingEntry::DIRECTORY, "audio", -1, 48 FtpDirectoryListingEntry::DIRECTORY, "audio", -1,
49 1994, 9, 13, 0, 30 }, 49 1994, 9, 13, 0, 30 },
50 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub", 50 { "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub",
51 FtpDirectoryListingEntry::SYMLINK, "pub", -1, 51 FtpDirectoryListingEntry::SYMLINK, "pub", -1,
52 2008, 9, 18, 0, 0 }, 52 2008, 9, 18, 0, 0 },
53 53
54 // Tests for the wu-ftpd variant: 54 // Tests for the wu-ftpd variant:
55 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub", 55 { "drwxr-xr-x 2 sys 512 Mar 27 2009 pub",
56 FtpDirectoryListingEntry::DIRECTORY, "pub", -1, 56 FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
57 2009, 3, 27, 0, 0 }, 57 2009, 3, 27, 0, 0 },
(...skipping 29 matching lines...) Expand all
87 // Tests for "ls -l" style listing with number of links 87 // Tests for "ls -l" style listing with number of links
88 // not separated from permission listing (http://crbug.com/70394). 88 // not separated from permission listing (http://crbug.com/70394).
89 { "drwxr-xr-x1732 266 111 90112 Jun 21 2001 .rda_2", 89 { "drwxr-xr-x1732 266 111 90112 Jun 21 2001 .rda_2",
90 FtpDirectoryListingEntry::DIRECTORY, ".rda_2", -1, 90 FtpDirectoryListingEntry::DIRECTORY, ".rda_2", -1,
91 2001, 6, 21, 0, 0 }, 91 2001, 6, 21, 0, 0 },
92 92
93 // Tests for "ls -l" style listing with group name containing spaces. 93 // Tests for "ls -l" style listing with group name containing spaces.
94 { "drwxrwxr-x 3 %%%% Domain Users 4096 Dec 9 2009 %%%%%", 94 { "drwxrwxr-x 3 %%%% Domain Users 4096 Dec 9 2009 %%%%%",
95 net::FtpDirectoryListingEntry::DIRECTORY, "%%%%%", -1, 95 net::FtpDirectoryListingEntry::DIRECTORY, "%%%%%", -1,
96 2009, 12, 9, 0, 0 }, 96 2009, 12, 9, 0, 0 },
97
98 // Tests for "ls -l" style listing in Russian locale (note the swapped
99 // parts order: the day of month is the first, before month).
100 { "-rwxrwxr-x 1 ftp ftp 123 23 \xd0\xbc\xd0\xb0\xd0\xb9 2011 test",
101 net::FtpDirectoryListingEntry::FILE, "test", 123,
102 2011, 5, 23, 0, 0 },
103 { "drwxrwxr-x 1 ftp ftp 4096 19 \xd0\xbe\xd0\xba\xd1\x82 2011 dir",
104 net::FtpDirectoryListingEntry::DIRECTORY, "dir", -1,
105 2011, 10, 19, 0, 0 },
97 }; 106 };
98 for (size_t i = 0; i < arraysize(good_cases); i++) { 107 for (size_t i = 0; i < arraysize(good_cases); i++) {
99 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 108 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
100 good_cases[i].input)); 109 good_cases[i].input));
101 110
102 std::vector<FtpDirectoryListingEntry> entries; 111 std::vector<FtpDirectoryListingEntry> entries;
103 EXPECT_TRUE(ParseFtpDirectoryListingLs( 112 EXPECT_TRUE(ParseFtpDirectoryListingLs(
104 GetSingleLineTestCase(good_cases[i].input), 113 GetSingleLineTestCase(good_cases[i].input),
105 GetMockCurrentTime(), 114 GetMockCurrentTime(),
106 &entries)); 115 &entries));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README", 152 "-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
144 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README", 153 "qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
145 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README", 154 "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
146 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README", 155 "-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
147 "-rw-r--r-- 1 ftp ftp", 156 "-rw-r--r-- 1 ftp ftp",
148 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README", 157 "-rw-r--rgb 1 ftp ftp 528 Nov 01 2007 README",
149 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README", 158 "-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
150 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README", 159 "qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
151 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README", 160 "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
152 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README", 161 "-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
153 "drwxrwxrwx 1 owner group 0 Sep 13 0:3 audio", 162 "drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio",
154 163
155 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub", 164 "-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub",
156 }; 165 };
157 for (size_t i = 0; i < arraysize(bad_cases); i++) { 166 for (size_t i = 0; i < arraysize(bad_cases); i++) {
158 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, 167 SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
159 bad_cases[i])); 168 bad_cases[i]));
160 169
161 std::vector<FtpDirectoryListingEntry> entries; 170 std::vector<FtpDirectoryListingEntry> entries;
162 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]), 171 EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]),
163 GetMockCurrentTime(), 172 GetMockCurrentTime(),
164 &entries)); 173 &entries));
165 } 174 }
166 } 175 }
167 176
168 } // namespace 177 } // namespace
169 178
170 } // namespace net 179 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698