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

Unified Diff: net/ftp/ftp_directory_listing_parser_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_unittest.h ('k') | net/ftp/ftp_directory_listing_parser_vms.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_unittest.cc
diff --git a/net/ftp/ftp_directory_listing_buffer_unittest.cc b/net/ftp/ftp_directory_listing_parser_unittest.cc
similarity index 84%
rename from net/ftp/ftp_directory_listing_buffer_unittest.cc
rename to net/ftp/ftp_directory_listing_parser_unittest.cc
index 4c710087b6b7b9d0bb9696094f322b7363503801..b8f0851b703fbf0739df8b6ad5810a08d170183d 100644
--- a/net/ftp/ftp_directory_listing_buffer_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_unittest.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2009 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.
-#include "net/ftp/ftp_directory_listing_buffer.h"
+#include "net/ftp/ftp_directory_listing_parser.h"
#include "base/file_util.h"
#include "base/format_macros.h"
@@ -15,6 +15,8 @@
#include "net/ftp/ftp_directory_listing_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace net {
+
namespace {
TEST(FtpDirectoryListingBufferTest, Parse) {
@@ -73,15 +75,14 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
for (size_t i = 0; i < arraysize(test_files); i++) {
SCOPED_TRACE(base::StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i]));
- net::FtpDirectoryListingBuffer buffer(mock_current_time);
-
std::string test_listing;
EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]),
&test_listing));
- EXPECT_EQ(net::OK, buffer.ConsumeData(test_listing.data(),
- test_listing.length()));
- EXPECT_EQ(net::OK, buffer.ProcessRemainingData());
+ std::vector<FtpDirectoryListingEntry> entries;
+ EXPECT_EQ(OK, ParseFtpDirectoryListing(test_listing,
+ mock_current_time,
+ &entries));
std::string expected_listing;
ASSERT_TRUE(file_util::ReadFileToString(
@@ -92,7 +93,8 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
StringTokenizer tokenizer(expected_listing, "\r\n");
while (tokenizer.GetNext())
lines.push_back(tokenizer.token());
- ASSERT_EQ(0U, lines.size() % 8);
+
+ ASSERT_EQ(8 * entries.size(), lines.size());
for (size_t i = 0; i < lines.size() / 8; i++) {
std::string type(lines[8 * i]);
@@ -109,15 +111,14 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
base::StringToInt(lines[8 * i + 6], &hour);
base::StringToInt(lines[8 * i + 7], &minute);
- ASSERT_TRUE(buffer.EntryAvailable());
- net::FtpDirectoryListingEntry entry = buffer.PopEntry();
+ const FtpDirectoryListingEntry& entry = entries[i];
if (type == "d") {
- EXPECT_EQ(net::FtpDirectoryListingEntry::DIRECTORY, entry.type);
+ EXPECT_EQ(FtpDirectoryListingEntry::DIRECTORY, entry.type);
} else if (type == "-") {
- EXPECT_EQ(net::FtpDirectoryListingEntry::FILE, entry.type);
+ EXPECT_EQ(FtpDirectoryListingEntry::FILE, entry.type);
} else if (type == "l") {
- EXPECT_EQ(net::FtpDirectoryListingEntry::SYMLINK, entry.type);
+ EXPECT_EQ(FtpDirectoryListingEntry::SYMLINK, entry.type);
} else {
ADD_FAILURE() << "invalid gold test data: " << type;
}
@@ -133,8 +134,9 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
EXPECT_EQ(hour, time_exploded.hour);
EXPECT_EQ(minute, time_exploded.minute);
}
- EXPECT_FALSE(buffer.EntryAvailable());
}
}
} // namespace
+
+} // namespace net
« no previous file with comments | « net/ftp/ftp_directory_listing_parser_unittest.h ('k') | net/ftp/ftp_directory_listing_parser_vms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698