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/files/file_util.h" | 8 #include "base/files/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 profile_2_name_ = L"My profile 2"; | 56 profile_2_name_ = L"My profile 2"; |
57 profile_2_path_ = CreateProfileDirectory(profile_2_name_); | 57 profile_2_path_ = CreateProfileDirectory(profile_2_name_); |
58 profile_3_name_ = L"My profile 3"; | 58 profile_3_name_ = L"My profile 3"; |
59 profile_3_path_ = CreateProfileDirectory(profile_3_name_); | 59 profile_3_path_ = CreateProfileDirectory(profile_3_name_); |
60 } | 60 } |
61 | 61 |
62 void TearDown() override { | 62 void TearDown() override { |
63 message_loop_.RunUntilIdle(); | 63 message_loop_.RunUntilIdle(); |
64 | 64 |
65 // Delete all profiles and ensure their shortcuts got removed. | 65 // Delete all profiles and ensure their shortcuts got removed. |
66 const int num_profiles = profile_info_cache_->GetNumberOfProfiles(); | 66 const size_t num_profiles = profile_info_cache_->GetNumberOfProfiles(); |
67 for (int i = 0; i < num_profiles; ++i) { | 67 for (size_t i = 0; i < num_profiles; ++i) { |
68 const base::FilePath profile_path = | 68 const base::FilePath profile_path = |
69 profile_info_cache_->GetPathOfProfileAtIndex(0); | 69 profile_info_cache_->GetPathOfProfileAtIndex(0); |
70 base::string16 profile_name = | 70 base::string16 profile_name = |
71 profile_info_cache_->GetNameOfProfileAtIndex(0); | 71 profile_info_cache_->GetNameOfProfileAtIndex(0); |
72 profile_info_cache_->DeleteProfileFromCache(profile_path); | 72 profile_info_cache_->DeleteProfileFromCache(profile_path); |
73 RunPendingTasks(); | 73 RunPendingTasks(); |
74 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); | 74 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); |
75 // The icon file is not deleted until the profile directory is deleted. | 75 // The icon file is not deleted until the profile directory is deleted. |
76 const base::FilePath icon_path = | 76 const base::FilePath icon_path = |
77 profiles::internal::GetProfileIconPath(profile_path); | 77 profiles::internal::GetProfileIconPath(profile_path); |
78 ASSERT_TRUE(base::PathExists(icon_path)); | 78 ASSERT_TRUE(base::PathExists(icon_path)); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 base::FilePath CreateProfileDirectory(const base::string16& profile_name) { | 82 base::FilePath CreateProfileDirectory(const base::string16& profile_name) { |
83 const base::FilePath profile_path = | 83 const base::FilePath profile_path = |
84 profile_info_cache_->GetUserDataDir().Append(profile_name); | 84 profile_info_cache_->GetUserDataDir().Append(profile_name); |
85 base::CreateDirectory(profile_path); | 85 base::CreateDirectory(profile_path); |
86 return profile_path; | 86 return profile_path; |
87 } | 87 } |
88 | 88 |
89 void RunPendingTasks() { | 89 void RunPendingTasks() { |
90 base::MessageLoop::current()->PostTask( | 90 base::MessageLoop::current()->PostTask( |
91 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 91 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
92 base::MessageLoop::current()->Run(); | 92 base::MessageLoop::current()->Run(); |
93 } | 93 } |
94 | 94 |
95 void SetupDefaultProfileShortcut(const tracked_objects::Location& location) { | 95 void SetupDefaultProfileShortcut(const tracked_objects::Location& location) { |
96 ASSERT_EQ(0, profile_info_cache_->GetNumberOfProfiles()) | 96 ASSERT_EQ(0u, profile_info_cache_->GetNumberOfProfiles()) |
97 << location.ToString(); | 97 << location.ToString(); |
98 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)) | 98 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)) |
99 << location.ToString(); | 99 << location.ToString(); |
100 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, | 100 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, |
101 std::string(), base::string16(), 0, | 101 std::string(), base::string16(), 0, |
102 std::string()); | 102 std::string()); |
103 // Also create a non-badged shortcut for Chrome, which is conveniently done | 103 // Also create a non-badged shortcut for Chrome, which is conveniently done |
104 // by |CreateProfileShortcut()| since there is only one profile. | 104 // by |CreateProfileShortcut()| since there is only one profile. |
105 profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_); | 105 profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_); |
106 RunPendingTasks(); | 106 RunPendingTasks(); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); | 870 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); |
871 | 871 |
872 // Ensure the icon doesn't change on avatar change without 2 profiles. | 872 // Ensure the icon doesn't change on avatar change without 2 profiles. |
873 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 873 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
874 RunPendingTasks(); | 874 RunPendingTasks(); |
875 | 875 |
876 std::string unbadged_icon_1_a; | 876 std::string unbadged_icon_1_a; |
877 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); | 877 EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); |
878 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); | 878 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); |
879 } | 879 } |
OLD | NEW |