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 "chrome/browser/ui/app_list/app_list_service.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/command_line.h" | 9 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
7 #include "base/macros.h" | 11 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
11 #include "base/prefs/pref_service_factory.h" | 15 #include "base/prefs/pref_service_factory.h" |
12 #include "base/prefs/testing_pref_store.h" | 16 #include "base/prefs/testing_pref_store.h" |
13 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profiles_state.h" | 18 #include "chrome/browser/profiles/profiles_state.h" |
15 #include "chrome/browser/ui/app_list/app_list_service.h" | |
16 #include "chrome/browser/ui/app_list/app_list_service_impl.h" | 19 #include "chrome/browser/ui/app_list/app_list_service_impl.h" |
17 #include "chrome/browser/ui/app_list/test/fake_profile.h" | 20 #include "chrome/browser/ui/app_list/test/fake_profile.h" |
18 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" | 21 #include "chrome/browser/ui/app_list/test/fake_profile_store.h" |
19 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
20 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/app_list/app_list_switches.h" | 25 #include "ui/app_list/app_list_switches.h" |
23 | 26 |
24 class TestingAppListServiceImpl : public AppListServiceImpl { | 27 class TestingAppListServiceImpl : public AppListServiceImpl { |
25 public: | 28 public: |
26 TestingAppListServiceImpl(const base::CommandLine& command_line, | 29 TestingAppListServiceImpl(const base::CommandLine& command_line, |
27 PrefService* local_state, | 30 PrefService* local_state, |
28 scoped_ptr<ProfileStore> profile_store) | 31 scoped_ptr<ProfileStore> profile_store) |
29 : AppListServiceImpl(command_line, local_state, profile_store.Pass()), | 32 : AppListServiceImpl(command_line, local_state, std::move(profile_store)), |
30 showing_for_profile_(NULL), | 33 showing_for_profile_(NULL), |
31 destroy_app_list_call_count_(0) {} | 34 destroy_app_list_call_count_(0) {} |
32 | 35 |
33 Profile* showing_for_profile() const { | 36 Profile* showing_for_profile() const { |
34 return showing_for_profile_; | 37 return showing_for_profile_; |
35 } | 38 } |
36 | 39 |
37 int destroy_app_list_call_count() const { | 40 int destroy_app_list_call_count() const { |
38 return destroy_app_list_call_count_; | 41 return destroy_app_list_call_count_; |
39 } | 42 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1"))); | 95 new FakeProfile("p1", user_data_dir_.AppendASCII("profile1"))); |
93 profile2_.reset( | 96 profile2_.reset( |
94 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2"))); | 97 new FakeProfile("p2", user_data_dir_.AppendASCII("profile2"))); |
95 PrefRegistrySimple* pref_registry = new PrefRegistrySimple; | 98 PrefRegistrySimple* pref_registry = new PrefRegistrySimple; |
96 | 99 |
97 AppListService::RegisterPrefs(pref_registry); | 100 AppListService::RegisterPrefs(pref_registry); |
98 profiles::RegisterPrefs(pref_registry); | 101 profiles::RegisterPrefs(pref_registry); |
99 | 102 |
100 base::PrefServiceFactory factory; | 103 base::PrefServiceFactory factory; |
101 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore)); | 104 factory.set_user_prefs(make_scoped_refptr(new TestingPrefStore)); |
102 local_state_ = factory.Create(pref_registry).Pass(); | 105 local_state_ = factory.Create(pref_registry); |
103 | 106 |
104 profile_store_ = new FakeProfileStore(user_data_dir_, local_state_.get()); | 107 profile_store_ = new FakeProfileStore(user_data_dir_, local_state_.get()); |
105 service_.reset(new TestingAppListServiceImpl( | 108 service_.reset(new TestingAppListServiceImpl( |
106 command_line, | 109 command_line, |
107 local_state_.get(), | 110 local_state_.get(), |
108 scoped_ptr<ProfileStore>(profile_store_))); | 111 scoped_ptr<ProfileStore>(profile_store_))); |
109 } | 112 } |
110 | 113 |
111 void EnableAppList() { | 114 void EnableAppList() { |
112 service_->EnableAppList(profile1_.get(), | 115 service_->EnableAppList(profile1_.get(), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, | 270 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, |
268 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 271 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
269 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); | 272 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); |
270 | 273 |
271 // An auto-show here should update the enable method to prevent recording it | 274 // An auto-show here should update the enable method to prevent recording it |
272 // as ENABLE_FOR_APP_INSTALL. | 275 // as ENABLE_FOR_APP_INSTALL. |
273 service_->ShowForAppInstall(profile1_.get(), "", false); | 276 service_->ShowForAppInstall(profile1_.get(), "", false); |
274 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, | 277 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, |
275 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 278 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
276 } | 279 } |
OLD | NEW |