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 { | |
| 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 ProfileManager::AllowGetDefaultProfile(); | |
|
Mr4D (OOO till 08-26)
2013/12/20 23:39:57
This function doesn't exist anymore (landed a patc
Dmitry Polukhin
2013/12/21 00:04:56
Excellent! This was artifact that has nothing with
| |
| 347 | |
| 348 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 349 Profile* primary_profile = profile_manager->GetPrimaryUserProfile(); | |
|
Mr4D (OOO till 08-26)
2013/12/20 23:39:57
Nit: Since Get*UserProfile function is static - an
Dmitry Polukhin
2013/12/21 00:04:56
Done. Because these functions are not virtual over
| |
| 350 EXPECT_TRUE(primary_profile->IsOffTheRecord()); | |
| 351 | |
| 352 Profile* active_profile = profile_manager->GetActiveUserProfile(); | |
|
Mr4D (OOO till 08-26)
2013/12/20 23:39:57
Same here.
Dmitry Polukhin
2013/12/21 00:04:56
Done.
| |
| 353 EXPECT_TRUE(active_profile->IsOffTheRecord()); | |
| 354 | |
| 355 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile)); | |
| 356 } | |
| 357 #endif | |
| 358 | |
| 303 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { | 359 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { |
| 304 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 360 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 305 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 361 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 306 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, | 362 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, |
| 307 Value::CreateBooleanValue(true)); | 363 Value::CreateBooleanValue(true)); |
| 308 | 364 |
| 309 // Setting a pref which is not applicable to a system (i.e., Android in this | 365 // 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 | 366 // 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 | 367 // 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. | 368 // 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()); | 921 dest_path2.BaseName().MaybeAsASCII()); |
| 866 profile_manager->ScheduleProfileForDeletion(dest_path2, | 922 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 867 ProfileManager::CreateCallback()); | 923 ProfileManager::CreateCallback()); |
| 868 // Spin the message loop so that all the callbacks can finish running. | 924 // Spin the message loop so that all the callbacks can finish running. |
| 869 base::RunLoop().RunUntilIdle(); | 925 base::RunLoop().RunUntilIdle(); |
| 870 | 926 |
| 871 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 927 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 872 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 928 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 873 } | 929 } |
| 874 #endif // !defined(OS_MACOSX) | 930 #endif // !defined(OS_MACOSX) |
| OLD | NEW |