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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 base::FilePath last_used_profile_path = | 161 base::FilePath last_used_profile_path = |
162 user_data_dir_.AppendASCII("last-used"); | 162 user_data_dir_.AppendASCII("last-used"); |
163 EXPECT_EQ(last_used_profile_path, | 163 EXPECT_EQ(last_used_profile_path, |
164 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 164 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
165 | 165 |
166 // For this test, the AppListViewDelegate is not created because the | 166 // For this test, the AppListViewDelegate is not created because the |
167 // app list is never shown, so there is nothing to destroy. | 167 // app list is never shown, so there is nothing to destroy. |
168 EXPECT_EQ(0, service_->destroy_app_list_call_count()); | 168 EXPECT_EQ(0, service_->destroy_app_list_call_count()); |
169 } | 169 } |
170 | 170 |
| 171 TEST_F(AppListServiceUnitTest, RefusesToLoadGuestAppListProfile) { |
| 172 // Unlikely, but if somehow the user's app_list.profile pref was set to the |
| 173 // guest profile, make sure we refuse to load it (or it would crash). |
| 174 local_state_->SetString( |
| 175 prefs::kAppListProfile, |
| 176 base::FilePath(chrome::kGuestProfileDir).MaybeAsASCII()); |
| 177 local_state_->SetString(prefs::kProfileLastUsed, "last-used"); |
| 178 base::FilePath last_used_profile_path = |
| 179 user_data_dir_.AppendASCII("last-used"); |
| 180 EXPECT_EQ(last_used_profile_path, |
| 181 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
| 182 } |
| 183 |
| 184 TEST_F(AppListServiceUnitTest, RefusesToLoadGuestLastUsedProfile) { |
| 185 // If the user's most recent browser session was a guest session, make sure we |
| 186 // do not open a guest profile in the launcher (which would crash). |
| 187 local_state_->SetString( |
| 188 prefs::kProfileLastUsed, |
| 189 base::FilePath(chrome::kGuestProfileDir).MaybeAsASCII()); |
| 190 base::FilePath initial_profile_path = |
| 191 user_data_dir_.AppendASCII(chrome::kInitialProfile); |
| 192 EXPECT_EQ(initial_profile_path, |
| 193 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
| 194 } |
| 195 |
171 TEST_F(AppListServiceUnitTest, SwitchingProfilesPersists) { | 196 TEST_F(AppListServiceUnitTest, SwitchingProfilesPersists) { |
172 profile_store_->LoadProfile(profile1_.get()); | 197 profile_store_->LoadProfile(profile1_.get()); |
173 profile_store_->LoadProfile(profile2_.get()); | 198 profile_store_->LoadProfile(profile2_.get()); |
174 EnableAppList(); | 199 EnableAppList(); |
175 service_->SetProfilePath(profile2_->GetPath()); | 200 service_->SetProfilePath(profile2_->GetPath()); |
176 service_->Show(); | 201 service_->Show(); |
177 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); | 202 EXPECT_EQ(profile2_.get(), service_->showing_for_profile()); |
178 EXPECT_EQ(profile2_->GetPath(), | 203 EXPECT_EQ(profile2_->GetPath(), |
179 service_->GetProfilePath(profile_store_->GetUserDataDir())); | 204 service_->GetProfilePath(profile_store_->GetUserDataDir())); |
180 service_->SetProfilePath(profile1_->GetPath()); | 205 service_->SetProfilePath(profile1_->GetPath()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, | 265 EXPECT_EQ(AppListService::ENABLE_FOR_APP_INSTALL, |
241 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 266 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
242 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); | 267 EXPECT_NE(0, local_state_->GetInt64(prefs::kAppListEnableTime)); |
243 | 268 |
244 // An auto-show here should update the enable method to prevent recording it | 269 // An auto-show here should update the enable method to prevent recording it |
245 // as ENABLE_FOR_APP_INSTALL. | 270 // as ENABLE_FOR_APP_INSTALL. |
246 service_->ShowForAppInstall(profile1_.get(), "", false); | 271 service_->ShowForAppInstall(profile1_.get(), "", false); |
247 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, | 272 EXPECT_EQ(AppListService::ENABLE_SHOWN_UNDISCOVERED, |
248 local_state_->GetInteger(prefs::kAppListEnableMethod)); | 273 local_state_->GetInteger(prefs::kAppListEnableMethod)); |
249 } | 274 } |
OLD | NEW |