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

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 10908088: Cleanup: Constify some ProfileKeyedBaseFactory methods and all overrides. Remove ProfileKeyedBaseFa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service_unittest.cc
===================================================================
--- chrome/browser/extensions/extension_service_unittest.cc (revision 154876)
+++ chrome/browser/extensions/extension_service_unittest.cc (working copy)
@@ -245,7 +245,6 @@
class MockProviderVisitor
: public extensions::ExternalProviderInterface::VisitorInterface {
public:
-
// The provider will return |fake_base_path| from
// GetBaseCrxFilePath(). User can test the behavior with
// and without an empty path using this parameter.
@@ -410,25 +409,28 @@
}
void ExtensionServiceTestBase::InitializeExtensionService(
- const FilePath& pref_file, const FilePath& extensions_install_dir,
+ const FilePath& profile_path,
+ const FilePath& pref_file,
+ const FilePath& extensions_install_dir,
bool autoupdate_enabled) {
- TestingProfile* profile = new TestingProfile();
+ TestingProfile::Builder profile_builder;
// Create a PrefService that only contains user defined preference values.
- PrefService* prefs =
- PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create();
- Profile::RegisterUserPrefs(prefs);
- chrome::RegisterUserPrefs(prefs);
- profile->SetPrefService(prefs);
+ scoped_ptr<PrefService> prefs(
+ PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create());
+ Profile::RegisterUserPrefs(prefs.get());
+ chrome::RegisterUserPrefs(prefs.get());
+ profile_builder.SetPrefService(prefs.Pass());
+ profile_builder.SetPath(profile_path);
+ profile_ = profile_builder.Build();
#if defined(ENABLE_THEMES)
- ThemeServiceFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
+ ThemeServiceFactory::GetInstance()->RegisterUserPrefsOnProfile(
Lei Zhang 2012/09/05 19:16:26 It also occurred to me, we probably don't need the
Elliot Glaysher 2012/09/05 19:35:39 Are you sure? I think this is a different prefserv
+ profile_.get());
#endif
- PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(prefs);
+ PluginPrefsFactory::GetInstance()->RegisterUserPrefsOnProfile(profile_.get());
- profile_.reset(profile);
-
service_ = static_cast<extensions::TestExtensionSystem*>(
- ExtensionSystem::Get(profile))->CreateExtensionService(
+ ExtensionSystem::Get(profile_.get()))->CreateExtensionService(
CommandLine::ForCurrentProcess(),
extensions_install_dir,
autoupdate_enabled);
@@ -436,7 +438,7 @@
service_->set_show_extensions_prompts(false);
management_policy_ = static_cast<extensions::TestExtensionSystem*>(
- ExtensionSystem::Get(profile))->CreateManagementPolicy();
+ ExtensionSystem::Get(profile_.get()))->CreateManagementPolicy();
// When we start up, we want to make sure there is no external provider,
// since the ExtensionService on Windows will use the Registry as a default
@@ -451,18 +453,18 @@
void ExtensionServiceTestBase::InitializeInstalledExtensionService(
const FilePath& prefs_file, const FilePath& source_install_dir) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- FilePath path_ = temp_dir_.path();
- path_ = path_.Append(FILE_PATH_LITERAL("TestingExtensionsPath"));
- file_util::Delete(path_, true);
- file_util::CreateDirectory(path_);
- FilePath temp_prefs = path_.Append(FILE_PATH_LITERAL("Preferences"));
+ FilePath path = temp_dir_.path();
+ path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath"));
+ file_util::Delete(path, true);
+ file_util::CreateDirectory(path);
+ FilePath temp_prefs = path.Append(FILE_PATH_LITERAL("Preferences"));
file_util::CopyFile(prefs_file, temp_prefs);
- extensions_install_dir_ = path_.Append(FILE_PATH_LITERAL("Extensions"));
+ extensions_install_dir_ = path.Append(FILE_PATH_LITERAL("Extensions"));
file_util::Delete(extensions_install_dir_, true);
file_util::CopyDirectory(source_install_dir, extensions_install_dir_, true);
- InitializeExtensionService(temp_prefs, extensions_install_dir_, false);
+ InitializeExtensionService(path, temp_prefs, extensions_install_dir_, false);
}
void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
@@ -483,17 +485,16 @@
void ExtensionServiceTestBase::InitializeExtensionServiceHelper(
bool autoupdate_enabled) {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- FilePath path_ = temp_dir_.path();
- path_ = path_.Append(FILE_PATH_LITERAL("TestingExtensionsPath"));
- file_util::Delete(path_, true);
- file_util::CreateDirectory(path_);
- FilePath prefs_filename = path_
- .Append(FILE_PATH_LITERAL("TestPreferences"));
- extensions_install_dir_ = path_.Append(FILE_PATH_LITERAL("Extensions"));
+ FilePath path = temp_dir_.path();
+ path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath"));
+ file_util::Delete(path, true);
+ file_util::CreateDirectory(path);
+ FilePath prefs_filename = path.Append(FILE_PATH_LITERAL("TestPreferences"));
+ extensions_install_dir_ = path.Append(FILE_PATH_LITERAL("Extensions"));
file_util::Delete(extensions_install_dir_, true);
file_util::CreateDirectory(extensions_install_dir_);
- InitializeExtensionService(prefs_filename, extensions_install_dir_,
+ InitializeExtensionService(path, prefs_filename, extensions_install_dir_,
autoupdate_enabled);
}
@@ -1037,7 +1038,6 @@
FAIL() << "Packing should not fail.";
else
FAIL() << "Existing CRX should have been overwritten.";
-
}
// Test loading good extensions from the profile directory.
@@ -4625,8 +4625,7 @@
ASSERT_EQ(list.size(), 3U);
extensions::AppSyncData data[kAppCount];
- for (size_t i = 0; i < kAppCount; ++i)
- {
+ for (size_t i = 0; i < kAppCount; ++i) {
data[i] = extensions::AppSyncData(list[i]);
}
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.h ('k') | chrome/browser/extensions/extension_system_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698