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 "chrome/browser/profiles/profile_info_cache_unittest.h" | 5 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // Make sure everything has completed, and the file has been written to disk. | 607 // Make sure everything has completed, and the file has been written to disk. |
608 base::RunLoop().RunUntilIdle(); | 608 base::RunLoop().RunUntilIdle(); |
609 | 609 |
610 // Clean up. | 610 // Clean up. |
611 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); | 611 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); |
612 EXPECT_TRUE(base::PathExists(icon_path)); | 612 EXPECT_TRUE(base::PathExists(icon_path)); |
613 EXPECT_TRUE(base::DeleteFile(icon_path, true)); | 613 EXPECT_TRUE(base::DeleteFile(icon_path, true)); |
614 EXPECT_FALSE(base::PathExists(icon_path)); | 614 EXPECT_FALSE(base::PathExists(icon_path)); |
615 } | 615 } |
616 | 616 |
| 617 TEST_F(ProfileInfoCacheTest, NothingToDownloadHighResAvatarTest) { |
| 618 switches::EnableNewAvatarMenuForTesting( |
| 619 base::CommandLine::ForCurrentProcess()); |
| 620 |
| 621 // The TestingProfileManager's ProfileInfoCache doesn't download avatars. |
| 622 ProfileInfoCache profile_info_cache( |
| 623 g_browser_process->local_state(), |
| 624 testing_profile_manager_.profile_manager()->user_data_dir()); |
| 625 |
| 626 const size_t kIconIndex = profiles::GetPlaceholderAvatarIndex(); |
| 627 |
| 628 EXPECT_EQ(0U, profile_info_cache.GetNumberOfProfiles()); |
| 629 base::FilePath path_1 = GetProfilePath("path_1"); |
| 630 profile_info_cache.AddProfileToCache(path_1, ASCIIToUTF16("name_1"), |
| 631 std::string(), base::string16(), |
| 632 kIconIndex, std::string()); |
| 633 EXPECT_EQ(1U, profile_info_cache.GetNumberOfProfiles()); |
| 634 base::RunLoop().RunUntilIdle(); |
| 635 |
| 636 // We haven't tried to download any high-res avatars as the specified icon is |
| 637 // just a placeholder. |
| 638 EXPECT_EQ(0U, profile_info_cache.cached_avatar_images_.size()); |
| 639 EXPECT_EQ(0U, profile_info_cache.avatar_images_downloads_in_progress_.size()); |
| 640 } |
| 641 |
617 TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) { | 642 TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) { |
618 switches::EnableNewAvatarMenuForTesting( | 643 switches::EnableNewAvatarMenuForTesting( |
619 base::CommandLine::ForCurrentProcess()); | 644 base::CommandLine::ForCurrentProcess()); |
620 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); | 645 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); |
621 | 646 |
622 base::FilePath path_1 = GetProfilePath("path_1"); | 647 base::FilePath path_1 = GetProfilePath("path_1"); |
623 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("Default Profile"), | 648 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("Default Profile"), |
624 std::string(), base::string16(), 0, | 649 std::string(), base::string16(), 0, |
625 std::string()); | 650 std::string()); |
626 base::FilePath path_2 = GetProfilePath("path_2"); | 651 base::FilePath path_2 = GetProfilePath("path_2"); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 // Profile names should have been preserved. | 725 // Profile names should have been preserved. |
701 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 726 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
702 GetCache()->GetIndexOfProfileWithPath(path_1))); | 727 GetCache()->GetIndexOfProfileWithPath(path_1))); |
703 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 728 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
704 GetCache()->GetIndexOfProfileWithPath(path_2))); | 729 GetCache()->GetIndexOfProfileWithPath(path_2))); |
705 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 730 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
706 GetCache()->GetIndexOfProfileWithPath(path_3))); | 731 GetCache()->GetIndexOfProfileWithPath(path_3))); |
707 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 732 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
708 GetCache()->GetIndexOfProfileWithPath(path_4))); | 733 GetCache()->GetIndexOfProfileWithPath(path_4))); |
709 } | 734 } |
OLD | NEW |