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_factory.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_profile.h" | 16 #include "chrome/browser/ui/app_list/test/fake_profile.h" |
17 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" | 17 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" |
18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_switches.h" | |
20 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/app_list/app_list_switches.h" |
22 | 22 |
23 class TestingAppListServiceImpl : public AppListServiceImpl { | 23 class TestingAppListServiceImpl : public AppListServiceImpl { |
24 public: | 24 public: |
25 TestingAppListServiceImpl(const base::CommandLine& command_line, | 25 TestingAppListServiceImpl(const base::CommandLine& command_line, |
26 PrefService* local_state, | 26 PrefService* local_state, |
27 scoped_ptr<ProfileStore> profile_store) | 27 scoped_ptr<ProfileStore> profile_store) |
28 : AppListServiceImpl(command_line, local_state, profile_store.Pass()), | 28 : AppListServiceImpl(command_line, local_state, profile_store.Pass()), |
29 showing_for_profile_(NULL), | 29 showing_for_profile_(NULL), |
30 destroy_app_list_call_count_(0) {} | 30 destroy_app_list_call_count_(0) {} |
31 | 31 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); | 203 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); |
204 EXPECT_EQ(profile2_->GetPath(), | 204 EXPECT_EQ(profile2_->GetPath(), |
205 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 205 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
206 service_->SetProfilePath(profile1_->GetPath()); | 206 service_->SetProfilePath(profile1_->GetPath()); |
207 EXPECT_EQ(profile1_->GetPath(), | 207 EXPECT_EQ(profile1_->GetPath(), |
208 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 208 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
209 } | 209 } |
210 | 210 |
211 TEST_F(AppListServiceUnitTest, EnableViaCommandLineFlag) { | 211 TEST_F(AppListServiceUnitTest, EnableViaCommandLineFlag) { |
212 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 212 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
213 command_line.AppendSwitch(switches::kEnableAppList); | 213 command_line.AppendSwitch(app_list::switches::kEnableAppList); |
214 SetupWithCommandLine(command_line); | 214 SetupWithCommandLine(command_line); |
215 service_->PerformStartupChecks(profile1_.get()); | 215 service_->PerformStartupChecks(profile1_.get()); |
216 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); | 216 EXPECT_TRUE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); |
217 } | 217 } |
218 | 218 |
219 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) { | 219 TEST_F(AppListServiceUnitTest, DisableViaCommandLineFlag) { |
220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 220 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
221 command_line.AppendSwitch(switches::kResetAppListInstallState); | 221 command_line.AppendSwitch(app_list::switches::kResetAppListInstallState); |
222 SetupWithCommandLine(command_line); | 222 SetupWithCommandLine(command_line); |
223 service_->PerformStartupChecks(profile1_.get()); | 223 service_->PerformStartupChecks(profile1_.get()); |
224 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); | 224 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); |
225 } | 225 } |
226 | 226 |
227 TEST_F(AppListServiceUnitTest, UMAPrefStates) { | 227 TEST_F(AppListServiceUnitTest, UMAPrefStates) { |
228 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); | 228 EXPECT_FALSE(local_state_->GetBoolean(prefs::kAppLauncherHasBeenEnabled)); |
229 EXPECT_EQ(AppListService::ENABLE_NOT_RECORDED, | 229 EXPECT_EQ(AppListService::ENABLE_NOT_RECORDED, |
230 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 230 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
231 EXPECT_EQ(0, local_state_->GetInt64(prefs::kAppListEnableTime)); | 231 EXPECT_EQ(0, local_state_->GetInt64(prefs::kAppListEnableTime)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, | 266 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, |
267 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 267 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
268 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); | 268 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); |
269 | 269 |
270 // An auto-show here should update the enable method to prevent recording it | 270 // An auto-show here should update the enable method to prevent recording it |
271 // as ENABLE_FOR_APP_INSTALL. | 271 // as ENABLE_FOR_APP_INSTALL. |
272 service_->ShowForAppInstall(profile1_.get(), "", false); | 272 service_->ShowForAppInstall(profile1_.get(), "", false); |
273 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, | 273 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, |
274 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 274 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
275 } | 275 } |
OLD | NEW |