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

Side by Side Diff: chrome/browser/ui/webui/settings/downloads_handler_unittest.cc

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: fixes Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "chrome/browser/ui/webui/settings/downloads_handler.h" 5 #include "chrome/browser/ui/webui/settings/downloads_handler.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "chrome/browser/download/chrome_download_manager_delegate.h" 8 #include "chrome/browser/download/chrome_download_manager_delegate.h"
8 #include "chrome/browser/download/download_prefs.h" 9 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
11 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
12 #include "content/public/browser/web_ui.h" 13 #include "content/public/browser/web_ui.h"
13 #include "content/public/test/mock_download_manager.h" 14 #include "content/public/test/mock_download_manager.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "content/public/test/test_web_ui.h" 16 #include "content/public/test/test_web_ui.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace settings { 19 namespace settings {
19 20
20 class DownloadsHandlerTest : public testing::Test { 21 class DownloadsHandlerTest : public testing::Test {
21 public: 22 public:
22 DownloadsHandlerTest() 23 DownloadsHandlerTest()
23 : download_manager_(new content::MockDownloadManager()), 24 : download_manager_(new content::MockDownloadManager()),
24 chrome_download_manager_delegate_(&profile_), 25 chrome_download_manager_delegate_(&profile_),
25 handler_(&profile_) { 26 handler_(&profile_) {
26 content::BrowserContext::SetDownloadManagerForTesting(&profile_, 27 content::BrowserContext::SetDownloadManagerForTesting(
27 download_manager_); 28 &profile_, base::WrapUnique(download_manager_));
Nico 2017/04/14 15:46:58 and here
Avi (use Gerrit) 2017/04/14 18:17:51 Done.
28 EXPECT_EQ(download_manager_, 29 EXPECT_EQ(download_manager_,
29 content::BrowserContext::GetDownloadManager(&profile_)); 30 content::BrowserContext::GetDownloadManager(&profile_));
30 31
31 EXPECT_CALL(*download_manager_, GetDelegate()) 32 EXPECT_CALL(*download_manager_, GetDelegate())
32 .WillRepeatedly(testing::Return(&chrome_download_manager_delegate_)); 33 .WillRepeatedly(testing::Return(&chrome_download_manager_delegate_));
33 EXPECT_CALL(*download_manager_, Shutdown()); 34 EXPECT_CALL(*download_manager_, Shutdown());
34 35
35 handler_.set_web_ui(&test_web_ui_); 36 handler_.set_web_ui(&test_web_ui_);
36 } 37 }
37 38
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 DownloadsHandler handler_; 81 DownloadsHandler handler_;
81 }; 82 };
82 83
83 TEST_F(DownloadsHandlerTest, AutoOpenDownloads) { 84 TEST_F(DownloadsHandlerTest, AutoOpenDownloads) {
84 // Touch the pref. 85 // Touch the pref.
85 profile()->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, ""); 86 profile()->GetPrefs()->SetString(prefs::kDownloadExtensionsToOpen, "");
86 VerifyAutoOpenDownloadsChangedCallback(); 87 VerifyAutoOpenDownloadsChangedCallback();
87 } 88 }
88 89
89 } // namespace settings 90 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698