OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/time.h" |
8 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
9 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 class NetUtilTest : public testing::Test { | 15 class NetUtilTest : public testing::Test { |
15 }; | 16 }; |
16 | 17 |
17 struct FileCase { | 18 struct FileCase { |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), filename); | 698 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), filename); |
698 } | 699 } |
699 } | 700 } |
700 | 701 |
701 // This is currently a windows specific function. | 702 // This is currently a windows specific function. |
702 #if defined(OS_WIN) | 703 #if defined(OS_WIN) |
703 namespace { | 704 namespace { |
704 | 705 |
705 struct GetDirectoryListingEntryCase { | 706 struct GetDirectoryListingEntryCase { |
706 const char* name; | 707 const char* name; |
707 DWORD file_attrib; | 708 bool is_dir; |
708 int64 filesize; | 709 int64 filesize; |
709 FILETIME* modified; | 710 base::Time time; |
710 const char* expected; | 711 const char* expected; |
711 }; | 712 }; |
712 | 713 |
713 } // namespace | 714 } // namespace |
714 TEST(NetUtilTest, GetDirectoryListingEntry) { | 715 TEST(NetUtilTest, GetDirectoryListingEntry) { |
715 const GetDirectoryListingEntryCase test_cases[] = { | 716 const GetDirectoryListingEntryCase test_cases[] = { |
716 {"Foo", | 717 {"Foo", |
717 0, | 718 false, |
718 10000, | 719 10000, |
719 NULL, | 720 base::Time(), |
720 "<script>addRow(\"Foo\",\"Foo\",0,\"9.8 kB\",\"\");</script>\n"}, | 721 "<script>addRow(\"Foo\",\"Foo\",0,\"9.8 kB\",\"\");</script>\n"}, |
721 {"quo\"tes", | 722 {"quo\"tes", |
722 0, | 723 false, |
723 10000, | 724 10000, |
724 NULL, | 725 base::Time(), |
725 "<script>addRow(\"quo\\\"tes\",\"quo%22tes\",0,\"9.8 kB\",\"\");</script>\n
"}, | 726 "<script>addRow(\"quo\\\"tes\",\"quo%22tes\",0,\"9.8 kB\",\"\");</script>\n
"}, |
726 }; | 727 }; |
727 | 728 |
728 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 729 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
729 const std::string results = net::GetDirectoryListingEntry( | 730 const std::string results = net::GetDirectoryListingEntry( |
730 test_cases[i].name, test_cases[i].file_attrib, | 731 test_cases[i].name, |
731 test_cases[i].filesize, test_cases[i].modified); | 732 test_cases[i].is_dir, |
| 733 test_cases[i].filesize, |
| 734 test_cases[i].time); |
732 EXPECT_EQ(test_cases[i].expected, results); | 735 EXPECT_EQ(test_cases[i].expected, results); |
733 } | 736 } |
734 } | 737 } |
735 #endif | 738 #endif |
OLD | NEW |