OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 if (info.download_info.show_download_item) | 766 if (info.download_info.show_download_item) |
767 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); | 767 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); |
768 } | 768 } |
769 | 769 |
770 void DownloadInsertFilesErrorCheckErrors(size_t count, | 770 void DownloadInsertFilesErrorCheckErrors(size_t count, |
771 FileErrorInjectInfo* info) { | 771 FileErrorInjectInfo* info) { |
772 DownloadFilesCheckErrorsSetup(); | 772 DownloadFilesCheckErrorsSetup(); |
773 | 773 |
774 // Set up file failures. | 774 // Set up file failures. |
775 scoped_refptr<content::TestFileErrorInjector> injector( | 775 scoped_refptr<content::TestFileErrorInjector> injector( |
776 content::TestFileErrorInjector::Create( | 776 content::TestFileErrorInjector::Create()); |
777 DownloadManagerForBrowser(browser()))); | |
778 | 777 |
779 for (size_t i = 0; i < count; ++i) { | 778 for (size_t i = 0; i < count; ++i) { |
780 // Set up the full URL, for download file tracking. | 779 // Set up the full URL, for download file tracking. |
781 std::string server_path = "files/downloads/"; | 780 std::string server_path = "files/downloads/"; |
782 server_path += info[i].download_info.url_name; | 781 server_path += info[i].download_info.url_name; |
783 GURL url = test_server()->GetURL(server_path); | 782 GURL url = test_server()->GetURL(server_path); |
784 info[i].error_info.url = url.spec(); | 783 info[i].error_info.url = url.spec(); |
785 | 784 |
786 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); | 785 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); |
787 } | 786 } |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2462 GetDownloads(browser(), &download_items); | 2461 GetDownloads(browser(), &download_items); |
2463 ASSERT_EQ(1u, download_items.size()); | 2462 ASSERT_EQ(1u, download_items.size()); |
2464 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2463 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
2465 download_items[0]->GetOriginalUrl()); | 2464 download_items[0]->GetOriginalUrl()); |
2466 | 2465 |
2467 // Check that the file contains the expected referrer. | 2466 // Check that the file contains the expected referrer. |
2468 FilePath file(download_items[0]->GetFullPath()); | 2467 FilePath file(download_items[0]->GetFullPath()); |
2469 std::string expected_contents = test_server()->GetURL("").spec(); | 2468 std::string expected_contents = test_server()->GetURL("").spec(); |
2470 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2469 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
2471 } | 2470 } |
OLD | NEW |