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" |
| 11 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "base/scoped_temp_dir.h" | |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/test/test_file_util.h" | 16 #include "base/test/test_file_util.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/app/chrome_command_ids.h" | 18 #include "chrome/app/chrome_command_ids.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/common/cancelable_request.h" | 20 #include "chrome/browser/common/cancelable_request.h" |
21 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 21 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
22 #include "chrome/browser/download/download_crx_util.h" | 22 #include "chrome/browser/download/download_crx_util.h" |
23 #include "chrome/browser/download/download_history.h" | 23 #include "chrome/browser/download/download_history.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 if (URLRequestSlowDownloadJob::NumberOutstandingRequests()) | 827 if (URLRequestSlowDownloadJob::NumberOutstandingRequests()) |
828 *result = false; | 828 *result = false; |
829 BrowserThread::PostTask( | 829 BrowserThread::PostTask( |
830 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); | 830 BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); |
831 } | 831 } |
832 | 832 |
833 // Location of the test data. | 833 // Location of the test data. |
834 FilePath test_dir_; | 834 FilePath test_dir_; |
835 | 835 |
836 // Location of the downloads directory for these tests | 836 // Location of the downloads directory for these tests |
837 ScopedTempDir downloads_directory_; | 837 base::ScopedTempDir downloads_directory_; |
838 | 838 |
839 scoped_ptr<DownloadTestFileChooserObserver> file_chooser_observer_; | 839 scoped_ptr<DownloadTestFileChooserObserver> file_chooser_observer_; |
840 }; | 840 }; |
841 | 841 |
842 // NOTES: | 842 // NOTES: |
843 // | 843 // |
844 // Files for these tests are found in DIR_TEST_DATA (currently | 844 // Files for these tests are found in DIR_TEST_DATA (currently |
845 // "chrome\test\data\", see chrome_paths.cc). | 845 // "chrome\test\data\", see chrome_paths.cc). |
846 // Mock responses have extension .mock-http-headers appended to the file name. | 846 // Mock responses have extension .mock-http-headers appended to the file name. |
847 | 847 |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); | 1739 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); |
1740 } | 1740 } |
1741 | 1741 |
1742 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { | 1742 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { |
1743 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1743 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1744 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1744 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1745 | 1745 |
1746 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 1746 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
1747 ASSERT_TRUE(web_contents); | 1747 ASSERT_TRUE(web_contents); |
1748 | 1748 |
1749 ScopedTempDir other_directory; | 1749 base::ScopedTempDir other_directory; |
1750 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); | 1750 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); |
1751 FilePath target_file_full_path | 1751 FilePath target_file_full_path |
1752 = other_directory.path().Append(file.BaseName()); | 1752 = other_directory.path().Append(file.BaseName()); |
1753 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1)); | 1753 content::DownloadTestObserver* observer(CreateWaiter(browser(), 1)); |
1754 scoped_ptr<DownloadUrlParameters> params( | 1754 scoped_ptr<DownloadUrlParameters> params( |
1755 DownloadUrlParameters::FromWebContents(web_contents, url)); | 1755 DownloadUrlParameters::FromWebContents(web_contents, url)); |
1756 params->set_file_path(target_file_full_path); | 1756 params->set_file_path(target_file_full_path); |
1757 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); | 1757 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); |
1758 observer->WaitForFinished(); | 1758 observer->WaitForFinished(); |
1759 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 1759 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2259 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 2259 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
2260 scoped_ptr<DownloadUrlParameters> params( | 2260 scoped_ptr<DownloadUrlParameters> params( |
2261 DownloadUrlParameters::FromWebContents(web_contents, url)); | 2261 DownloadUrlParameters::FromWebContents(web_contents, url)); |
2262 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); | 2262 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); |
2263 download_manager->DownloadUrl(params.Pass()); | 2263 download_manager->DownloadUrl(params.Pass()); |
2264 observer->WaitForFinished(); | 2264 observer->WaitForFinished(); |
2265 | 2265 |
2266 // Verify that download shelf is not shown. | 2266 // Verify that download shelf is not shown. |
2267 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2267 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2268 } | 2268 } |
OLD | NEW |