| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 virtual Profile* CreateProfileHelper( | 371 virtual Profile* CreateProfileHelper( |
| 372 const base::FilePath& file_path) OVERRIDE { | 372 const base::FilePath& file_path) OVERRIDE { |
| 373 TestingProfile::Builder builder; | 373 TestingProfile::Builder builder; |
| 374 builder.SetGuestSession(); | 374 builder.SetGuestSession(); |
| 375 builder.SetPath(file_path); | 375 builder.SetPath(file_path); |
| 376 TestingProfile* testing_profile = builder.Build().release(); | 376 TestingProfile* testing_profile = builder.Build().release(); |
| 377 return testing_profile; | 377 return testing_profile; |
| 378 } | 378 } |
| 379 }; | 379 }; |
| 380 | 380 |
| 381 class ProfileManagerGuestTest : public ProfileManagerTest, | 381 class ProfileManagerGuestTest : public ProfileManagerTest { |
| 382 public testing::WithParamInterface<bool> { | |
| 383 protected: | 382 protected: |
| 384 virtual void SetUp() { | 383 virtual void SetUp() { |
| 385 // Create a new temporary directory, and store the path | 384 // Create a new temporary directory, and store the path |
| 386 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 385 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 387 TestingBrowserProcess::GetGlobal()->SetProfileManager( | 386 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
| 388 new UnittestGuestProfileManager(temp_dir_.path())); | 387 new UnittestGuestProfileManager(temp_dir_.path())); |
| 389 | 388 |
| 390 #if defined(OS_CHROMEOS) | 389 #if defined(OS_CHROMEOS) |
| 391 CommandLine* cl = CommandLine::ForCurrentProcess(); | 390 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 392 if (GetParam()) | 391 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, |
| 393 cl->AppendSwitch(switches::kMultiProfiles); | 392 std::string(chrome::kProfileDirPrefix) + |
| 394 | 393 chromeos::UserManager::kGuestUserName); |
| 395 cl->AppendSwitch(switches::kTestType); | |
| 396 if (profiles::IsMultipleProfilesEnabled()) { | |
| 397 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, | |
| 398 std::string(chrome::kProfileDirPrefix) + | |
| 399 chromeos::UserManager::kGuestUserName); | |
| 400 } else { | |
| 401 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | |
| 402 } | |
| 403 cl->AppendSwitch(chromeos::switches::kGuestSession); | 394 cl->AppendSwitch(chromeos::switches::kGuestSession); |
| 404 cl->AppendSwitch(::switches::kIncognito); | 395 cl->AppendSwitch(::switches::kIncognito); |
| 405 | 396 |
| 406 chromeos::UserManager::Get()->UserLoggedIn( | 397 chromeos::UserManager::Get()->UserLoggedIn( |
| 407 chromeos::UserManager::kGuestUserName, | 398 chromeos::UserManager::kGuestUserName, |
| 408 chromeos::UserManager::kGuestUserName, | 399 chromeos::UserManager::kGuestUserName, |
| 409 false); | 400 false); |
| 410 #endif | 401 #endif |
| 411 } | 402 } |
| 412 }; | 403 }; |
| 413 | 404 |
| 414 INSTANTIATE_TEST_CASE_P(ProfileManagerGuestTestInstantiation, | 405 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) { |
| 415 ProfileManagerGuestTest, | |
| 416 testing::Bool()); | |
| 417 | |
| 418 TEST_P(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) { | |
| 419 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 406 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 420 ASSERT_TRUE(profile_manager); | 407 ASSERT_TRUE(profile_manager); |
| 421 | 408 |
| 422 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); | 409 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); |
| 423 ASSERT_TRUE(profile); | 410 ASSERT_TRUE(profile); |
| 424 EXPECT_TRUE(profile->IsOffTheRecord()); | 411 EXPECT_TRUE(profile->IsOffTheRecord()); |
| 425 } | 412 } |
| 426 | 413 |
| 427 #if defined(OS_CHROMEOS) | 414 #if defined(OS_CHROMEOS) |
| 428 TEST_P(ProfileManagerGuestTest, GuestProfileIngonito) { | 415 TEST_F(ProfileManagerGuestTest, GuestProfileIngonito) { |
| 429 Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); | 416 Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); |
| 430 EXPECT_TRUE(primary_profile->IsOffTheRecord()); | 417 EXPECT_TRUE(primary_profile->IsOffTheRecord()); |
| 431 | 418 |
| 432 Profile* active_profile = ProfileManager::GetActiveUserProfile(); | 419 Profile* active_profile = ProfileManager::GetActiveUserProfile(); |
| 433 EXPECT_TRUE(active_profile->IsOffTheRecord()); | 420 EXPECT_TRUE(active_profile->IsOffTheRecord()); |
| 434 | 421 |
| 435 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile)); | 422 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile)); |
| 436 | 423 |
| 437 Profile* last_used_profile = ProfileManager::GetLastUsedProfile(); | 424 Profile* last_used_profile = ProfileManager::GetLastUsedProfile(); |
| 438 EXPECT_TRUE(last_used_profile->IsOffTheRecord()); | 425 EXPECT_TRUE(last_used_profile->IsOffTheRecord()); |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 dest_path2.BaseName().MaybeAsASCII()); | 1094 dest_path2.BaseName().MaybeAsASCII()); |
| 1108 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1095 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 1109 ProfileManager::CreateCallback()); | 1096 ProfileManager::CreateCallback()); |
| 1110 // Spin the message loop so that all the callbacks can finish running. | 1097 // Spin the message loop so that all the callbacks can finish running. |
| 1111 base::RunLoop().RunUntilIdle(); | 1098 base::RunLoop().RunUntilIdle(); |
| 1112 | 1099 |
| 1113 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1100 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 1114 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1101 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 1115 } | 1102 } |
| 1116 #endif // !defined(OS_MACOSX) | 1103 #endif // !defined(OS_MACOSX) |
| OLD | NEW |