Chromium Code Reviews| Index: chrome/browser/download/download_browsertest.cc |
| diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc |
| index a85588646eac1bf7c81cd56087a61af2f7a6e5d6..4c9b49f01b0616eca739a073bb1b7c69966e5a74 100644 |
| --- a/chrome/browser/download/download_browsertest.cc |
| +++ b/chrome/browser/download/download_browsertest.cc |
| @@ -203,6 +203,14 @@ bool WasAutoOpened(DownloadItem* item) { |
| return item->GetAutoOpened(); |
| } |
| +// Called when a download starts. Marks the download as hidden. |
| +void SetHiddenDownloadCallback(scoped_refptr<DownloadManager> download_manager, |
| + content::DownloadId id, |
| + net::Error error) { |
| + DownloadItem* item = download_manager->GetDownload(id.local()); |
| + item->SetShouldShowInShelf(item, false); |
|
Randy Smith (Not in Mondays)
2012/10/09 19:36:06
How does this work? Or is it left over from a pre
sail
2012/10/09 19:46:13
Done.
argh, merge conflict. Fixed.
|
| +} |
| + |
| } // namespace |
| // While an object of this class exists, it will mock out download |
| @@ -2244,3 +2252,30 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, LoadURLExternallyReferrerPolicy) { |
| std::string expected_contents = test_server()->GetURL("").spec(); |
| ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) { |
| + FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
| + GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
| + |
| + scoped_refptr<DownloadManager> download_manager = |
| + DownloadManagerForBrowser(browser()); |
| + scoped_ptr<content::DownloadTestObserver> observer( |
| + new content::DownloadTestObserverTerminal( |
| + download_manager, |
| + 1, |
| + content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| + content::DownloadSaveInfo save_info; |
| + save_info.prompt_for_save_location = false; |
| + |
| + // Download and set IsHiddenDownload to true. |
| + WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| + scoped_ptr<DownloadUrlParameters> params( |
| + DownloadUrlParameters::FromWebContents(web_contents, url, save_info)); |
| + params->set_callback( |
| + base::Bind(&SetHiddenDownloadCallback, download_manager)); |
| + download_manager->DownloadUrl(params.Pass()); |
| + observer->WaitForFinished(); |
| + |
| + // Verify that download shelf is not shown. |
| + EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| +} |