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 24edca1a73baa5f8c1973c67e847c1b2202eb0eb..b8fa4b3aab40ee8cb76b32458a80803966fee634 100644 |
| --- a/chrome/browser/download/download_browsertest.cc |
| +++ b/chrome/browser/download/download_browsertest.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| +#include "base/feature_list.h" |
| #include "base/files/file.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| @@ -82,6 +83,7 @@ |
| #include "content/public/browser/render_widget_host.h" |
| #include "content/public/browser/resource_context.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "content/public/common/content_features.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/context_menu_params.h" |
| #include "content/public/test/browser_test_utils.h" |
| @@ -450,6 +452,11 @@ class DownloadTest : public InProcessBrowserTest { |
| DownloadTest() {} |
| void SetUpOnMainThread() override { |
| + base::FeatureList::ClearInstanceForTesting(); |
| + scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| + feature_list->InitializeFromCommandLine( |
| + content::kDownloadResumptionFeature.name, std::string()); |
| + base::FeatureList::SetInstance(std::move(feature_list)); |
|
asanka
2015/12/18 19:25:35
+asvitkine: ^^^
|
| BrowserThread::PostTask( |
| BrowserThread::IO, FROM_HERE, |
| base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| @@ -887,11 +894,16 @@ class DownloadTest : public InProcessBrowserTest { |
| browser()->tab_strip_model()->GetActiveWebContents(); |
| ASSERT_TRUE(web_contents); |
| - scoped_ptr<content::DownloadTestObserver> observer( |
| - new content::DownloadTestObserverTerminal( |
| - download_manager, |
| - 1, |
| - content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| + scoped_ptr<content::DownloadTestObserver> observer; |
| + if (download_info.reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) { |
| + observer.reset(new content::DownloadTestObserverTerminal( |
| + download_manager, 1, |
| + content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| + } else { |
| + observer.reset(new content::DownloadTestObserverInterrupted( |
| + download_manager, 1, |
| + content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| + } |
| if (download_info.download_method == DOWNLOAD_DIRECT) { |
| // Go directly to download. Don't wait for navigation. |
| @@ -1742,9 +1754,11 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { |
| // at this point as our queries will be behind the history updates |
| // invoked by completion. |
| scoped_ptr<content::DownloadTestObserver> download_observer( |
| - CreateWaiter(browser(), 1)); |
| - ui_test_utils::NavigateToURL(browser(), |
| - GURL(net::URLRequestSlowDownloadJob::kErrorDownloadUrl)); |
| + new content::DownloadTestObserverInterrupted( |
| + DownloadManagerForBrowser(browser()), 1, |
| + content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| + ui_test_utils::NavigateToURL( |
| + browser(), GURL(net::URLRequestSlowDownloadJob::kErrorDownloadUrl)); |
| download_observer->WaitForFinished(); |
| EXPECT_EQ(1u, download_observer->NumDownloadsSeenInState( |
| DownloadItem::INTERRUPTED)); |
| @@ -3074,8 +3088,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadTest_PercentComplete) { |
| // A download that is interrupted due to a file error should be able to be |
| // resumed. |
| IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_NoPrompt) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableDownloadResumption); |
| scoped_refptr<content::TestFileErrorInjector> error_injector( |
| content::TestFileErrorInjector::Create( |
| DownloadManagerForBrowser(browser()))); |
| @@ -3099,8 +3111,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_NoPrompt) { |
| // path is invalid or unusable should cause a prompt to be displayed on |
| // resumption. |
| IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPrompt) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableDownloadResumption); |
| scoped_refptr<content::TestFileErrorInjector> error_injector( |
| content::TestFileErrorInjector::Create( |
| DownloadManagerForBrowser(browser()))); |
| @@ -3123,8 +3133,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPrompt) { |
| // The user shouldn't be prompted on a resumed download unless a prompt is |
| // necessary due to the interrupt reason. |
| IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPromptAlways) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableDownloadResumption); |
| browser()->profile()->GetPrefs()->SetBoolean( |
| prefs::kPromptForDownload, true); |
| scoped_refptr<content::TestFileErrorInjector> error_injector( |
| @@ -3153,8 +3161,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPromptAlways) { |
| // A download that is interrupted due to a transient error should be resumed |
| // automatically. |
| IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_Automatic) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableDownloadResumption); |
| scoped_refptr<content::TestFileErrorInjector> error_injector( |
| content::TestFileErrorInjector::Create( |
| DownloadManagerForBrowser(browser()))); |
| @@ -3173,8 +3179,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_Automatic) { |
| // An interrupting download should be resumable multiple times. |
| IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_MultipleAttempts) { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - switches::kEnableDownloadResumption); |
| scoped_refptr<content::TestFileErrorInjector> error_injector( |
| content::TestFileErrorInjector::Create( |
| DownloadManagerForBrowser(browser()))); |