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 b0f7552aba9c35adfe668631faf31f8357f9d6be..02c7590c3e611d367e58984a1fc57d6e20b28abc 100644 |
| --- a/chrome/browser/download/download_browsertest.cc |
| +++ b/chrome/browser/download/download_browsertest.cc |
| @@ -201,6 +201,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->SetIsHiddenDownload(true); |
| +} |
| + |
| } // namespace |
| // While an object of this class exists, it will mock out download |
| @@ -2242,3 +2250,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 ShouldShowInDownloadsUI to false. |
|
asanka
2012/10/02 21:08:37
Nit: Comment out of date.
sail
2012/10/02 21:48:26
Done.
|
| + 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()); |
| +} |