Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 base::RunLoop().RunUntilIdle(); | 293 base::RunLoop().RunUntilIdle(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 TEST_F(ProfileManagerTest, GetGuestProfilePath) { | 296 TEST_F(ProfileManagerTest, GetGuestProfilePath) { |
| 297 base::FilePath guest_path = ProfileManager::GetGuestProfilePath(); | 297 base::FilePath guest_path = ProfileManager::GetGuestProfilePath(); |
| 298 base::FilePath expected_path = temp_dir_.path(); | 298 base::FilePath expected_path = temp_dir_.path(); |
| 299 expected_path = expected_path.Append(chrome::kGuestProfileDir); | 299 expected_path = expected_path.Append(chrome::kGuestProfileDir); |
| 300 EXPECT_EQ(expected_path, guest_path); | 300 EXPECT_EQ(expected_path, guest_path); |
| 301 } | 301 } |
| 302 | 302 |
| 303 #if defined(OS_CHROMEOS) | |
| 304 class UnittestGuestProfileManager : public UnittestProfileManager { | |
| 305 public: | |
| 306 explicit UnittestGuestProfileManager(const base::FilePath& user_data_dir) | |
| 307 : UnittestProfileManager(user_data_dir) {} | |
| 308 | |
| 309 protected: | |
| 310 virtual Profile* CreateProfileHelper( | |
| 311 const base::FilePath& file_path) OVERRIDE { | |
| 312 TestingProfile* testing_profile = new TestingProfile(file_path, NULL); | |
| 313 | |
| 314 TestingProfile::Builder builder; | |
| 315 builder.SetIncognito(); | |
| 316 builder.SetGuestSession(); | |
| 317 builder.SetPath(ProfileManager::GetGuestProfilePath()); | |
| 318 testing_profile->SetOffTheRecordProfile(builder.Build().PassAs<Profile>()); | |
| 319 | |
| 320 return testing_profile; | |
| 321 } | |
| 322 }; | |
| 323 | |
| 324 class ProfileManagerGuestTest : public ProfileManagerTest { | |
|
Nikita (slow)
2013/12/25 07:48:24
Please add another instance of this test that will
Dmitry Polukhin
2014/01/06 20:26:55
Guest profile is no allowed in multi-profile sessi
| |
| 325 protected: | |
| 326 virtual void SetUp() { | |
| 327 // Create a new temporary directory, and store the path | |
| 328 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 329 TestingBrowserProcess::GetGlobal()->SetProfileManager( | |
| 330 new UnittestGuestProfileManager(temp_dir_.path())); | |
| 331 | |
| 332 CommandLine* cl = CommandLine::ForCurrentProcess(); | |
| 333 cl->AppendSwitch(switches::kTestType); | |
| 334 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | |
| 335 cl->AppendSwitch(chromeos::switches::kGuestSession); | |
| 336 cl->AppendSwitch(::switches::kIncognito); | |
| 337 | |
| 338 chromeos::UserManager::Get()->UserLoggedIn( | |
| 339 chromeos::UserManager::kGuestUserName, | |
| 340 chromeos::UserManager::kGuestUserName, | |
| 341 false); | |
| 342 } | |
| 343 }; | |
| 344 | |
| 345 TEST_F(ProfileManagerGuestTest, GuestProfileIngonito) { | |
| 346 Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); | |
| 347 EXPECT_TRUE(primary_profile->IsOffTheRecord()); | |
| 348 | |
| 349 Profile* active_profile = ProfileManager::GetActiveUserProfile(); | |
| 350 EXPECT_TRUE(active_profile->IsOffTheRecord()); | |
| 351 | |
| 352 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile)); | |
| 353 } | |
| 354 #endif | |
| 355 | |
| 303 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { | 356 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { |
| 304 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 357 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 305 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 358 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 306 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, | 359 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, |
| 307 Value::CreateBooleanValue(true)); | 360 Value::CreateBooleanValue(true)); |
| 308 | 361 |
| 309 // Setting a pref which is not applicable to a system (i.e., Android in this | 362 // Setting a pref which is not applicable to a system (i.e., Android in this |
| 310 // case) does not necessarily create it. Don't bother continuing with the | 363 // case) does not necessarily create it. Don't bother continuing with the |
| 311 // test if this pref doesn't exist because it will not load the profiles if | 364 // test if this pref doesn't exist because it will not load the profiles if |
| 312 // it cannot verify that the pref for background mode is enabled. | 365 // it cannot verify that the pref for background mode is enabled. |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 dest_path2.BaseName().MaybeAsASCII()); | 918 dest_path2.BaseName().MaybeAsASCII()); |
| 866 profile_manager->ScheduleProfileForDeletion(dest_path2, | 919 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 867 ProfileManager::CreateCallback()); | 920 ProfileManager::CreateCallback()); |
| 868 // Spin the message loop so that all the callbacks can finish running. | 921 // Spin the message loop so that all the callbacks can finish running. |
| 869 base::RunLoop().RunUntilIdle(); | 922 base::RunLoop().RunUntilIdle(); |
| 870 | 923 |
| 871 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 924 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 872 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 925 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 873 } | 926 } |
| 874 #endif // !defined(OS_MACOSX) | 927 #endif // !defined(OS_MACOSX) |
| OLD | NEW |