| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/test/test_shortcut_win.h" | 10 #include "base/test/test_shortcut_win.h" |
| 11 #include "base/win/shortcut.h" | 11 #include "base/win/shortcut.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 14 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 15 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
| 16 #include "chrome/installer/util/shell_util.h" | 16 #include "chrome/installer/util/shell_util.h" |
| 17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 18 #include "chrome/test/base/testing_pref_service.h" | 18 #include "chrome/test/base/testing_pref_service.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "chrome/test/base/testing_profile_manager.h" | 20 #include "chrome/test/base/testing_profile_manager.h" |
| 21 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
| 22 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 base::win::VerifyShortcutStatus VerifyProfileShortcut( | 30 // Sets |path| to the path to the shortcut for this profile. |
| 31 const string16& profile_name) { | 31 // Automatically fails the test on failure to do so. |
| 32 void GetShortcutPathForProfile(BrowserDistribution* dist, |
| 33 const string16& profile_name, |
| 34 FilePath* path) { |
| 35 string16 shortcut_name; |
| 36 EXPECT_TRUE(ShellUtil::GetDesktopPath(false, path)); |
| 37 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, profile_name, |
| 38 &shortcut_name)); |
| 39 *path = path->Append(shortcut_name); |
| 40 } |
| 41 |
| 42 // Returns true if the shortcut for this profile exists. |
| 43 bool ProfileShortcutExists(BrowserDistribution* dist, |
| 44 const string16& profile_name) { |
| 45 FilePath shortcut_path; |
| 46 GetShortcutPathForProfile(dist, profile_name, &shortcut_path); |
| 47 return file_util::PathExists(shortcut_path); |
| 48 } |
| 49 |
| 50 // Calls base::win::ValidateShortcut() with expected properties for |
| 51 // |profile_name|'s shortcut. |
| 52 void ValidateProfileShortcut(BrowserDistribution* dist, |
| 53 const string16& profile_name) { |
| 54 EXPECT_TRUE(ProfileShortcutExists(dist, profile_name)); |
| 55 |
| 32 FilePath exe_path; | 56 FilePath exe_path; |
| 33 EXPECT_TRUE(PathService::Get(base::FILE_EXE, &exe_path)); | 57 EXPECT_TRUE(PathService::Get(base::FILE_EXE, &exe_path)); |
| 34 | 58 |
| 35 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
| 36 | |
| 37 // Get the desktop path of the current user. | |
| 38 FilePath shortcut_path; | 59 FilePath shortcut_path; |
| 39 ShellUtil::GetDesktopPath(false, &shortcut_path); | 60 GetShortcutPathForProfile(dist, profile_name, &shortcut_path); |
| 40 // Get the name of the shortcut with profile attached | |
| 41 string16 shortcut_name; | |
| 42 ShellUtil::GetChromeShortcutName(dist, false, profile_name, | |
| 43 &shortcut_name); | |
| 44 shortcut_path = shortcut_path.Append(shortcut_name); | |
| 45 | 61 |
| 46 // TODO(hallielaine): With this new struct method for VerifyShortcut you can | 62 // TODO(hallielaine): With this new struct method for VerifyShortcut you can |
| 47 // now test more properties like: arguments, icon, icon_index, and app_id. | 63 // now test more properties like: arguments, icon, icon_index, and app_id. |
| 48 base::win::ShortcutProperties expected_properties; | 64 base::win::ShortcutProperties expected_properties; |
| 49 expected_properties.set_target(exe_path); | 65 expected_properties.set_target(exe_path); |
| 50 expected_properties.set_description(dist->GetAppDescription()); | 66 expected_properties.set_description(dist->GetAppDescription()); |
| 51 expected_properties.set_dual_mode(false); | 67 expected_properties.set_dual_mode(false); |
| 52 return base::win::VerifyShortcut(shortcut_path, expected_properties); | 68 base::win::ValidateShortcut(shortcut_path, expected_properties); |
| 53 } | 69 } |
| 54 | 70 |
| 55 } // namespace | 71 } // namespace |
| 56 | 72 |
| 57 class ProfileShortcutManagerTest : public testing::Test { | 73 class ProfileShortcutManagerTest : public testing::Test { |
| 58 protected: | 74 protected: |
| 59 ProfileShortcutManagerTest() | 75 ProfileShortcutManagerTest() |
| 60 : ui_thread_(BrowserThread::UI, &message_loop_), | 76 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 61 file_thread_(BrowserThread::FILE, &message_loop_) { | 77 file_thread_(BrowserThread::FILE, &message_loop_) { |
| 62 } | 78 } |
| 63 | 79 |
| 64 virtual void SetUp() OVERRIDE { | 80 virtual void SetUp() OVERRIDE { |
| 81 dist_ = BrowserDistribution::GetDistribution(); |
| 82 ASSERT_TRUE(dist_ != NULL); |
| 83 |
| 65 // Mock the user's Desktop into a temp directory. | 84 // Mock the user's Desktop into a temp directory. |
| 66 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); | 85 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); |
| 67 ASSERT_TRUE(PathService::Override(base::DIR_USER_DESKTOP, | 86 ASSERT_TRUE(PathService::Override(base::DIR_USER_DESKTOP, |
| 68 fake_user_desktop_.path())); | 87 fake_user_desktop_.path())); |
| 69 | 88 |
| 70 TestingBrowserProcess* browser_process = | 89 TestingBrowserProcess* browser_process = |
| 71 static_cast<TestingBrowserProcess*>(g_browser_process); | 90 static_cast<TestingBrowserProcess*>(g_browser_process); |
| 72 profile_manager_.reset(new TestingProfileManager(browser_process)); | 91 profile_manager_.reset(new TestingProfileManager(browser_process)); |
| 73 ASSERT_TRUE(profile_manager_->SetUp()); | 92 ASSERT_TRUE(profile_manager_->SetUp()); |
| 74 | 93 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 98 profile_manager_->profile_info_cache()->GetPathOfProfileAtIndex(0); | 117 profile_manager_->profile_info_cache()->GetPathOfProfileAtIndex(0); |
| 99 string16 profile_name; | 118 string16 profile_name; |
| 100 if (i != num_profiles - 1) { | 119 if (i != num_profiles - 1) { |
| 101 profile_name = | 120 profile_name = |
| 102 profile_manager_->profile_info_cache()->GetNameOfProfileAtIndex(0); | 121 profile_manager_->profile_info_cache()->GetNameOfProfileAtIndex(0); |
| 103 } | 122 } |
| 104 profile_manager_->profile_info_cache()->DeleteProfileFromCache( | 123 profile_manager_->profile_info_cache()->DeleteProfileFromCache( |
| 105 profile_path); | 124 profile_path); |
| 106 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 125 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 107 MessageLoop::current()->Run(); | 126 MessageLoop::current()->Run(); |
| 108 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 127 ASSERT_FALSE(ProfileShortcutExists(dist_, profile_name)); |
| 109 VerifyProfileShortcut(profile_name)); | |
| 110 ASSERT_FALSE(file_util::PathExists(profile_path.Append( | 128 ASSERT_FALSE(file_util::PathExists(profile_path.Append( |
| 111 FILE_PATH_LITERAL("Google Profile.ico")))); | 129 FILE_PATH_LITERAL("Google Profile.ico")))); |
| 112 } | 130 } |
| 113 } | 131 } |
| 114 | 132 |
| 115 void SetupDefaultProfileShortcut() { | 133 void SetupDefaultProfileShortcut() { |
| 116 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 134 ASSERT_FALSE(ProfileShortcutExists(dist_, profile_name_)); |
| 117 VerifyProfileShortcut(profile_name_)); | |
| 118 // A non-badged shortcut for chrome is automatically created with the | 135 // A non-badged shortcut for chrome is automatically created with the |
| 119 // first profile (for the case when the user deletes their only | 136 // first profile (for the case when the user deletes their only |
| 120 // profile). | 137 // profile). |
| 121 profile_manager_->profile_info_cache()->AddProfileToCache( | 138 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 122 dest_path_, profile_name_, string16(), 0); | 139 dest_path_, profile_name_, string16(), 0); |
| 123 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 140 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 124 MessageLoop::current()->Run(); | 141 MessageLoop::current()->Run(); |
| 125 // We now have 1 profile, so we expect a new shortcut with no profile | 142 // We now have 1 profile, so we expect a new shortcut with no profile |
| 126 // information. | 143 // information. |
| 127 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 144 ValidateProfileShortcut(dist_, string16()); |
| 128 VerifyProfileShortcut(string16())); | |
| 129 } | 145 } |
| 130 | 146 |
| 131 void SetupAndCreateTwoShortcuts() { | 147 void SetupAndCreateTwoShortcuts() { |
| 132 ASSERT_EQ(0, profile_manager_->profile_info_cache()->GetNumberOfProfiles()); | 148 ASSERT_EQ(0, profile_manager_->profile_info_cache()->GetNumberOfProfiles()); |
| 133 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 149 ASSERT_FALSE(ProfileShortcutExists(dist_, profile_name_)); |
| 134 VerifyProfileShortcut(profile_name_)); | 150 ASSERT_FALSE(ProfileShortcutExists(dist_, second_profile_name_)); |
| 135 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | |
| 136 VerifyProfileShortcut(second_profile_name_)); | |
| 137 | 151 |
| 138 profile_manager_->profile_info_cache()->AddProfileToCache( | 152 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 139 dest_path_, profile_name_, string16(), 0); | 153 dest_path_, profile_name_, string16(), 0); |
| 140 profile_manager_->profile_info_cache()->AddProfileToCache( | 154 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 141 second_dest_path_, second_profile_name_, string16(), 0); | 155 second_dest_path_, second_profile_name_, string16(), 0); |
| 142 profile_manager_->profile_manager()->profile_shortcut_manager()-> | 156 profile_manager_->profile_manager()->profile_shortcut_manager()-> |
| 143 CreateProfileShortcut(second_dest_path_); | 157 CreateProfileShortcut(second_dest_path_); |
| 144 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 158 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 145 MessageLoop::current()->Run(); | 159 MessageLoop::current()->Run(); |
| 146 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 160 ValidateProfileShortcut(dist_, profile_name_); |
| 147 VerifyProfileShortcut(profile_name_)); | 161 ValidateProfileShortcut(dist_, second_profile_name_); |
| 148 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | |
| 149 VerifyProfileShortcut(second_profile_name_)); | |
| 150 } | 162 } |
| 151 | 163 |
| 164 BrowserDistribution* dist_; |
| 152 MessageLoopForUI message_loop_; | 165 MessageLoopForUI message_loop_; |
| 153 content::TestBrowserThread ui_thread_; | 166 content::TestBrowserThread ui_thread_; |
| 154 content::TestBrowserThread file_thread_; | 167 content::TestBrowserThread file_thread_; |
| 155 scoped_ptr<TestingProfileManager> profile_manager_; | 168 scoped_ptr<TestingProfileManager> profile_manager_; |
| 156 ScopedTempDir fake_user_desktop_; | 169 ScopedTempDir fake_user_desktop_; |
| 157 FilePath dest_path_; | 170 FilePath dest_path_; |
| 158 string16 profile_name_; | 171 string16 profile_name_; |
| 159 FilePath second_dest_path_; | 172 FilePath second_dest_path_; |
| 160 string16 second_profile_name_; | 173 string16 second_profile_name_; |
| 161 }; | 174 }; |
| 162 | 175 |
| 163 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreate) { | 176 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreate) { |
| 164 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) | 177 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) |
| 165 return; | 178 return; |
| 166 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); | 179 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); |
| 167 | 180 |
| 168 profile_manager_->profile_info_cache()->AddProfileToCache( | 181 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 169 second_dest_path_, second_profile_name_, string16(), 0); | 182 second_dest_path_, second_profile_name_, string16(), 0); |
| 170 profile_manager_->profile_manager()->profile_shortcut_manager()-> | 183 profile_manager_->profile_manager()->profile_shortcut_manager()-> |
| 171 CreateProfileShortcut(second_dest_path_); | 184 CreateProfileShortcut(second_dest_path_); |
| 172 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 185 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 173 MessageLoop::current()->Run(); | 186 MessageLoop::current()->Run(); |
| 174 | 187 |
| 175 // We now have 2 profiles, so we expect a new shortcut with profile | 188 // We now have 2 profiles, so we expect a new shortcut with profile |
| 176 // information for this 2nd profile. | 189 // information for this 2nd profile. |
| 177 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 190 ValidateProfileShortcut(dist_, second_profile_name_); |
| 178 VerifyProfileShortcut(second_profile_name_)); | |
| 179 ASSERT_TRUE(file_util::PathExists(second_dest_path_.Append( | 191 ASSERT_TRUE(file_util::PathExists(second_dest_path_.Append( |
| 180 FILE_PATH_LITERAL("Google Profile.ico")))); | 192 FILE_PATH_LITERAL("Google Profile.ico")))); |
| 181 } | 193 } |
| 182 | 194 |
| 183 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) { | 195 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsUpdate) { |
| 184 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) | 196 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) |
| 185 return; | 197 return; |
| 186 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); | 198 ProfileShortcutManagerTest::SetupDefaultProfileShortcut(); |
| 187 | 199 |
| 188 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 200 EXPECT_FALSE(ProfileShortcutExists(dist_, second_profile_name_)); |
| 189 VerifyProfileShortcut(second_profile_name_)); | |
| 190 | 201 |
| 191 profile_manager_->profile_info_cache()->AddProfileToCache( | 202 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 192 second_dest_path_, second_profile_name_, string16(), 0); | 203 second_dest_path_, second_profile_name_, string16(), 0); |
| 193 profile_manager_->profile_manager()->profile_shortcut_manager()-> | 204 profile_manager_->profile_manager()->profile_shortcut_manager()-> |
| 194 CreateProfileShortcut(second_dest_path_); | 205 CreateProfileShortcut(second_dest_path_); |
| 195 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 206 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 196 MessageLoop::current()->Run(); | 207 MessageLoop::current()->Run(); |
| 197 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 208 ValidateProfileShortcut(dist_, second_profile_name_); |
| 198 VerifyProfileShortcut(second_profile_name_)); | |
| 199 | 209 |
| 200 // Cause an update in ProfileShortcutManager by modifying the profile info | 210 // Cause an update in ProfileShortcutManager by modifying the profile info |
| 201 // cache. | 211 // cache. |
| 202 string16 new_profile_name = ASCIIToUTF16("New Profile Name"); | 212 string16 new_profile_name = ASCIIToUTF16("New Profile Name"); |
| 203 profile_manager_->profile_info_cache()->SetNameOfProfileAtIndex( | 213 profile_manager_->profile_info_cache()->SetNameOfProfileAtIndex( |
| 204 profile_manager_->profile_info_cache()->GetIndexOfProfileWithPath( | 214 profile_manager_->profile_info_cache()->GetIndexOfProfileWithPath( |
| 205 second_dest_path_), | 215 second_dest_path_), |
| 206 new_profile_name); | 216 new_profile_name); |
| 207 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 217 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 208 MessageLoop::current()->Run(); | 218 MessageLoop::current()->Run(); |
| 209 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 219 EXPECT_FALSE(ProfileShortcutExists(dist_, second_profile_name_)); |
| 210 VerifyProfileShortcut(second_profile_name_)); | 220 ValidateProfileShortcut(dist_, new_profile_name); |
| 211 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | |
| 212 VerifyProfileShortcut(new_profile_name)); | |
| 213 } | 221 } |
| 214 | 222 |
| 215 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) { | 223 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) { |
| 216 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) | 224 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) |
| 217 return; | 225 return; |
| 218 ProfileShortcutManagerTest::SetupAndCreateTwoShortcuts(); | 226 ProfileShortcutManagerTest::SetupAndCreateTwoShortcuts(); |
| 219 | 227 |
| 220 // Delete one shortcut | 228 // Delete one shortcut |
| 221 profile_manager_->profile_info_cache()->DeleteProfileFromCache( | 229 profile_manager_->profile_info_cache()->DeleteProfileFromCache( |
| 222 second_dest_path_); | 230 second_dest_path_); |
| 223 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 231 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 224 MessageLoop::current()->Run(); | 232 MessageLoop::current()->Run(); |
| 225 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 233 EXPECT_FALSE(ProfileShortcutExists(dist_, second_profile_name_)); |
| 226 VerifyProfileShortcut(second_profile_name_)); | |
| 227 | 234 |
| 228 // Verify that the profile name has been removed from the remaining shortcut | 235 // Verify that the profile name has been removed from the remaining shortcut |
| 229 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 236 ValidateProfileShortcut(dist_, string16()); |
| 230 VerifyProfileShortcut(string16())); | |
| 231 // Verify that an additional shortcut, with the default profile's name does | 237 // Verify that an additional shortcut, with the default profile's name does |
| 232 // not exist | 238 // not exist |
| 233 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 239 EXPECT_FALSE(ProfileShortcutExists(dist_, profile_name_)); |
| 234 VerifyProfileShortcut(profile_name_)); | |
| 235 } | 240 } |
| 236 | 241 |
| 237 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) { | 242 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) { |
| 238 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) | 243 if (!profile_manager_->profile_manager()->profile_shortcut_manager()) |
| 239 return; | 244 return; |
| 240 ProfileShortcutManagerTest::SetupAndCreateTwoShortcuts(); | 245 ProfileShortcutManagerTest::SetupAndCreateTwoShortcuts(); |
| 241 | 246 |
| 242 // Delete one shortcut | 247 // Delete one shortcut |
| 243 profile_manager_->profile_info_cache()->DeleteProfileFromCache( | 248 profile_manager_->profile_info_cache()->DeleteProfileFromCache( |
| 244 second_dest_path_); | 249 second_dest_path_); |
| 245 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 250 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 246 MessageLoop::current()->Run(); | 251 MessageLoop::current()->Run(); |
| 247 | 252 |
| 248 // Verify that a default shortcut exists (no profile name/avatar) | 253 // Verify that a default shortcut exists (no profile name/avatar) |
| 249 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 254 ValidateProfileShortcut(dist_, string16()); |
| 250 VerifyProfileShortcut(string16())); | |
| 251 // Verify that an additional shortcut, with the default profile's name does | 255 // Verify that an additional shortcut, with the default profile's name does |
| 252 // not exist | 256 // not exist |
| 253 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 257 EXPECT_FALSE(ProfileShortcutExists(dist_, profile_name_)); |
| 254 VerifyProfileShortcut(profile_name_)); | |
| 255 | 258 |
| 256 // Create a second profile and shortcut | 259 // Create a second profile and shortcut |
| 257 profile_manager_->profile_info_cache()->AddProfileToCache( | 260 profile_manager_->profile_info_cache()->AddProfileToCache( |
| 258 second_dest_path_, second_profile_name_, string16(), 0); | 261 second_dest_path_, second_profile_name_, string16(), 0); |
| 259 profile_manager_->profile_manager()->profile_shortcut_manager()-> | 262 profile_manager_->profile_manager()->profile_shortcut_manager()-> |
| 260 CreateProfileShortcut(second_dest_path_); | 263 CreateProfileShortcut(second_dest_path_); |
| 261 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 264 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 262 MessageLoop::current()->Run(); | 265 MessageLoop::current()->Run(); |
| 263 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 266 ValidateProfileShortcut(dist_, second_profile_name_); |
| 264 VerifyProfileShortcut(second_profile_name_)); | |
| 265 | 267 |
| 266 // Verify that the original shortcut received the profile's name | 268 // Verify that the original shortcut received the profile's name |
| 267 EXPECT_EQ(base::win::VERIFY_SHORTCUT_SUCCESS, | 269 ValidateProfileShortcut(dist_, profile_name_); |
| 268 VerifyProfileShortcut(profile_name_)); | |
| 269 // Verify that a default shortcut no longer exists | 270 // Verify that a default shortcut no longer exists |
| 270 EXPECT_EQ(base::win::VERIFY_SHORTCUT_FAILURE_FILE_NOT_FOUND, | 271 EXPECT_FALSE(ProfileShortcutExists(dist_, string16())); |
| 271 VerifyProfileShortcut(string16())); | |
| 272 } | 272 } |
| 273 | |
| OLD | NEW |