| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 EXPECT_TRUE(last_used_profile->IsOffTheRecord()); | 433 EXPECT_TRUE(last_used_profile->IsOffTheRecord()); |
| 434 | 434 |
| 435 EXPECT_TRUE(last_used_profile->IsSameProfile(active_profile)); | 435 EXPECT_TRUE(last_used_profile->IsSameProfile(active_profile)); |
| 436 } | 436 } |
| 437 #endif | 437 #endif |
| 438 | 438 |
| 439 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { | 439 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { |
| 440 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 440 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 441 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 441 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 442 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, | 442 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, |
| 443 base::Value::CreateBooleanValue(true)); | 443 new base::FundamentalValue(true)); |
| 444 | 444 |
| 445 // Setting a pref which is not applicable to a system (i.e., Android in this | 445 // Setting a pref which is not applicable to a system (i.e., Android in this |
| 446 // case) does not necessarily create it. Don't bother continuing with the | 446 // case) does not necessarily create it. Don't bother continuing with the |
| 447 // test if this pref doesn't exist because it will not load the profiles if | 447 // test if this pref doesn't exist because it will not load the profiles if |
| 448 // it cannot verify that the pref for background mode is enabled. | 448 // it cannot verify that the pref for background mode is enabled. |
| 449 if (!local_state_.Get()->HasPrefPath(prefs::kBackgroundModeEnabled)) | 449 if (!local_state_.Get()->HasPrefPath(prefs::kBackgroundModeEnabled)) |
| 450 return; | 450 return; |
| 451 | 451 |
| 452 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 452 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
| 453 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"), | 453 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 465 | 465 |
| 466 profile_manager->AutoloadProfiles(); | 466 profile_manager->AutoloadProfiles(); |
| 467 | 467 |
| 468 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); | 468 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 TEST_F(ProfileManagerTest, DoNotAutoloadProfilesIfBackgroundModeOff) { | 471 TEST_F(ProfileManagerTest, DoNotAutoloadProfilesIfBackgroundModeOff) { |
| 472 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 472 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 473 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 473 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 474 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, | 474 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, |
| 475 base::Value::CreateBooleanValue(false)); | 475 new base::FundamentalValue(false)); |
| 476 | 476 |
| 477 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 477 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
| 478 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"), | 478 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_1"), |
| 479 ASCIIToUTF16("name_1"), base::string16(), 0, | 479 ASCIIToUTF16("name_1"), base::string16(), 0, |
| 480 std::string()); | 480 std::string()); |
| 481 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"), | 481 cache.AddProfileToCache(cache.GetUserDataDir().AppendASCII("path_2"), |
| 482 ASCIIToUTF16("name_2"), base::string16(), 0, | 482 ASCIIToUTF16("name_2"), base::string16(), 0, |
| 483 std::string()); | 483 std::string()); |
| 484 cache.SetBackgroundStatusOfProfileAtIndex(0, false); | 484 cache.SetBackgroundStatusOfProfileAtIndex(0, false); |
| 485 cache.SetBackgroundStatusOfProfileAtIndex(1, true); | 485 cache.SetBackgroundStatusOfProfileAtIndex(1, true); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 dest_path2.BaseName().MaybeAsASCII()); | 1116 dest_path2.BaseName().MaybeAsASCII()); |
| 1117 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1117 profile_manager->ScheduleProfileForDeletion(dest_path2, |
| 1118 ProfileManager::CreateCallback()); | 1118 ProfileManager::CreateCallback()); |
| 1119 // Spin the message loop so that all the callbacks can finish running. | 1119 // Spin the message loop so that all the callbacks can finish running. |
| 1120 base::RunLoop().RunUntilIdle(); | 1120 base::RunLoop().RunUntilIdle(); |
| 1121 | 1121 |
| 1122 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1122 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 1123 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1123 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 1124 } | 1124 } |
| 1125 #endif // !defined(OS_MACOSX) | 1125 #endif // !defined(OS_MACOSX) |
| OLD | NEW |