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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 531 |
532 // Check that the profiles can be extracted from the local state. | 532 // Check that the profiles can be extracted from the local state. |
533 std::vector<base::string16> names = ProfileInfoCache::GetProfileNames(); | 533 std::vector<base::string16> names = ProfileInfoCache::GetProfileNames(); |
534 for (size_t i = 0; i < 4; i++) | 534 for (size_t i = 0; i < 4; i++) |
535 ASSERT_FALSE(names[i].empty()); | 535 ASSERT_FALSE(names[i].empty()); |
536 } | 536 } |
537 | 537 |
538 // High res avatar downloading is only supported on desktop. | 538 // High res avatar downloading is only supported on desktop. |
539 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) | 539 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS) |
540 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { | 540 TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { |
541 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 541 switches::EnableNewAvatarMenuForTesting( |
| 542 base::CommandLine::ForCurrentProcess()); |
542 | 543 |
543 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); | 544 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); |
544 base::FilePath path_1 = GetProfilePath("path_1"); | 545 base::FilePath path_1 = GetProfilePath("path_1"); |
545 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), | 546 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), |
546 base::string16(), 0, std::string()); | 547 base::string16(), 0, std::string()); |
547 EXPECT_EQ(1U, GetCache()->GetNumberOfProfiles()); | 548 EXPECT_EQ(1U, GetCache()->GetNumberOfProfiles()); |
548 | 549 |
549 // We haven't downloaded any high-res avatars yet. | 550 // We haven't downloaded any high-res avatars yet. |
550 EXPECT_EQ(0U, GetCache()->cached_avatar_images_.size()); | 551 EXPECT_EQ(0U, GetCache()->cached_avatar_images_.size()); |
551 | 552 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 // Clean up. | 586 // Clean up. |
586 base::FilePath icon_path = | 587 base::FilePath icon_path = |
587 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); | 588 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); |
588 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); | 589 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); |
589 EXPECT_TRUE(base::PathExists(icon_path)); | 590 EXPECT_TRUE(base::PathExists(icon_path)); |
590 EXPECT_TRUE(base::DeleteFile(icon_path, true)); | 591 EXPECT_TRUE(base::DeleteFile(icon_path, true)); |
591 EXPECT_FALSE(base::PathExists(icon_path)); | 592 EXPECT_FALSE(base::PathExists(icon_path)); |
592 } | 593 } |
593 | 594 |
594 TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) { | 595 TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) { |
595 switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 596 switches::EnableNewAvatarMenuForTesting( |
| 597 base::CommandLine::ForCurrentProcess()); |
596 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); | 598 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); |
597 | 599 |
598 base::FilePath path_1 = GetProfilePath("path_1"); | 600 base::FilePath path_1 = GetProfilePath("path_1"); |
599 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("Default Profile"), | 601 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("Default Profile"), |
600 base::string16(), 0, std::string()); | 602 base::string16(), 0, std::string()); |
601 base::FilePath path_2 = GetProfilePath("path_2"); | 603 base::FilePath path_2 = GetProfilePath("path_2"); |
602 GetCache()->AddProfileToCache(path_2, ASCIIToUTF16("First user"), | 604 GetCache()->AddProfileToCache(path_2, ASCIIToUTF16("First user"), |
603 base::string16(), 1, std::string()); | 605 base::string16(), 1, std::string()); |
604 base::string16 name_3 = ASCIIToUTF16("Lemonade"); | 606 base::string16 name_3 = ASCIIToUTF16("Lemonade"); |
605 base::FilePath path_3 = GetProfilePath("path_3"); | 607 base::FilePath path_3 = GetProfilePath("path_3"); |
(...skipping 26 matching lines...) Expand all Loading... |
632 GetCache()->GetIndexOfProfileWithPath(path_3))); | 634 GetCache()->GetIndexOfProfileWithPath(path_3))); |
633 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 635 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
634 GetCache()->GetIndexOfProfileWithPath(path_4))); | 636 GetCache()->GetIndexOfProfileWithPath(path_4))); |
635 EXPECT_EQ(name_5, GetCache()->GetNameOfProfileAtIndex( | 637 EXPECT_EQ(name_5, GetCache()->GetNameOfProfileAtIndex( |
636 GetCache()->GetIndexOfProfileWithPath(path_5))); | 638 GetCache()->GetIndexOfProfileWithPath(path_5))); |
637 } | 639 } |
638 #endif | 640 #endif |
639 | 641 |
640 TEST_F(ProfileInfoCacheTest, | 642 TEST_F(ProfileInfoCacheTest, |
641 DontMigrateLegacyProfileNamesWithoutNewAvatarMenu) { | 643 DontMigrateLegacyProfileNamesWithoutNewAvatarMenu) { |
642 switches::DisableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess()); | 644 switches::DisableNewAvatarMenuForTesting( |
| 645 base::CommandLine::ForCurrentProcess()); |
643 | 646 |
644 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); | 647 EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); |
645 | 648 |
646 base::string16 name_1 = ASCIIToUTF16("Default Profile"); | 649 base::string16 name_1 = ASCIIToUTF16("Default Profile"); |
647 base::FilePath path_1 = GetProfilePath("path_1"); | 650 base::FilePath path_1 = GetProfilePath("path_1"); |
648 GetCache()->AddProfileToCache(path_1, name_1, | 651 GetCache()->AddProfileToCache(path_1, name_1, |
649 base::string16(), 0, std::string()); | 652 base::string16(), 0, std::string()); |
650 base::string16 name_2 = ASCIIToUTF16("First user"); | 653 base::string16 name_2 = ASCIIToUTF16("First user"); |
651 base::FilePath path_2 = GetProfilePath("path_2"); | 654 base::FilePath path_2 = GetProfilePath("path_2"); |
652 GetCache()->AddProfileToCache(path_2, name_2, | 655 GetCache()->AddProfileToCache(path_2, name_2, |
(...skipping 14 matching lines...) Expand all Loading... |
667 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 670 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
668 GetCache()->GetIndexOfProfileWithPath(path_1))); | 671 GetCache()->GetIndexOfProfileWithPath(path_1))); |
669 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 672 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
670 GetCache()->GetIndexOfProfileWithPath(path_2))); | 673 GetCache()->GetIndexOfProfileWithPath(path_2))); |
671 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 674 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
672 GetCache()->GetIndexOfProfileWithPath(path_3))); | 675 GetCache()->GetIndexOfProfileWithPath(path_3))); |
673 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 676 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
674 GetCache()->GetIndexOfProfileWithPath(path_4))); | 677 GetCache()->GetIndexOfProfileWithPath(path_4))); |
675 } | 678 } |
676 | 679 |
OLD | NEW |