OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/pref_service_builder.h" | 10 #include "base/prefs/pref_service_factory.h" |
11 #include "base/prefs/testing_pref_store.h" | 11 #include "base/prefs/testing_pref_store.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profiles_state.h" | 13 #include "chrome/browser/profiles/profiles_state.h" |
14 #include "chrome/browser/ui/app_list/app_list_service.h" | 14 #include "chrome/browser/ui/app_list/app_list_service.h" |
15 #include "chrome/browser/ui/app_list/app_list_service_impl.h" | 15 #include "chrome/browser/ui/app_list/app_list_service_impl.h" |
16 #include "chrome/browser/ui/app_list/test/fake_keep_alive_service.h" | 16 #include "chrome/browser/ui/app_list/test/fake_keep_alive_service.h" |
17 #include "chrome/browser/ui/app_list/test/fake_profile.h" | 17 #include "chrome/browser/ui/app_list/test/fake_profile.h" |
18 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" | 18 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" |
19 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("udd")); | 85 user_data_dir_ = base::FilePath(FILE_PATH_LITERAL("udd")); |
86 profile1_.reset( | 86 profile1_.reset( |
87 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1"))); | 87 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1"))); |
88 profile2_.reset( | 88 profile2_.reset( |
89 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2"))); | 89 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2"))); |
90 PrefRegistrySimple* pref_registry = new PrefRegistrySimple; | 90 PrefRegistrySimple* pref_registry = new PrefRegistrySimple; |
91 | 91 |
92 AppListService::RegisterPrefs(pref_registry); | 92 AppListService::RegisterPrefs(pref_registry); |
93 profiles::RegisterPrefs(pref_registry); | 93 profiles::RegisterPrefs(pref_registry); |
94 | 94 |
95 PrefServiceBuilder builder; | 95 base::PrefServiceFactory factory; |
96 builder.WithUserPrefs(new TestingPrefStore); | 96 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore)); |
97 local_state_.reset(builder.Create(pref_registry)); | 97 local_state_ = factory.Create(pref_registry).Pass(); |
98 | 98 |
99 keep_alive_service_ = new FakeKeepAliveService; | 99 keep_alive_service_ = new FakeKeepAliveService; |
100 profile_store_ = new FakeProfileStore(user_data_dir_); | 100 profile_store_ = new FakeProfileStore(user_data_dir_); |
101 service_.reset(new TestingAppListServiceImpl( | 101 service_.reset(new TestingAppListServiceImpl( |
102 command_line, | 102 command_line, |
103 local_state_.get(), | 103 local_state_.get(), |
104 scoped_ptr<ProfileStore>(profile_store_), | 104 scoped_ptr<ProfileStore>(profile_store_), |
105 scoped_ptr<KeepAliveService>(keep_alive_service_))); | 105 scoped_ptr<KeepAliveService>(keep_alive_service_))); |
106 } | 106 } |
107 | 107 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); | 172 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); |
173 } | 173 } |
174 | 174 |
175 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) { | 175 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) { |
176 CommandLine command_line(CommandLine::NO_PROGRAM); | 176 CommandLine command_line(CommandLine::NO_PROGRAM); |
177 command_line.AppendSwitch(switches::kResetAppListInstallState); | 177 command_line.AppendSwitch(switches::kResetAppListInstallState); |
178 SetupWithCommandLine(command_line); | 178 SetupWithCommandLine(command_line); |
179 service_->HandleCommandLineFlags(profile1_.get()); | 179 service_->HandleCommandLineFlags(profile1_.get()); |
180 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); | 180 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); |
181 } | 181 } |
OLD | NEW |