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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 if (info.download_info.show_download_item) | 771 if (info.download_info.show_download_item) |
772 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); | 772 EXPECT_TRUE(injector->HadFile(GURL(info.error_info.url))) << s.str(); |
773 } | 773 } |
774 | 774 |
775 void DownloadInsertFilesErrorCheckErrors(size_t count, | 775 void DownloadInsertFilesErrorCheckErrors(size_t count, |
776 FileErrorInjectInfo* info) { | 776 FileErrorInjectInfo* info) { |
777 DownloadFilesCheckErrorsSetup(); | 777 DownloadFilesCheckErrorsSetup(); |
778 | 778 |
779 // Set up file failures. | 779 // Set up file failures. |
780 scoped_refptr<content::TestFileErrorInjector> injector( | 780 scoped_refptr<content::TestFileErrorInjector> injector( |
781 content::TestFileErrorInjector::Create( | 781 content::TestFileErrorInjector::Create()); |
782 DownloadManagerForBrowser(browser()))); | |
783 | 782 |
784 for (size_t i = 0; i < count; ++i) { | 783 for (size_t i = 0; i < count; ++i) { |
785 // Set up the full URL, for download file tracking. | 784 // Set up the full URL, for download file tracking. |
786 std::string server_path = "files/downloads/"; | 785 std::string server_path = "files/downloads/"; |
787 server_path += info[i].download_info.url_name; | 786 server_path += info[i].download_info.url_name; |
788 GURL url = test_server()->GetURL(server_path); | 787 GURL url = test_server()->GetURL(server_path); |
789 info[i].error_info.url = url.spec(); | 788 info[i].error_info.url = url.spec(); |
790 | 789 |
791 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); | 790 DownloadInsertFilesErrorCheckErrorsLoopBody(injector, info[i], i); |
792 } | 791 } |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2470 GetDownloads(browser(), &download_items); | 2469 GetDownloads(browser(), &download_items); |
2471 ASSERT_EQ(1u, download_items.size()); | 2470 ASSERT_EQ(1u, download_items.size()); |
2472 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), | 2471 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), |
2473 download_items[0]->GetOriginalUrl()); | 2472 download_items[0]->GetOriginalUrl()); |
2474 | 2473 |
2475 // Check that the file contains the expected referrer. | 2474 // Check that the file contains the expected referrer. |
2476 FilePath file(download_items[0]->GetFullPath()); | 2475 FilePath file(download_items[0]->GetFullPath()); |
2477 std::string expected_contents = test_server()->GetURL("").spec(); | 2476 std::string expected_contents = test_server()->GetURL("").spec(); |
2478 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); | 2477 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
2479 } | 2478 } |
OLD | NEW |