| Index: chrome/browser/download/download_browsertest.cc
|
| diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
|
| index e5f6c5d888969ffbc25f2f7e5d9cb8310eedce8a..9e1ffb61e8b5d4abad42adfe2c3c42ffd95bd5c8 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"
|
| @@ -80,6 +81,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"
|
| @@ -407,6 +409,11 @@ class DownloadTest : public InProcessBrowserTest {
|
| DownloadTest() {}
|
|
|
| void SetUpOnMainThread() override {
|
| + base::FeatureList::ClearInstanceForTesting();
|
| + scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
|
| + feature_list->InitializeFromCommandLine(
|
| + features::kDownloadResumption.name, std::string());
|
| + base::FeatureList::SetInstance(std::move(feature_list));
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
|
| @@ -844,11 +851,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.
|
| @@ -1691,9 +1703,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));
|
| @@ -3018,8 +3032,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())));
|
| @@ -3043,8 +3055,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())));
|
| @@ -3067,8 +3077,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(
|
| @@ -3097,8 +3105,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())));
|
| @@ -3117,8 +3123,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())));
|
|
|