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

Unified Diff: net/ftp/ftp_directory_listing_parser_ls_unittest.cc

Issue 6670085: FTP: Detect the character encoding only after the entire listing is received. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test coverage Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | net/ftp/ftp_directory_listing_parser_netware.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser_ls_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
index 88bbecd74860032c064a89dbd070a42547bfbb01..8a1fe956ce5116985179c83c2914f1bc7ff758d2 100644
--- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,91 +9,97 @@
#include "base/stringprintf.h"
#include "net/ftp/ftp_directory_listing_parser_ls.h"
+namespace net {
+
namespace {
-typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest;
+typedef FtpDirectoryListingParserTest FtpDirectoryListingParserLsTest;
TEST_F(FtpDirectoryListingParserLsTest, Good) {
const struct SingleLineTestData good_cases[] = {
{ "-rw-r--r-- 1 ftp ftp 528 Nov 01 2007 README",
- net::FtpDirectoryListingEntry::FILE, "README", 528,
+ FtpDirectoryListingEntry::FILE, "README", 528,
2007, 11, 1, 0, 0 },
{ "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 directory",
- net::FtpDirectoryListingEntry::DIRECTORY, "directory", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "directory", -1,
1994, 5, 15, 18, 11 },
{ "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
- net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
+ FtpDirectoryListingEntry::SYMLINK, "pub", -1,
2008, 9, 18, 0, 0 },
{ "lrwxrwxrwx 1 0 0 3 Oct 12 13:37 mirror -> pub",
- net::FtpDirectoryListingEntry::SYMLINK, "mirror", -1,
+ FtpDirectoryListingEntry::SYMLINK, "mirror", -1,
1994, 10, 12, 13, 37 },
{ "drwxrwsr-x 4 501 501 4096 Feb 20 2007 pub",
- net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
2007, 2, 20, 0, 0 },
{ "drwxr-xr-x 4 (?) (?) 4096 Apr 8 2007 jigdo",
- net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
2007, 4, 8, 0, 0 },
{ "drwx-wx-wt 2 root wheel 512 Jul 1 02:15 incoming",
- net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
1994, 7, 1, 2, 15 },
{ "-rw-r--r-- 1 2 3 3447432 May 18 2009 Foo - Manual.pdf",
- net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
+ FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
2009, 5, 18, 0, 0 },
{ "d-wx-wx-wt+ 4 ftp 989 512 Dec 8 15:54 incoming",
- net::FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "incoming", -1,
1993, 12, 8, 15, 54 },
{ "drwxrwxrwx 1 owner group 0 Sep 13 0:30 audio",
- net::FtpDirectoryListingEntry::DIRECTORY, "audio", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "audio", -1,
1994, 9, 13, 0, 30 },
{ "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub",
- net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
+ FtpDirectoryListingEntry::SYMLINK, "pub", -1,
2008, 9, 18, 0, 0 },
// Tests for the wu-ftpd variant:
{ "drwxr-xr-x 2 sys 512 Mar 27 2009 pub",
- net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
2009, 3, 27, 0, 0 },
{ "lrwxrwxrwx 0 0 26 Sep 18 2008 pub -> vol/1/.CLUSTER/var_ftp/pub",
- net::FtpDirectoryListingEntry::SYMLINK, "pub", -1,
+ FtpDirectoryListingEntry::SYMLINK, "pub", -1,
2008, 9, 18, 0, 0 },
{ "drwxr-xr-x (?) (?) 4096 Apr 8 2007 jigdo",
- net::FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "jigdo", -1,
2007, 4, 8, 0, 0 },
{ "-rw-r--r-- 2 3 3447432 May 18 2009 Foo - Manual.pdf",
- net::FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
+ FtpDirectoryListingEntry::FILE, "Foo - Manual.pdf", 3447432,
2009, 5, 18, 0, 0 },
// Tests for "ls -l" style listings sent by an OS/2 server (FtpServer):
{ "-r--r--r-- 1 ftp -A--- 13274 Mar 1 2006 UpTime.exe",
- net::FtpDirectoryListingEntry::FILE, "UpTime.exe", 13274,
+ FtpDirectoryListingEntry::FILE, "UpTime.exe", 13274,
2006, 3, 1, 0, 0 },
{ "dr--r--r-- 1 ftp ----- 0 Nov 17 17:08 kernels",
- net::FtpDirectoryListingEntry::DIRECTORY, "kernels", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "kernels", -1,
1993, 11, 17, 17, 8 },
// Tests for "ls -l" style listing sent by Xplain FTP Server.
{ "drwxr-xr-x folder 0 Jul 17 2006 online",
- net::FtpDirectoryListingEntry::DIRECTORY, "online", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "online", -1,
2006, 7, 17, 0, 0 },
// Tests for "ls -l" style listing with owning group name
// not separated from file size (http://crbug.com/58963).
{ "-rw-r--r-- 1 ftpadmin ftpadmin125435904 Apr 9 2008 .pureftpd-upload",
- net::FtpDirectoryListingEntry::FILE, ".pureftpd-upload", 0,
+ FtpDirectoryListingEntry::FILE, ".pureftpd-upload", 0,
2008, 4, 9, 0, 0 },
// Tests for "ls -l" style listing with number of links
// not separated from permission listing (http://crbug.com/70394).
{ "drwxr-xr-x1732 266 111 90112 Jun 21 2001 .rda_2",
- net::FtpDirectoryListingEntry::DIRECTORY, ".rda_2", -1,
+ FtpDirectoryListingEntry::DIRECTORY, ".rda_2", -1,
2001, 6, 21, 0, 0 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
good_cases[i].input));
- net::FtpDirectoryListingParserLs parser(GetMockCurrentTime());
- RunSingleLineTestCase(&parser, good_cases[i]);
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_TRUE(ParseFtpDirectoryListingLs(
+ GetSingleLineTestCase(good_cases[i].input),
+ GetMockCurrentTime(),
+ &entries));
+ VerifySingleLineTestCase(good_cases[i], entries);
}
}
@@ -114,11 +120,12 @@ TEST_F(FtpDirectoryListingParserLsTest, Ignored) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
ignored_cases[i]));
- net::FtpDirectoryListingParserLs parser(GetMockCurrentTime());
- EXPECT_TRUE(parser.ConsumeLine(UTF8ToUTF16(ignored_cases[i])));
- EXPECT_FALSE(parser.EntryAvailable());
- EXPECT_TRUE(parser.OnEndOfInput());
- EXPECT_FALSE(parser.EntryAvailable());
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_TRUE(ParseFtpDirectoryListingLs(
+ GetSingleLineTestCase(ignored_cases[i]),
+ GetMockCurrentTime(),
+ &entries));
+ EXPECT_EQ(0U, entries.size());
}
}
@@ -143,9 +150,16 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) {
"-qqqqqqqqq+ 2 sys 512 Mar 27 2009 pub",
};
for (size_t i = 0; i < arraysize(bad_cases); i++) {
- net::FtpDirectoryListingParserLs parser(GetMockCurrentTime());
- EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i];
+ SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
+ bad_cases[i]));
+
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_FALSE(ParseFtpDirectoryListingLs(GetSingleLineTestCase(bad_cases[i]),
+ GetMockCurrentTime(),
+ &entries));
}
}
} // namespace
+
+} // namespace net
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_ls.cc ('k') | net/ftp/ftp_directory_listing_parser_netware.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698