Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Unified Diff: chrome/browser/download/download_browsertest.cc

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/browser_context.cc » ('j') | content/browser/browser_context.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1a37f8e29e08b302360ade32d07cd2a38b7a29cb 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -782,7 +782,8 @@ class DownloadTest : public InProcessBrowserTest {
// Set up file failures.
scoped_refptr<content::TestFileErrorInjector> injector(
- content::TestFileErrorInjector::Create());
+ content::TestFileErrorInjector::Create(
+ DownloadManagerForBrowser(browser())));
for (size_t i = 0; i < count; ++i) {
// Set up the full URL, for download file tracking.
@@ -1519,8 +1520,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) {
}
// Test to make sure auto-open works.
-// Feel free to re-disable this test if it starts failing again, but please see
-// if the failure looks like http://crbug.com/118159 and use that bug if so.
IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) {
FilePath file(FILE_PATH_LITERAL("download-autoopen.txt"));
GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
@@ -1529,8 +1528,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) {
GetDownloadPrefs(browser())->EnableAutoOpenBasedOnExtension(file));
// Mock out external opening on all downloads until end of test.
- MockDownloadOpeningObserver observer(
- DownloadManagerForBrowser(browser()));
+ MockDownloadOpeningObserver observer(DownloadManagerForBrowser(browser()));
DownloadAndWait(browser(), url);
@@ -1539,7 +1537,12 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, AutoOpen) {
DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
EXPECT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState());
- EXPECT_TRUE(downloads[0]->GetOpened());
+
+ // Unfortunately, this will block forever, causing a timeout, if
+ // the download is never opened.
+ content::DownloadUpdatedObserver(
+ downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
+ EXPECT_TRUE(downloads[0]->GetOpened()); // Confirm it anyway.
// As long as we're here, confirmed everything else is good.
EXPECT_EQ(1, browser()->tab_count());
@@ -1641,7 +1644,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) {
DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
content::DownloadUpdatedObserver(
- downloads[0], base::Bind(WasAutoOpened)).WaitForEvent();
+ downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
// Check that the extension was installed.
@@ -1703,7 +1706,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) {
DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
ASSERT_EQ(1u, downloads.size());
content::DownloadUpdatedObserver(
- downloads[0], base::Bind(WasAutoOpened)).WaitForEvent();
+ downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
// Check that the extension was installed.
@@ -1770,7 +1773,13 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) {
target_file_full_path,
OriginFile(file)));
- // Temporary downloads won't be visible.
+ // Temporary are treated as auto-opened, and after that open won't be
+ // visible; wait for auto-open and confirm not visible.
+ std::vector<DownloadItem*> downloads;
+ DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
+ ASSERT_EQ(1u, downloads.size());
+ content::DownloadUpdatedObserver(
+ downloads[0], base::Bind(&WasAutoOpened)).WaitForEvent();
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
}
« no previous file with comments | « no previous file | content/browser/browser_context.cc » ('j') | content/browser/browser_context.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698