OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/net_util.h" | 5 #include "net/base/directory_listing.h" |
6 | |
7 #include <stdint.h> | |
8 | |
9 #include <string> | |
10 | 6 |
11 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 8 #include "base/time/time.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "url/gurl.h" | |
15 | 10 |
16 namespace net { | 11 namespace net { |
17 | 12 |
18 namespace { | 13 namespace { |
19 | 14 |
20 struct GetDirectoryListingEntryCase { | 15 struct GetDirectoryListingEntryCase { |
21 const wchar_t* name; | 16 const wchar_t* name; |
22 const char* const raw_bytes; | 17 const char* const raw_bytes; |
23 bool is_dir; | 18 bool is_dir; |
24 int64_t filesize; | 19 int64_t filesize; |
25 base::Time time; | 20 base::Time time; |
26 const char* const expected; | 21 const char* const expected; |
27 }; | 22 }; |
28 | 23 |
29 TEST(NetUtilTest, GetDirectoryListingEntry) { | 24 TEST(DirectoryListingTest, GetDirectoryListingEntry) { |
30 const GetDirectoryListingEntryCase test_cases[] = { | 25 const GetDirectoryListingEntryCase test_cases[] = { |
31 {L"Foo", | 26 {L"Foo", |
32 "", | 27 "", |
33 false, | 28 false, |
34 10000, | 29 10000, |
35 base::Time(), | 30 base::Time(), |
36 "<script>addRow(\"Foo\",\"Foo\",0,\"9.8 kB\",\"\");</script>\n"}, | 31 "<script>addRow(\"Foo\",\"Foo\",0,\"9.8 kB\",\"\");</script>\n"}, |
37 {L"quo\"tes", | 32 {L"quo\"tes", |
38 "", | 33 "", |
39 false, | 34 false, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 const std::string results = GetDirectoryListingEntry( | 67 const std::string results = GetDirectoryListingEntry( |
73 base::WideToUTF16(test_cases[i].name), test_cases[i].raw_bytes, | 68 base::WideToUTF16(test_cases[i].name), test_cases[i].raw_bytes, |
74 test_cases[i].is_dir, test_cases[i].filesize, test_cases[i].time); | 69 test_cases[i].is_dir, test_cases[i].filesize, test_cases[i].time); |
75 EXPECT_EQ(test_cases[i].expected, results); | 70 EXPECT_EQ(test_cases[i].expected, results); |
76 } | 71 } |
77 } | 72 } |
78 | 73 |
79 } // namespace | 74 } // namespace |
80 | 75 |
81 } // namespace net | 76 } // namespace net |
OLD | NEW |