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

Unified Diff: net/ftp/ftp_directory_listing_parser_netware_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_netware.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.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_netware_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc b/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
index c02fb974a7c5e9c2be169d2eae3705632b8d4809..5f373ac828380706286be4f265ff542ae5b72338 100644
--- a/net/ftp/ftp_directory_listing_parser_netware_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_netware_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.
@@ -10,27 +10,35 @@
#include "base/utf_string_conversions.h"
#include "net/ftp/ftp_directory_listing_parser_netware.h"
+namespace net {
+
namespace {
-typedef net::FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest;
+typedef FtpDirectoryListingParserTest FtpDirectoryListingParserNetwareTest;
TEST_F(FtpDirectoryListingParserNetwareTest, Good) {
const struct SingleLineTestData good_cases[] = {
{ "d [RWCEAFMS] ftpadmin 512 Jan 29 2004 pub",
- net::FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
+ FtpDirectoryListingEntry::DIRECTORY, "pub", -1,
2004, 1, 29, 0, 0 },
{ "- [RW------] ftpadmin 123 Nov 11 18:25 afile",
- net::FtpDirectoryListingEntry::FILE, "afile", 123,
+ FtpDirectoryListingEntry::FILE, "afile", 123,
1994, 11, 11, 18, 25 },
};
for (size_t i = 0; i < arraysize(good_cases); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
good_cases[i].input));
- net::FtpDirectoryListingParserNetware parser(GetMockCurrentTime());
- // The parser requires a "total n" like before accepting regular input.
- ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1")));
- RunSingleLineTestCase(&parser, good_cases[i]);
+ std::vector<string16> lines(GetSingleLineTestCase(good_cases[i].input));
+
+ // The parser requires a "total n" line before accepting regular input.
+ lines.insert(lines.begin(), ASCIIToUTF16("total 1"));
+
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_TRUE(ParseFtpDirectoryListingNetware(lines,
+ GetMockCurrentTime(),
+ &entries));
+ VerifySingleLineTestCase(good_cases[i], entries);
}
}
@@ -45,11 +53,21 @@ TEST_F(FtpDirectoryListingParserNetwareTest, Bad) {
"l [RW------] ftpadmin 512 Jan 29 2004 pub",
};
for (size_t i = 0; i < arraysize(bad_cases); i++) {
- net::FtpDirectoryListingParserNetware parser(GetMockCurrentTime());
- // The parser requires a "total n" like before accepting regular input.
- ASSERT_TRUE(parser.ConsumeLine(UTF8ToUTF16("total 1")));
- EXPECT_FALSE(parser.ConsumeLine(UTF8ToUTF16(bad_cases[i]))) << bad_cases[i];
+ SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i,
+ bad_cases[i]));
+
+ std::vector<string16> lines(GetSingleLineTestCase(bad_cases[i]));
+
+ // The parser requires a "total n" line before accepting regular input.
+ lines.insert(lines.begin(), ASCIIToUTF16("total 1"));
+
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_FALSE(ParseFtpDirectoryListingNetware(lines,
+ GetMockCurrentTime(),
+ &entries));
}
}
} // namespace
+
+} // namespace net
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_netware.cc ('k') | net/ftp/ftp_directory_listing_parser_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698