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

Side by Side Diff: chrome/browser/profile_resetter/profile_resetter_unittest.cc

Issue 1165913002: [Cleanup] Used scoped pointers in KeyedServiceFactory's SetTestingFactory functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/profile_resetter/profile_resetter.h" 5 #include "chrome/browser/profile_resetter/profile_resetter.h"
6 6
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/scoped_path_override.h" 11 #include "base/test/scoped_path_override.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_service_test_base.h" 13 #include "chrome/browser/extensions/extension_service_test_base.h"
13 #include "chrome/browser/extensions/tab_helper.h" 14 #include "chrome/browser/extensions/tab_helper.h"
14 #include "chrome/browser/prefs/session_startup_pref.h" 15 #include "chrome/browser/prefs/session_startup_pref.h"
15 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" 16 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h"
16 #include "chrome/browser/profile_resetter/profile_resetter_test_base.h" 17 #include "chrome/browser/profile_resetter/profile_resetter_test_base.h"
17 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h" 18 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 public ProfileResetterTestBase { 101 public ProfileResetterTestBase {
101 public: 102 public:
102 ProfileResetterTest(); 103 ProfileResetterTest();
103 ~ProfileResetterTest() override; 104 ~ProfileResetterTest() override;
104 105
105 protected: 106 protected:
106 void SetUp() override; 107 void SetUp() override;
107 108
108 TestingProfile* profile() { return profile_.get(); } 109 TestingProfile* profile() { return profile_.get(); }
109 110
110 static KeyedService* CreateTemplateURLService( 111 static scoped_ptr<KeyedService> CreateTemplateURLService(
111 content::BrowserContext* context); 112 content::BrowserContext* context);
112 113
113 private: 114 private:
114 #if defined(OS_WIN) 115 #if defined(OS_WIN)
115 base::ScopedPathOverride user_desktop_override_; 116 base::ScopedPathOverride user_desktop_override_;
116 base::ScopedPathOverride app_dir_override_; 117 base::ScopedPathOverride app_dir_override_;
117 base::ScopedPathOverride start_menu_override_; 118 base::ScopedPathOverride start_menu_override_;
118 base::ScopedPathOverride taskbar_pins_override_; 119 base::ScopedPathOverride taskbar_pins_override_;
119 base::win::ScopedCOMInitializer com_init_; 120 base::win::ScopedCOMInitializer com_init_;
120 #endif 121 #endif
(...skipping 16 matching lines...) Expand all
137 InitializeEmptyExtensionService(); 138 InitializeEmptyExtensionService();
138 139
139 profile()->CreateWebDataService(); 140 profile()->CreateWebDataService();
140 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( 141 TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
141 profile(), 142 profile(),
142 &ProfileResetterTest::CreateTemplateURLService); 143 &ProfileResetterTest::CreateTemplateURLService);
143 resetter_.reset(new ProfileResetter(profile())); 144 resetter_.reset(new ProfileResetter(profile()));
144 } 145 }
145 146
146 // static 147 // static
147 KeyedService* ProfileResetterTest::CreateTemplateURLService( 148 scoped_ptr<KeyedService> ProfileResetterTest::CreateTemplateURLService(
148 content::BrowserContext* context) { 149 content::BrowserContext* context) {
149 Profile* profile = static_cast<Profile*>(context); 150 Profile* profile = static_cast<Profile*>(context);
150 return new TemplateURLService( 151 return make_scoped_ptr(new TemplateURLService(
151 profile->GetPrefs(), 152 profile->GetPrefs(),
152 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), 153 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)),
153 WebDataServiceFactory::GetKeywordWebDataForProfile( 154 WebDataServiceFactory::GetKeywordWebDataForProfile(
154 profile, ServiceAccessType::EXPLICIT_ACCESS), 155 profile, ServiceAccessType::EXPLICIT_ACCESS),
155 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()); 156 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()));
156 } 157 }
157 158
158 159
159 // PinnedTabsResetTest -------------------------------------------------------- 160 // PinnedTabsResetTest --------------------------------------------------------
160 161
161 class PinnedTabsResetTest : public BrowserWithTestWindowTest, 162 class PinnedTabsResetTest : public BrowserWithTestWindowTest,
162 public ProfileResetterTestBase { 163 public ProfileResetterTestBase {
163 protected: 164 protected:
164 void SetUp() override; 165 void SetUp() override;
165 166
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 new ResettableSettingsSnapshot(profile())); 1073 new ResettableSettingsSnapshot(profile()));
1073 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail, 1074 deleted_snapshot->RequestShortcuts(base::Bind(&FeedbackCapture::Fail,
1074 base::Unretained(&capture))); 1075 base::Unretained(&capture)));
1075 deleted_snapshot.reset(); 1076 deleted_snapshot.reset();
1076 // Running remaining tasks shouldn't trigger the callback to be called as 1077 // Running remaining tasks shouldn't trigger the callback to be called as
1077 // |deleted_snapshot| was deleted before it could run. 1078 // |deleted_snapshot| was deleted before it could run.
1078 base::MessageLoop::current()->RunUntilIdle(); 1079 base::MessageLoop::current()->RunUntilIdle();
1079 } 1080 }
1080 1081
1081 } // namespace 1082 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698