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 |