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 "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 L"test.html"}, | 691 L"test.html"}, |
692 }; | 692 }; |
693 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 693 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
694 std::wstring filename = net::GetSuggestedFilename( | 694 std::wstring filename = net::GetSuggestedFilename( |
695 GURL(test_cases[i].url), test_cases[i].content_disp_header, | 695 GURL(test_cases[i].url), test_cases[i].content_disp_header, |
696 test_cases[i].default_filename); | 696 test_cases[i].default_filename); |
697 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), filename); | 697 EXPECT_EQ(std::wstring(test_cases[i].expected_filename), filename); |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
| 701 // This is currently a windows specific function. |
| 702 #if defined(OS_WIN) |
| 703 namespace { |
| 704 |
| 705 struct GetDirectoryListingEntryCase { |
| 706 const char* name; |
| 707 DWORD file_attrib; |
| 708 int64 filesize; |
| 709 FILETIME* modified; |
| 710 const char* expected; |
| 711 }; |
| 712 |
| 713 } // namespace |
| 714 TEST(NetUtilTest, GetDirectoryListingEntry) { |
| 715 const GetDirectoryListingEntryCase test_cases[] = { |
| 716 {"Foo", |
| 717 0, |
| 718 10000, |
| 719 NULL, |
| 720 "<script>addRow(\"Foo\",\"Foo\",0,\"9.8 kB\",\"\");</script>\n"}, |
| 721 {"quo\"tes", |
| 722 0, |
| 723 10000, |
| 724 NULL, |
| 725 "<script>addRow(\"quo\\\"tes\",\"quo%22tes\",0,\"9.8 kB\",\"\");</script>\n
"}, |
| 726 }; |
| 727 |
| 728 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 729 const std::string results = net::GetDirectoryListingEntry( |
| 730 test_cases[i].name, test_cases[i].file_attrib, |
| 731 test_cases[i].filesize, test_cases[i].modified); |
| 732 EXPECT_EQ(test_cases[i].expected, results); |
| 733 } |
| 734 } |
| 735 #endif |
OLD | NEW |