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" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 base::FilePath last_used_profile_path = | 155 base::FilePath last_used_profile_path = |
156 user_data_dir_.AppendASCII("last-used"); | 156 user_data_dir_.AppendASCII("last-used"); |
157 EXPECT_EQ(last_used_profile_path, | 157 EXPECT_EQ(last_used_profile_path, |
158 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 158 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
159 | 159 |
160 // For this test, the AppListViewDelegate is not created because the | 160 // For this test, the AppListViewDelegate is not created because the |
161 // app list is never shown, so there is nothing to destroy. | 161 // app list is never shown, so there is nothing to destroy. |
162 EXPECT_EQ(0, service_->destroy_app_list_call_count()); | 162 EXPECT_EQ(0, service_->destroy_app_list_call_count()); |
163 } | 163 } |
164 | 164 |
| 165 TEST_F(AppListServiceUnitTest, RefusesToLoadGuestAppListProfile) { |
| 166 // Unlikely, but if somehow the user's app_list.profile pref was set to the |
| 167 // guest profile, make sure we refuse to load it (or it would crash). |
| 168 local_state_->SetString(prefs::kAppListProfile, chrome::kGuestProfileDir); |
| 169 local_state_->SetString(prefs::kProfileLastUsed, "last-used"); |
| 170 base::FilePath initial_profile_path = user_data_dir_.AppendASCII("last-used"); |
| 171 EXPECT_EQ(initial_profile_path, |
| 172 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
| 173 } |
| 174 |
| 175 TEST_F(AppListServiceUnitTest, RefusesToLoadGuestLastUsedProfile) { |
| 176 // If the user's most recent browser session was a guest session, make sure we |
| 177 // do not open a guest profile in the launcher (which would crash). |
| 178 local_state_->SetString(prefs::kProfileLastUsed, chrome::kGuestProfileDir); |
| 179 base::FilePath initial_profile_path = |
| 180 user_data_dir_.AppendASCII(chrome::kInitialProfile); |
| 181 EXPECT_EQ(initial_profile_path, |
| 182 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
| 183 } |
| 184 |
165 TEST_F(AppListServiceUnitTest, SwitchingProfilesPersists) { | 185 TEST_F(AppListServiceUnitTest, SwitchingProfilesPersists) { |
166 profile_store_->LoadProfile(profile1_.get()); | 186 profile_store_->LoadProfile(profile1_.get()); |
167 profile_store_->LoadProfile(profile2_.get()); | 187 profile_store_->LoadProfile(profile2_.get()); |
168 EnableAppList(); | 188 EnableAppList(); |
169 service_->SetProfilePath(profile2_->GetPath()); | 189 service_->SetProfilePath(profile2_->GetPath()); |
170 service_->Show(); | 190 service_->Show(); |
171 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); | 191 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); |
172 EXPECT_EQ(profile2_->GetPath(), | 192 EXPECT_EQ(profile2_->GetPath(), |
173 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 193 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
174 service_->SetProfilePath(profile1_->GetPath()); | 194 service_->SetProfilePath(profile1_->GetPath()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, | 254 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, |
235 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 255 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
236 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); | 256 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); |
237 | 257 |
238 // An auto-show here should update the enable method to prevent recording it | 258 // An auto-show here should update the enable method to prevent recording it |
239 // as ENABLE_FOR_APP_INSTALL. | 259 // as ENABLE_FOR_APP_INSTALL. |
240 service_->ShowForAppInstall(profile1_.get(), "", false); | 260 service_->ShowForAppInstall(profile1_.get(), "", false); |
241 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, | 261 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, |
242 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 262 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
243 } | 263 } |
OLD | NEW |