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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc

Issue 1538933002: Enable download resumption by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Disable everything on windows only. http://crbug.com/306144 5 // Disable everything on windows only. http://crbug.com/306144
6 #ifndef OS_WIN 6 #ifndef OS_WIN
7 7
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "chrome/test/base/in_process_browser_test.h" 31 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
33 #include "content/public/browser/browser_context.h" 33 #include "content/public/browser/browser_context.h"
34 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/download_item.h" 35 #include "content/public/browser/download_item.h"
36 #include "content/public/browser/download_manager.h" 36 #include "content/public/browser/download_manager.h"
37 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/storage_partition.h" 38 #include "content/public/browser/storage_partition.h"
39 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
40 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_features.h"
41 #include "content/public/test/download_test_observer.h" 41 #include "content/public/test/download_test_observer.h"
42 #include "extensions/browser/event_router.h" 42 #include "extensions/browser/event_router.h"
43 #include "extensions/browser/notification_types.h" 43 #include "extensions/browser/notification_types.h"
44 #include "net/base/data_url.h" 44 #include "net/base/data_url.h"
45 #include "net/base/net_util.h" 45 #include "net/base/net_util.h"
46 #include "net/test/embedded_test_server/embedded_test_server.h" 46 #include "net/test/embedded_test_server/embedded_test_server.h"
47 #include "net/test/url_request/url_request_slow_download_job.h" 47 #include "net/test/url_request/url_request_slow_download_job.h"
48 #include "net/url_request/url_request.h" 48 #include "net/url_request/url_request.h"
49 #include "net/url_request/url_request_context.h" 49 #include "net/url_request/url_request_context.h"
50 #include "net/url_request/url_request_job.h" 50 #include "net/url_request/url_request_job.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 void RemoveFilenameDeterminer(content::RenderProcessHost* host) { 303 void RemoveFilenameDeterminer(content::RenderProcessHost* host) {
304 EventRouter::Get(current_browser()->profile())->RemoveEventListener( 304 EventRouter::Get(current_browser()->profile())->RemoveEventListener(
305 downloads::OnDeterminingFilename::kEventName, host, GetExtensionId()); 305 downloads::OnDeterminingFilename::kEventName, host, GetExtensionId());
306 } 306 }
307 307
308 Browser* current_browser() { return current_browser_; } 308 Browser* current_browser() { return current_browser_; }
309 309
310 // InProcessBrowserTest 310 // InProcessBrowserTest
311 void SetUpOnMainThread() override { 311 void SetUpOnMainThread() override {
312 base::FeatureList::ClearInstanceForTesting();
313 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
314 feature_list->InitializeFromCommandLine(
315 content::kDownloadResumptionFeature.name, std::string());
316 base::FeatureList::SetInstance(std::move(feature_list));
asanka 2015/12/18 19:25:35 +asvitkine: ^^^
317
312 ExtensionApiTest::SetUpOnMainThread(); 318 ExtensionApiTest::SetUpOnMainThread();
313 BrowserThread::PostTask( 319 BrowserThread::PostTask(
314 BrowserThread::IO, FROM_HERE, 320 BrowserThread::IO, FROM_HERE,
315 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); 321 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
316 InProcessBrowserTest::SetUpOnMainThread(); 322 InProcessBrowserTest::SetUpOnMainThread();
317 GoOnTheRecord(); 323 GoOnTheRecord();
318 CreateAndSetDownloadsDirectory(); 324 CreateAndSetDownloadsDirectory();
319 current_browser()->profile()->GetPrefs()->SetBoolean( 325 current_browser()->profile()->GetPrefs()->SetBoolean(
320 prefs::kPromptForDownload, false); 326 prefs::kPromptForDownload, false);
321 GetOnRecordManager()->RemoveAllDownloads(); 327 GetOnRecordManager()->RemoveAllDownloads();
(...skipping 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after
3851 #else 3857 #else
3852 #define MAYBE_DownloadExtensionTest_OnDeterminingFilename_InterruptedResume \ 3858 #define MAYBE_DownloadExtensionTest_OnDeterminingFilename_InterruptedResume \
3853 DownloadExtensionTest_OnDeterminingFilename_InterruptedResume 3859 DownloadExtensionTest_OnDeterminingFilename_InterruptedResume
3854 #endif 3860 #endif
3855 3861
3856 // Test download interruption while extensions determining filename. Should not 3862 // Test download interruption while extensions determining filename. Should not
3857 // re-dispatch onDeterminingFilename. 3863 // re-dispatch onDeterminingFilename.
3858 IN_PROC_BROWSER_TEST_F( 3864 IN_PROC_BROWSER_TEST_F(
3859 DownloadExtensionTest, 3865 DownloadExtensionTest,
3860 MAYBE_DownloadExtensionTest_OnDeterminingFilename_InterruptedResume) { 3866 MAYBE_DownloadExtensionTest_OnDeterminingFilename_InterruptedResume) {
3861 base::CommandLine::ForCurrentProcess()->AppendSwitch(
3862 switches::kEnableDownloadResumption);
3863 LoadExtension("downloads_split"); 3867 LoadExtension("downloads_split");
3864 ASSERT_TRUE(StartEmbeddedTestServer()); 3868 ASSERT_TRUE(StartEmbeddedTestServer());
3865 GoOnTheRecord(); 3869 GoOnTheRecord();
3866 content::RenderProcessHost* host = AddFilenameDeterminer(); 3870 content::RenderProcessHost* host = AddFilenameDeterminer();
3867 3871
3868 // Start a download. 3872 // Start a download.
3869 DownloadItem* item = NULL; 3873 DownloadItem* item = NULL;
3870 { 3874 {
3871 DownloadManager* manager = GetCurrentManager(); 3875 DownloadManager* manager = GetCurrentManager();
3872 scoped_ptr<content::DownloadTestObserver> observer( 3876 scoped_ptr<content::DownloadTestObserver> observer(
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
4151 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); 4155 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
4152 EXPECT_FALSE(warnings.empty()); 4156 EXPECT_FALSE(warnings.empty());
4153 EXPECT_EQ(Warning::kDownloadFilenameConflict, 4157 EXPECT_EQ(Warning::kDownloadFilenameConflict,
4154 warnings.begin()->warning_type()); 4158 warnings.begin()->warning_type());
4155 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); 4159 EXPECT_EQ("incumbent", warnings.begin()->extension_id());
4156 } 4160 }
4157 4161
4158 } // namespace extensions 4162 } // namespace extensions
4159 4163
4160 #endif // http://crbug.com/306144 4164 #endif // http://crbug.com/306144
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698