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

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: update histograms for SERVER_UNKNOWN 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
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 85%
rename from net/ftp/ftp_directory_listing_buffer_unittest.cc
rename to net/ftp/ftp_directory_listing_parser_unittest.cc
index 4c710087b6b7b9d0bb9696094f322b7363503801..541ffec81406ec046a020c82a1099ced86bd1f6b 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(
@@ -94,6 +95,8 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
lines.push_back(tokenizer.token());
ASSERT_EQ(0U, lines.size() % 8);
+ ASSERT_EQ(lines.size() / 8, entries.size());
eroman 2011/03/24 23:09:35 nit: these two asserts could be combined into one:
Paweł Hajdan Jr. 2011/03/26 09:47:50 Done.
+
for (size_t i = 0; i < lines.size() / 8; i++) {
std::string type(lines[8 * i]);
std::string name(lines[8 * i + 1]);
@@ -109,15 +112,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();
+ FtpDirectoryListingEntry entry = entries[i];
eroman 2011/03/24 23:09:35 nit: could make this |const FtpDirectoryListingEnt
Paweł Hajdan Jr. 2011/03/26 09:47:50 Done.
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 +135,9 @@ TEST(FtpDirectoryListingBufferTest, Parse) {
EXPECT_EQ(hour, time_exploded.hour);
EXPECT_EQ(minute, time_exploded.minute);
}
- EXPECT_FALSE(buffer.EntryAvailable());
}
}
} // namespace
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698