OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/ftp/ftp_directory_listing_buffer.h" | 5 #include "net/ftp/ftp_directory_listing_buffer.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/format_macros.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/ftp/ftp_directory_listing_parsers.h" | 13 #include "net/ftp/ftp_directory_listing_parsers.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 TEST(FtpDirectoryListingBufferTest, Parse) { | 18 TEST(FtpDirectoryListingBufferTest, Parse) { |
(...skipping 11 matching lines...) Expand all Loading... |
29 "dir-listing-vms-4", | 30 "dir-listing-vms-4", |
30 }; | 31 }; |
31 | 32 |
32 FilePath test_dir; | 33 FilePath test_dir; |
33 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); | 34 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir); |
34 test_dir = test_dir.AppendASCII("net"); | 35 test_dir = test_dir.AppendASCII("net"); |
35 test_dir = test_dir.AppendASCII("data"); | 36 test_dir = test_dir.AppendASCII("data"); |
36 test_dir = test_dir.AppendASCII("ftp"); | 37 test_dir = test_dir.AppendASCII("ftp"); |
37 | 38 |
38 for (size_t i = 0; i < arraysize(test_files); i++) { | 39 for (size_t i = 0; i < arraysize(test_files); i++) { |
39 SCOPED_TRACE(StringPrintf("Test[%d]: %s", i, test_files[i])); | 40 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, test_files[i])); |
40 | 41 |
41 net::FtpDirectoryListingBuffer buffer; | 42 net::FtpDirectoryListingBuffer buffer; |
42 | 43 |
43 std::string test_listing; | 44 std::string test_listing; |
44 EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]), | 45 EXPECT_TRUE(file_util::ReadFileToString(test_dir.AppendASCII(test_files[i]), |
45 &test_listing)); | 46 &test_listing)); |
46 | 47 |
47 EXPECT_EQ(net::OK, buffer.ConsumeData(test_listing.data(), | 48 EXPECT_EQ(net::OK, buffer.ConsumeData(test_listing.data(), |
48 test_listing.length())); | 49 test_listing.length())); |
49 EXPECT_EQ(net::OK, buffer.ProcessRemainingData()); | 50 EXPECT_EQ(net::OK, buffer.ProcessRemainingData()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 EXPECT_EQ(hour, time_exploded.hour); | 104 EXPECT_EQ(hour, time_exploded.hour); |
104 EXPECT_EQ(minute, time_exploded.minute); | 105 EXPECT_EQ(minute, time_exploded.minute); |
105 EXPECT_EQ(0, time_exploded.second); | 106 EXPECT_EQ(0, time_exploded.second); |
106 EXPECT_EQ(0, time_exploded.millisecond); | 107 EXPECT_EQ(0, time_exploded.millisecond); |
107 } | 108 } |
108 EXPECT_FALSE(buffer.EntryAvailable()); | 109 EXPECT_FALSE(buffer.EntryAvailable()); |
109 } | 110 } |
110 } | 111 } |
111 | 112 |
112 } // namespace | 113 } // namespace |
OLD | NEW |