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 <objbase.h> // For CoInitialize(). | 5 #include <objbase.h> // For CoInitialize(). |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 | 799 |
800 TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) { | 800 TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) { |
801 SetupDefaultProfileShortcut(FROM_HERE); | 801 SetupDefaultProfileShortcut(FROM_HERE); |
802 const base::FilePath icon_path_1 = | 802 const base::FilePath icon_path_1 = |
803 profiles::internal::GetProfileIconPath(profile_1_path_); | 803 profiles::internal::GetProfileIconPath(profile_1_path_); |
804 const base::FilePath icon_path_2 = | 804 const base::FilePath icon_path_2 = |
805 profiles::internal::GetProfileIconPath(profile_2_path_); | 805 profiles::internal::GetProfileIconPath(profile_2_path_); |
806 | 806 |
807 // Default profile has unbadged icon to start. | 807 // Default profile has unbadged icon to start. |
808 std::string unbadged_icon_1; | 808 std::string unbadged_icon_1; |
809 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1)); | 809 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1)); |
810 | 810 |
811 // Creating a new profile adds a badge to both the new profile icon and the | 811 // Creating a new profile adds a badge to both the new profile icon and the |
812 // default profile icon. Since they use the same icon index, the icon files | 812 // default profile icon. Since they use the same icon index, the icon files |
813 // should be the same. | 813 // should be the same. |
814 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 814 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
815 | 815 |
816 std::string badged_icon_1; | 816 std::string badged_icon_1; |
817 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &badged_icon_1)); | 817 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &badged_icon_1)); |
818 std::string badged_icon_2; | 818 std::string badged_icon_2; |
819 EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &badged_icon_2)); | 819 EXPECT_TRUE(base::ReadFileToString(icon_path_2, &badged_icon_2)); |
820 | 820 |
821 EXPECT_NE(badged_icon_1, unbadged_icon_1); | 821 EXPECT_NE(badged_icon_1, unbadged_icon_1); |
822 EXPECT_EQ(badged_icon_1, badged_icon_2); | 822 EXPECT_EQ(badged_icon_1, badged_icon_2); |
823 | 823 |
824 // Deleting the default profile will unbadge the new profile's icon and should | 824 // Deleting the default profile will unbadge the new profile's icon and should |
825 // result in an icon that is identical to the unbadged default profile icon. | 825 // result in an icon that is identical to the unbadged default profile icon. |
826 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); | 826 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
827 RunPendingTasks(); | 827 RunPendingTasks(); |
828 | 828 |
829 std::string unbadged_icon_2; | 829 std::string unbadged_icon_2; |
830 EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &unbadged_icon_2)); | 830 EXPECT_TRUE(base::ReadFileToString(icon_path_2, &unbadged_icon_2)); |
831 EXPECT_EQ(unbadged_icon_1, unbadged_icon_2); | 831 EXPECT_EQ(unbadged_icon_1, unbadged_icon_2); |
832 } | 832 } |
833 | 833 |
834 TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { | 834 TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { |
835 SetupAndCreateTwoShortcuts(FROM_HERE); | 835 SetupAndCreateTwoShortcuts(FROM_HERE); |
836 const base::FilePath icon_path_1 = | 836 const base::FilePath icon_path_1 = |
837 profiles::internal::GetProfileIconPath(profile_1_path_); | 837 profiles::internal::GetProfileIconPath(profile_1_path_); |
838 const base::FilePath icon_path_2 = | 838 const base::FilePath icon_path_2 = |
839 profiles::internal::GetProfileIconPath(profile_2_path_); | 839 profiles::internal::GetProfileIconPath(profile_2_path_); |
840 const size_t profile_index_1 = | 840 const size_t profile_index_1 = |
841 profile_info_cache_->GetIndexOfProfileWithPath(profile_1_path_); | 841 profile_info_cache_->GetIndexOfProfileWithPath(profile_1_path_); |
842 | 842 |
843 std::string badged_icon_1; | 843 std::string badged_icon_1; |
844 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &badged_icon_1)); | 844 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &badged_icon_1)); |
845 std::string badged_icon_2; | 845 std::string badged_icon_2; |
846 EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &badged_icon_2)); | 846 EXPECT_TRUE(base::ReadFileToString(icon_path_2, &badged_icon_2)); |
847 | 847 |
848 // Profile 1 and 2 are created with the same icon. | 848 // Profile 1 and 2 are created with the same icon. |
849 EXPECT_EQ(badged_icon_1, badged_icon_2); | 849 EXPECT_EQ(badged_icon_1, badged_icon_2); |
850 | 850 |
851 // Change profile 1's icon. | 851 // Change profile 1's icon. |
852 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 852 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
853 RunPendingTasks(); | 853 RunPendingTasks(); |
854 | 854 |
855 std::string new_badged_icon_1; | 855 std::string new_badged_icon_1; |
856 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &new_badged_icon_1)); | 856 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &new_badged_icon_1)); |
857 EXPECT_NE(new_badged_icon_1, badged_icon_1); | 857 EXPECT_NE(new_badged_icon_1, badged_icon_1); |
858 | 858 |
859 // Ensure the new icon is not the unbadged icon. | 859 // Ensure the new icon is not the unbadged icon. |
860 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 860 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
861 RunPendingTasks(); | 861 RunPendingTasks(); |
862 | 862 |
863 std::string unbadged_icon_1; | 863 std::string unbadged_icon_1; |
864 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1)); | 864 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1)); |
865 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); | 865 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); |
866 | 866 |
867 // Ensure the icon doesn't change on avatar change without 2 profiles. | 867 // Ensure the icon doesn't change on avatar change without 2 profiles. |
868 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 868 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
869 RunPendingTasks(); | 869 RunPendingTasks(); |
870 | 870 |
871 std::string unbadged_icon_1_a; | 871 std::string unbadged_icon_1_a; |
872 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); | 872 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); |
873 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); | 873 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); |
874 } | 874 } |
OLD | NEW |