| 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.h" | 10 #include "base/message_loop.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const int num_profiles = profile_info_cache_->GetNumberOfProfiles(); | 66 const int num_profiles = profile_info_cache_->GetNumberOfProfiles(); |
| 67 for (int i = 0; i < num_profiles; ++i) { | 67 for (int 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 string16 profile_name = profile_info_cache_->GetNameOfProfileAtIndex(0); | 70 string16 profile_name = profile_info_cache_->GetNameOfProfileAtIndex(0); |
| 71 profile_info_cache_->DeleteProfileFromCache(profile_path); | 71 profile_info_cache_->DeleteProfileFromCache(profile_path); |
| 72 RunPendingTasks(); | 72 RunPendingTasks(); |
| 73 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); | 73 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); |
| 74 const base::FilePath icon_path = | 74 const base::FilePath icon_path = |
| 75 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); | 75 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); |
| 76 ASSERT_FALSE(file_util::PathExists(icon_path)); | 76 ASSERT_FALSE(base::PathExists(icon_path)); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 base::FilePath CreateProfileDirectory(const string16& profile_name) { | 80 base::FilePath CreateProfileDirectory(const string16& profile_name) { |
| 81 const base::FilePath profile_path = | 81 const base::FilePath profile_path = |
| 82 profile_info_cache_->GetUserDataDir().Append(profile_name); | 82 profile_info_cache_->GetUserDataDir().Append(profile_name); |
| 83 file_util::CreateDirectoryW(profile_path); | 83 file_util::CreateDirectoryW(profile_path); |
| 84 return profile_path; | 84 return profile_path; |
| 85 } | 85 } |
| 86 | 86 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 // Returns the default shortcut path for this profile. | 114 // Returns the default shortcut path for this profile. |
| 115 base::FilePath GetDefaultShortcutPathForProfile( | 115 base::FilePath GetDefaultShortcutPathForProfile( |
| 116 const string16& profile_name) { | 116 const string16& profile_name) { |
| 117 return GetUserShortcutsDirectory().Append( | 117 return GetUserShortcutsDirectory().Append( |
| 118 profiles::internal::GetShortcutFilenameForProfile(profile_name, | 118 profiles::internal::GetShortcutFilenameForProfile(profile_name, |
| 119 GetDistribution())); | 119 GetDistribution())); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Returns true if the shortcut for this profile exists. | 122 // Returns true if the shortcut for this profile exists. |
| 123 bool ProfileShortcutExistsAtDefaultPath(const string16& profile_name) { | 123 bool ProfileShortcutExistsAtDefaultPath(const string16& profile_name) { |
| 124 return file_util::PathExists( | 124 return base::PathExists( |
| 125 GetDefaultShortcutPathForProfile(profile_name)); | 125 GetDefaultShortcutPathForProfile(profile_name)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Calls base::win::ValidateShortcut() with expected properties for the | 128 // Calls base::win::ValidateShortcut() with expected properties for the |
| 129 // shortcut at |shortcut_path| for the profile at |profile_path|. | 129 // shortcut at |shortcut_path| for the profile at |profile_path|. |
| 130 void ValidateProfileShortcutAtPath(const tracked_objects::Location& location, | 130 void ValidateProfileShortcutAtPath(const tracked_objects::Location& location, |
| 131 const base::FilePath& shortcut_path, | 131 const base::FilePath& shortcut_path, |
| 132 const base::FilePath& profile_path) { | 132 const base::FilePath& profile_path) { |
| 133 EXPECT_TRUE(file_util::PathExists(shortcut_path)) << location.ToString(); | 133 EXPECT_TRUE(base::PathExists(shortcut_path)) << location.ToString(); |
| 134 | 134 |
| 135 // Ensure that the corresponding icon exists. | 135 // Ensure that the corresponding icon exists. |
| 136 const base::FilePath icon_path = | 136 const base::FilePath icon_path = |
| 137 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); | 137 profile_path.AppendASCII(profiles::internal::kProfileIconFileName); |
| 138 EXPECT_TRUE(file_util::PathExists(icon_path)) << location.ToString(); | 138 EXPECT_TRUE(base::PathExists(icon_path)) << location.ToString(); |
| 139 | 139 |
| 140 base::win::ShortcutProperties expected_properties; | 140 base::win::ShortcutProperties expected_properties; |
| 141 expected_properties.set_app_id( | 141 expected_properties.set_app_id( |
| 142 ShellIntegration::GetChromiumModelIdForProfile(profile_path)); | 142 ShellIntegration::GetChromiumModelIdForProfile(profile_path)); |
| 143 expected_properties.set_target(GetExePath()); | 143 expected_properties.set_target(GetExePath()); |
| 144 expected_properties.set_description(GetDistribution()->GetAppDescription()); | 144 expected_properties.set_description(GetDistribution()->GetAppDescription()); |
| 145 expected_properties.set_dual_mode(false); | 145 expected_properties.set_dual_mode(false); |
| 146 expected_properties.set_arguments( | 146 expected_properties.set_arguments( |
| 147 profiles::internal::CreateProfileShortcutFlags(profile_path)); | 147 profiles::internal::CreateProfileShortcutFlags(profile_path)); |
| 148 expected_properties.set_icon(icon_path, 0); | 148 expected_properties.set_icon(icon_path, 0); |
| 149 base::win::ValidateShortcut(shortcut_path, expected_properties); | 149 base::win::ValidateShortcut(shortcut_path, expected_properties); |
| 150 } | 150 } |
| 151 | 151 |
| 152 // Calls base::win::ValidateShortcut() with expected properties for | 152 // Calls base::win::ValidateShortcut() with expected properties for |
| 153 // |profile_name|'s shortcut. | 153 // |profile_name|'s shortcut. |
| 154 void ValidateProfileShortcut(const tracked_objects::Location& location, | 154 void ValidateProfileShortcut(const tracked_objects::Location& location, |
| 155 const string16& profile_name, | 155 const string16& profile_name, |
| 156 const base::FilePath& profile_path) { | 156 const base::FilePath& profile_path) { |
| 157 ValidateProfileShortcutAtPath( | 157 ValidateProfileShortcutAtPath( |
| 158 location, GetDefaultShortcutPathForProfile(profile_name), profile_path); | 158 location, GetDefaultShortcutPathForProfile(profile_name), profile_path); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ValidateNonProfileShortcutAtPath( | 161 void ValidateNonProfileShortcutAtPath( |
| 162 const tracked_objects::Location& location, | 162 const tracked_objects::Location& location, |
| 163 const base::FilePath& shortcut_path) { | 163 const base::FilePath& shortcut_path) { |
| 164 EXPECT_TRUE(file_util::PathExists(shortcut_path)) << location.ToString(); | 164 EXPECT_TRUE(base::PathExists(shortcut_path)) << location.ToString(); |
| 165 | 165 |
| 166 base::win::ShortcutProperties expected_properties; | 166 base::win::ShortcutProperties expected_properties; |
| 167 expected_properties.set_target(GetExePath()); | 167 expected_properties.set_target(GetExePath()); |
| 168 expected_properties.set_arguments(string16()); | 168 expected_properties.set_arguments(string16()); |
| 169 expected_properties.set_icon(GetExePath(), 0); | 169 expected_properties.set_icon(GetExePath(), 0); |
| 170 expected_properties.set_description(GetDistribution()->GetAppDescription()); | 170 expected_properties.set_description(GetDistribution()->GetAppDescription()); |
| 171 expected_properties.set_dual_mode(false); | 171 expected_properties.set_dual_mode(false); |
| 172 base::win::ValidateShortcut(shortcut_path, expected_properties); | 172 base::win::ValidateShortcut(shortcut_path, expected_properties); |
| 173 } | 173 } |
| 174 | 174 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 190 ValidateProfileShortcut(location, profile_name, profile_path); | 190 ValidateProfileShortcut(location, profile_name, profile_path); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Creates a regular (non-profile) desktop shortcut with the given name and | 193 // Creates a regular (non-profile) desktop shortcut with the given name and |
| 194 // returns its path. Fails the test if an error occurs. | 194 // returns its path. Fails the test if an error occurs. |
| 195 base::FilePath CreateRegularShortcutWithName( | 195 base::FilePath CreateRegularShortcutWithName( |
| 196 const tracked_objects::Location& location, | 196 const tracked_objects::Location& location, |
| 197 const string16& shortcut_name) { | 197 const string16& shortcut_name) { |
| 198 const base::FilePath shortcut_path = | 198 const base::FilePath shortcut_path = |
| 199 GetUserShortcutsDirectory().Append(shortcut_name + installer::kLnkExt); | 199 GetUserShortcutsDirectory().Append(shortcut_name + installer::kLnkExt); |
| 200 EXPECT_FALSE(file_util::PathExists(shortcut_path)) << location.ToString(); | 200 EXPECT_FALSE(base::PathExists(shortcut_path)) << location.ToString(); |
| 201 | 201 |
| 202 installer::Product product(GetDistribution()); | 202 installer::Product product(GetDistribution()); |
| 203 ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); | 203 ShellUtil::ShortcutProperties properties(ShellUtil::CURRENT_USER); |
| 204 product.AddDefaultShortcutProperties(GetExePath(), &properties); | 204 product.AddDefaultShortcutProperties(GetExePath(), &properties); |
| 205 properties.set_shortcut_name(shortcut_name); | 205 properties.set_shortcut_name(shortcut_name); |
| 206 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 206 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 207 ShellUtil::SHORTCUT_LOCATION_DESKTOP, GetDistribution(), properties, | 207 ShellUtil::SHORTCUT_LOCATION_DESKTOP, GetDistribution(), properties, |
| 208 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); | 208 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); |
| 209 EXPECT_TRUE(file_util::PathExists(shortcut_path)) << location.ToString(); | 209 EXPECT_TRUE(base::PathExists(shortcut_path)) << location.ToString(); |
| 210 | 210 |
| 211 return shortcut_path; | 211 return shortcut_path; |
| 212 } | 212 } |
| 213 | 213 |
| 214 base::FilePath CreateRegularSystemLevelShortcut( | 214 base::FilePath CreateRegularSystemLevelShortcut( |
| 215 const tracked_objects::Location& location) { | 215 const tracked_objects::Location& location) { |
| 216 BrowserDistribution* distribution = GetDistribution(); | 216 BrowserDistribution* distribution = GetDistribution(); |
| 217 installer::Product product(distribution); | 217 installer::Product product(distribution); |
| 218 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); | 218 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); |
| 219 product.AddDefaultShortcutProperties(GetExePath(), &properties); | 219 product.AddDefaultShortcutProperties(GetExePath(), &properties); |
| 220 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 220 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 221 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, | 221 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, |
| 222 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); | 222 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); |
| 223 const base::FilePath system_level_shortcut_path = | 223 const base::FilePath system_level_shortcut_path = |
| 224 GetSystemShortcutsDirectory().Append( | 224 GetSystemShortcutsDirectory().Append( |
| 225 distribution->GetAppShortCutName() + installer::kLnkExt); | 225 distribution->GetAppShortCutName() + installer::kLnkExt); |
| 226 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)) | 226 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)) |
| 227 << location.ToString(); | 227 << location.ToString(); |
| 228 return system_level_shortcut_path; | 228 return system_level_shortcut_path; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void RenameProfile(const tracked_objects::Location& location, | 231 void RenameProfile(const tracked_objects::Location& location, |
| 232 const base::FilePath& profile_path, | 232 const base::FilePath& profile_path, |
| 233 const string16& new_profile_name) { | 233 const string16& new_profile_name) { |
| 234 const size_t profile_index = | 234 const size_t profile_index = |
| 235 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); | 235 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); |
| 236 ASSERT_NE(std::string::npos, profile_index); | 236 ASSERT_NE(std::string::npos, profile_index); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) { | 385 TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) { |
| 386 SetupAndCreateTwoShortcuts(FROM_HERE); | 386 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 387 | 387 |
| 388 const base::FilePath profile_1_shortcut_path = | 388 const base::FilePath profile_1_shortcut_path = |
| 389 GetDefaultShortcutPathForProfile(profile_1_name_); | 389 GetDefaultShortcutPathForProfile(profile_1_name_); |
| 390 const base::FilePath profile_2_shortcut_path = | 390 const base::FilePath profile_2_shortcut_path = |
| 391 GetDefaultShortcutPathForProfile(profile_2_name_); | 391 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 392 | 392 |
| 393 // Delete the shortcut for the first profile, but keep the one for the 2nd. | 393 // Delete the shortcut for the first profile, but keep the one for the 2nd. |
| 394 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); | 394 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); |
| 395 ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 395 ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 396 ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); | 396 ASSERT_TRUE(base::PathExists(profile_2_shortcut_path)); |
| 397 | 397 |
| 398 // Delete the profile that doesn't have a shortcut. | 398 // Delete the profile that doesn't have a shortcut. |
| 399 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); | 399 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
| 400 RunPendingTasks(); | 400 RunPendingTasks(); |
| 401 | 401 |
| 402 // Verify that the remaining shortcut does not have a profile name. | 402 // Verify that the remaining shortcut does not have a profile name. |
| 403 ValidateNonProfileShortcut(FROM_HERE); | 403 ValidateNonProfileShortcut(FROM_HERE); |
| 404 // Verify that shortcuts with profile names do not exist. | 404 // Verify that shortcuts with profile names do not exist. |
| 405 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 405 EXPECT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 406 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 406 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) { | 409 TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) { |
| 410 SetupAndCreateTwoShortcuts(FROM_HERE); | 410 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 411 | 411 |
| 412 const base::FilePath profile_1_shortcut_path = | 412 const base::FilePath profile_1_shortcut_path = |
| 413 GetDefaultShortcutPathForProfile(profile_1_name_); | 413 GetDefaultShortcutPathForProfile(profile_1_name_); |
| 414 const base::FilePath profile_2_shortcut_path = | 414 const base::FilePath profile_2_shortcut_path = |
| 415 GetDefaultShortcutPathForProfile(profile_2_name_); | 415 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 416 | 416 |
| 417 // Delete the shortcut for the first profile, but keep the one for the 2nd. | 417 // Delete the shortcut for the first profile, but keep the one for the 2nd. |
| 418 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); | 418 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); |
| 419 ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 419 ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 420 ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); | 420 ASSERT_TRUE(base::PathExists(profile_2_shortcut_path)); |
| 421 | 421 |
| 422 // Delete the profile that has a shortcut. | 422 // Delete the profile that has a shortcut. |
| 423 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 423 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 424 RunPendingTasks(); | 424 RunPendingTasks(); |
| 425 | 425 |
| 426 // Verify that the remaining shortcut does not have a profile name. | 426 // Verify that the remaining shortcut does not have a profile name. |
| 427 ValidateNonProfileShortcut(FROM_HERE); | 427 ValidateNonProfileShortcut(FROM_HERE); |
| 428 // Verify that shortcuts with profile names do not exist. | 428 // Verify that shortcuts with profile names do not exist. |
| 429 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 429 EXPECT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 430 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 430 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 431 } | 431 } |
| 432 | 432 |
| 433 TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) { | 433 TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) { |
| 434 SetupAndCreateTwoShortcuts(FROM_HERE); | 434 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 435 CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_); | 435 CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_); |
| 436 | 436 |
| 437 const base::FilePath non_profile_shortcut_path = | 437 const base::FilePath non_profile_shortcut_path = |
| 438 GetDefaultShortcutPathForProfile(string16()); | 438 GetDefaultShortcutPathForProfile(string16()); |
| 439 const base::FilePath profile_1_shortcut_path = | 439 const base::FilePath profile_1_shortcut_path = |
| 440 GetDefaultShortcutPathForProfile(profile_1_name_); | 440 GetDefaultShortcutPathForProfile(profile_1_name_); |
| 441 const base::FilePath profile_2_shortcut_path = | 441 const base::FilePath profile_2_shortcut_path = |
| 442 GetDefaultShortcutPathForProfile(profile_2_name_); | 442 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 443 const base::FilePath profile_3_shortcut_path = | 443 const base::FilePath profile_3_shortcut_path = |
| 444 GetDefaultShortcutPathForProfile(profile_3_name_); | 444 GetDefaultShortcutPathForProfile(profile_3_name_); |
| 445 | 445 |
| 446 // Delete shortcuts for the first two profiles. | 446 // Delete shortcuts for the first two profiles. |
| 447 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); | 447 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); |
| 448 ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); | 448 ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); |
| 449 | 449 |
| 450 // Only the shortcut to the third profile should exist. | 450 // Only the shortcut to the third profile should exist. |
| 451 ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 451 ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 452 ASSERT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 452 ASSERT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 453 ASSERT_FALSE(file_util::PathExists(non_profile_shortcut_path)); | 453 ASSERT_FALSE(base::PathExists(non_profile_shortcut_path)); |
| 454 ASSERT_TRUE(file_util::PathExists(profile_3_shortcut_path)); | 454 ASSERT_TRUE(base::PathExists(profile_3_shortcut_path)); |
| 455 | 455 |
| 456 // Delete the third profile and check that its shortcut is gone and no | 456 // Delete the third profile and check that its shortcut is gone and no |
| 457 // shortcuts have been re-created. | 457 // shortcuts have been re-created. |
| 458 profile_info_cache_->DeleteProfileFromCache(profile_3_path_); | 458 profile_info_cache_->DeleteProfileFromCache(profile_3_path_); |
| 459 RunPendingTasks(); | 459 RunPendingTasks(); |
| 460 ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 460 ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 461 ASSERT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 461 ASSERT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 462 ASSERT_FALSE(file_util::PathExists(profile_3_shortcut_path)); | 462 ASSERT_FALSE(base::PathExists(profile_3_shortcut_path)); |
| 463 ASSERT_FALSE(file_util::PathExists(non_profile_shortcut_path)); | 463 ASSERT_FALSE(base::PathExists(non_profile_shortcut_path)); |
| 464 } | 464 } |
| 465 | 465 |
| 466 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) { | 466 TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) { |
| 467 SetupAndCreateTwoShortcuts(FROM_HERE); | 467 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 468 | 468 |
| 469 // Delete one shortcut. | 469 // Delete one shortcut. |
| 470 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 470 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 471 RunPendingTasks(); | 471 RunPendingTasks(); |
| 472 | 472 |
| 473 // Verify that a default shortcut exists (no profile name/avatar). | 473 // Verify that a default shortcut exists (no profile name/avatar). |
| (...skipping 23 matching lines...) Expand all Loading... |
| 497 | 497 |
| 498 // Ensure that a new shortcut does not get made if the old one was renamed. | 498 // Ensure that a new shortcut does not get made if the old one was renamed. |
| 499 profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); | 499 profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); |
| 500 RunPendingTasks(); | 500 RunPendingTasks(); |
| 501 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); | 501 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); |
| 502 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 502 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 503 profile_2_path_); | 503 profile_2_path_); |
| 504 | 504 |
| 505 // Delete the renamed shortcut and try to create it again, which should work. | 505 // Delete the renamed shortcut and try to create it again, which should work. |
| 506 ASSERT_TRUE(base::Delete(profile_2_shortcut_path_2, false)); | 506 ASSERT_TRUE(base::Delete(profile_2_shortcut_path_2, false)); |
| 507 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_2)); | 507 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2)); |
| 508 profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); | 508 profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); |
| 509 RunPendingTasks(); | 509 RunPendingTasks(); |
| 510 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 510 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 511 } | 511 } |
| 512 | 512 |
| 513 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) { | 513 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) { |
| 514 SetupAndCreateTwoShortcuts(FROM_HERE); | 514 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 515 | 515 |
| 516 const base::FilePath profile_2_shortcut_path_1 = | 516 const base::FilePath profile_2_shortcut_path_1 = |
| 517 GetDefaultShortcutPathForProfile(profile_2_name_); | 517 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 518 const base::FilePath profile_2_shortcut_path_2 = | 518 const base::FilePath profile_2_shortcut_path_2 = |
| 519 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); | 519 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); |
| 520 // Make a copy of the shortcut. | 520 // Make a copy of the shortcut. |
| 521 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1, | 521 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1, |
| 522 profile_2_shortcut_path_2)); | 522 profile_2_shortcut_path_2)); |
| 523 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, | 523 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, |
| 524 profile_2_path_); | 524 profile_2_path_); |
| 525 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 525 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 526 profile_2_path_); | 526 profile_2_path_); |
| 527 | 527 |
| 528 // Also, copy the shortcut for the first user and ensure it gets preserved. | 528 // Also, copy the shortcut for the first user and ensure it gets preserved. |
| 529 const base::FilePath preserved_profile_1_shortcut_path = | 529 const base::FilePath preserved_profile_1_shortcut_path = |
| 530 GetUserShortcutsDirectory().Append(L"Preserved.lnk"); | 530 GetUserShortcutsDirectory().Append(L"Preserved.lnk"); |
| 531 ASSERT_TRUE(base::CopyFile( | 531 ASSERT_TRUE(base::CopyFile( |
| 532 GetDefaultShortcutPathForProfile(profile_1_name_), | 532 GetDefaultShortcutPathForProfile(profile_1_name_), |
| 533 preserved_profile_1_shortcut_path)); | 533 preserved_profile_1_shortcut_path)); |
| 534 EXPECT_TRUE(file_util::PathExists(preserved_profile_1_shortcut_path)); | 534 EXPECT_TRUE(base::PathExists(preserved_profile_1_shortcut_path)); |
| 535 | 535 |
| 536 // Delete the profile and ensure both shortcuts were also deleted. | 536 // Delete the profile and ensure both shortcuts were also deleted. |
| 537 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 537 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 538 RunPendingTasks(); | 538 RunPendingTasks(); |
| 539 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_1)); | 539 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1)); |
| 540 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_2)); | 540 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2)); |
| 541 ValidateNonProfileShortcutAtPath(FROM_HERE, | 541 ValidateNonProfileShortcutAtPath(FROM_HERE, |
| 542 preserved_profile_1_shortcut_path); | 542 preserved_profile_1_shortcut_path); |
| 543 } | 543 } |
| 544 | 544 |
| 545 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsAfterProfileRename) { | 545 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsAfterProfileRename) { |
| 546 SetupAndCreateTwoShortcuts(FROM_HERE); | 546 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 547 | 547 |
| 548 const base::FilePath profile_2_shortcut_path_1 = | 548 const base::FilePath profile_2_shortcut_path_1 = |
| 549 GetDefaultShortcutPathForProfile(profile_2_name_); | 549 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 550 const base::FilePath profile_2_shortcut_path_2 = | 550 const base::FilePath profile_2_shortcut_path_2 = |
| 551 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); | 551 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); |
| 552 // Make a copy of the shortcut. | 552 // Make a copy of the shortcut. |
| 553 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1, | 553 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1, |
| 554 profile_2_shortcut_path_2)); | 554 profile_2_shortcut_path_2)); |
| 555 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, | 555 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, |
| 556 profile_2_path_); | 556 profile_2_path_); |
| 557 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 557 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 558 profile_2_path_); | 558 profile_2_path_); |
| 559 | 559 |
| 560 // Now, rename the profile. | 560 // Now, rename the profile. |
| 561 const string16 new_profile_2_name = L"New profile"; | 561 const string16 new_profile_2_name = L"New profile"; |
| 562 RenameProfile(FROM_HERE, profile_2_path_, new_profile_2_name); | 562 RenameProfile(FROM_HERE, profile_2_path_, new_profile_2_name); |
| 563 | 563 |
| 564 // The original shortcut should be renamed but the copied shortcut should | 564 // The original shortcut should be renamed but the copied shortcut should |
| 565 // keep its name. | 565 // keep its name. |
| 566 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_1)); | 566 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1)); |
| 567 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 567 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 568 profile_2_path_); | 568 profile_2_path_); |
| 569 ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_); | 569 ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_); |
| 570 } | 570 } |
| 571 | 571 |
| 572 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { | 572 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { |
| 573 SetupDefaultProfileShortcut(FROM_HERE); | 573 SetupDefaultProfileShortcut(FROM_HERE); |
| 574 | 574 |
| 575 // Delete the shortcut that got created for this profile and instead make | 575 // Delete the shortcut that got created for this profile and instead make |
| 576 // a new one without any command-line flags. | 576 // a new one without any command-line flags. |
| 577 ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), | 577 ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), |
| 578 false)); | 578 false)); |
| 579 const base::FilePath regular_shortcut_path = | 579 const base::FilePath regular_shortcut_path = |
| 580 CreateRegularShortcutWithName(FROM_HERE, | 580 CreateRegularShortcutWithName(FROM_HERE, |
| 581 GetDistribution()->GetAppShortCutName()); | 581 GetDistribution()->GetAppShortCutName()); |
| 582 | 582 |
| 583 // Add another profile and check that the shortcut was replaced with | 583 // Add another profile and check that the shortcut was replaced with |
| 584 // a badged shortcut with the right command line for the profile | 584 // a badged shortcut with the right command line for the profile |
| 585 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 585 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 586 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); | 586 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); |
| 587 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 587 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
| 588 } | 588 } |
| 589 | 589 |
| 590 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { | 590 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { |
| 591 SetupDefaultProfileShortcut(FROM_HERE); | 591 SetupDefaultProfileShortcut(FROM_HERE); |
| 592 | 592 |
| 593 // Delete the shortcut that got created for this profile and instead make | 593 // Delete the shortcut that got created for this profile and instead make |
| 594 // two new ones without any command-line flags. | 594 // two new ones without any command-line flags. |
| 595 ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), | 595 ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), |
| 596 false)); | 596 false)); |
| 597 const base::FilePath regular_shortcut_path = | 597 const base::FilePath regular_shortcut_path = |
| 598 CreateRegularShortcutWithName(FROM_HERE, | 598 CreateRegularShortcutWithName(FROM_HERE, |
| 599 GetDistribution()->GetAppShortCutName()); | 599 GetDistribution()->GetAppShortCutName()); |
| 600 const base::FilePath customized_regular_shortcut_path = | 600 const base::FilePath customized_regular_shortcut_path = |
| 601 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); | 601 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); |
| 602 | 602 |
| 603 // Add another profile and check that one shortcut was renamed and that the | 603 // Add another profile and check that one shortcut was renamed and that the |
| 604 // other shortcut was updated but kept the same name. | 604 // other shortcut was updated but kept the same name. |
| 605 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 605 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 606 EXPECT_FALSE(file_util::PathExists(regular_shortcut_path)); | 606 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); |
| 607 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, | 607 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, |
| 608 profile_1_path_); | 608 profile_1_path_); |
| 609 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 609 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
| 610 } | 610 } |
| 611 | 611 |
| 612 TEST_F(ProfileShortcutManagerTest, RemoveProfileShortcuts) { | 612 TEST_F(ProfileShortcutManagerTest, RemoveProfileShortcuts) { |
| 613 SetupAndCreateTwoShortcuts(FROM_HERE); | 613 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 614 CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_); | 614 CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_); |
| 615 | 615 |
| 616 const base::FilePath profile_1_shortcut_path_1 = | 616 const base::FilePath profile_1_shortcut_path_1 = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 629 profile_2_shortcut_path_2)); | 629 profile_2_shortcut_path_2)); |
| 630 ValidateProfileShortcutAtPath(FROM_HERE, profile_1_shortcut_path_2, | 630 ValidateProfileShortcutAtPath(FROM_HERE, profile_1_shortcut_path_2, |
| 631 profile_1_path_); | 631 profile_1_path_); |
| 632 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 632 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 633 profile_2_path_); | 633 profile_2_path_); |
| 634 | 634 |
| 635 // Delete shortcuts for profile 1 and ensure that they got deleted while the | 635 // Delete shortcuts for profile 1 and ensure that they got deleted while the |
| 636 // shortcuts for profile 2 were kept. | 636 // shortcuts for profile 2 were kept. |
| 637 profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_); | 637 profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_); |
| 638 RunPendingTasks(); | 638 RunPendingTasks(); |
| 639 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path_1)); | 639 EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_1)); |
| 640 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path_2)); | 640 EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_2)); |
| 641 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, | 641 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, |
| 642 profile_2_path_); | 642 profile_2_path_); |
| 643 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, | 643 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, |
| 644 profile_2_path_); | 644 profile_2_path_); |
| 645 } | 645 } |
| 646 | 646 |
| 647 TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) { | 647 TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) { |
| 648 SetupAndCreateTwoShortcuts(FROM_HERE); | 648 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 649 | 649 |
| 650 struct HasShortcutsResult { | 650 struct HasShortcutsResult { |
| 651 bool has_shortcuts; | 651 bool has_shortcuts; |
| 652 void set_has_shortcuts(bool value) { has_shortcuts = value; } | 652 void set_has_shortcuts(bool value) { has_shortcuts = value; } |
| 653 } result = { false }; | 653 } result = { false }; |
| 654 | 654 |
| 655 const base::Callback<void(bool)> callback = | 655 const base::Callback<void(bool)> callback = |
| 656 base::Bind(&HasShortcutsResult::set_has_shortcuts, | 656 base::Bind(&HasShortcutsResult::set_has_shortcuts, |
| 657 base::Unretained(&result)); | 657 base::Unretained(&result)); |
| 658 | 658 |
| 659 // Profile 2 should have a shortcut initially. | 659 // Profile 2 should have a shortcut initially. |
| 660 profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); | 660 profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); |
| 661 RunPendingTasks(); | 661 RunPendingTasks(); |
| 662 EXPECT_TRUE(result.has_shortcuts); | 662 EXPECT_TRUE(result.has_shortcuts); |
| 663 | 663 |
| 664 // Delete the shortcut and check that the function returns false. | 664 // Delete the shortcut and check that the function returns false. |
| 665 const base::FilePath profile_2_shortcut_path = | 665 const base::FilePath profile_2_shortcut_path = |
| 666 GetDefaultShortcutPathForProfile(profile_2_name_); | 666 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 667 ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); | 667 ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); |
| 668 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 668 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 669 profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); | 669 profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); |
| 670 RunPendingTasks(); | 670 RunPendingTasks(); |
| 671 EXPECT_FALSE(result.has_shortcuts); | 671 EXPECT_FALSE(result.has_shortcuts); |
| 672 } | 672 } |
| 673 | 673 |
| 674 TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) { | 674 TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) { |
| 675 const base::FilePath system_level_shortcut_path = | 675 const base::FilePath system_level_shortcut_path = |
| 676 CreateRegularSystemLevelShortcut(FROM_HERE); | 676 CreateRegularSystemLevelShortcut(FROM_HERE); |
| 677 | 677 |
| 678 // Create the initial profile. | 678 // Create the initial profile. |
| 679 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, | 679 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, |
| 680 string16(), 0, false); | 680 string16(), 0, false); |
| 681 RunPendingTasks(); | 681 RunPendingTasks(); |
| 682 ASSERT_EQ(1U, profile_info_cache_->GetNumberOfProfiles()); | 682 ASSERT_EQ(1U, profile_info_cache_->GetNumberOfProfiles()); |
| 683 | 683 |
| 684 // Ensure system-level continues to exist and user-level was not created. | 684 // Ensure system-level continues to exist and user-level was not created. |
| 685 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 685 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
| 686 EXPECT_FALSE(file_util::PathExists( | 686 EXPECT_FALSE(base::PathExists( |
| 687 GetDefaultShortcutPathForProfile(string16()))); | 687 GetDefaultShortcutPathForProfile(string16()))); |
| 688 | 688 |
| 689 // Create another profile with a shortcut and ensure both profiles receive | 689 // Create another profile with a shortcut and ensure both profiles receive |
| 690 // user-level profile shortcuts and the system-level one still exists. | 690 // user-level profile shortcuts and the system-level one still exists. |
| 691 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 691 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 692 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 692 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
| 693 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 693 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 694 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 694 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
| 695 | 695 |
| 696 // Create a third profile without a shortcut and ensure it doesn't get one. | 696 // Create a third profile without a shortcut and ensure it doesn't get one. |
| 697 profile_info_cache_->AddProfileToCache(profile_3_path_, profile_3_name_, | 697 profile_info_cache_->AddProfileToCache(profile_3_path_, profile_3_name_, |
| 698 string16(), 0, false); | 698 string16(), 0, false); |
| 699 RunPendingTasks(); | 699 RunPendingTasks(); |
| 700 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); | 700 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
| 701 | 701 |
| 702 // Ensure that changing the avatar icon and the name does not result in a | 702 // Ensure that changing the avatar icon and the name does not result in a |
| 703 // shortcut being created. | 703 // shortcut being created. |
| 704 profile_info_cache_->SetAvatarIconOfProfileAtIndex( | 704 profile_info_cache_->SetAvatarIconOfProfileAtIndex( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 729 SetupAndCreateTwoShortcuts(FROM_HERE); | 729 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 730 | 730 |
| 731 const base::FilePath system_level_shortcut_path = | 731 const base::FilePath system_level_shortcut_path = |
| 732 CreateRegularSystemLevelShortcut(FROM_HERE); | 732 CreateRegularSystemLevelShortcut(FROM_HERE); |
| 733 | 733 |
| 734 // Delete a profile and verify that only the system-level shortcut still | 734 // Delete a profile and verify that only the system-level shortcut still |
| 735 // exists. | 735 // exists. |
| 736 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); | 736 profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
| 737 RunPendingTasks(); | 737 RunPendingTasks(); |
| 738 | 738 |
| 739 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 739 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
| 740 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(string16())); | 740 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(string16())); |
| 741 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)); | 741 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)); |
| 742 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); | 742 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); |
| 743 } | 743 } |
| 744 | 744 |
| 745 TEST_F(ProfileShortcutManagerTest, | 745 TEST_F(ProfileShortcutManagerTest, |
| 746 DeleteSecondToLastProfileWithShortcutWhenSystemLevelShortcutExists) { | 746 DeleteSecondToLastProfileWithShortcutWhenSystemLevelShortcutExists) { |
| 747 SetupAndCreateTwoShortcuts(FROM_HERE); | 747 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 748 | 748 |
| 749 const base::FilePath profile_1_shortcut_path = | 749 const base::FilePath profile_1_shortcut_path = |
| 750 GetDefaultShortcutPathForProfile(profile_1_name_); | 750 GetDefaultShortcutPathForProfile(profile_1_name_); |
| 751 const base::FilePath profile_2_shortcut_path = | 751 const base::FilePath profile_2_shortcut_path = |
| 752 GetDefaultShortcutPathForProfile(profile_2_name_); | 752 GetDefaultShortcutPathForProfile(profile_2_name_); |
| 753 | 753 |
| 754 // Delete the shortcut for the first profile, but keep the one for the 2nd. | 754 // Delete the shortcut for the first profile, but keep the one for the 2nd. |
| 755 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); | 755 ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); |
| 756 ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 756 ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 757 ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); | 757 ASSERT_TRUE(base::PathExists(profile_2_shortcut_path)); |
| 758 | 758 |
| 759 const base::FilePath system_level_shortcut_path = | 759 const base::FilePath system_level_shortcut_path = |
| 760 CreateRegularSystemLevelShortcut(FROM_HERE); | 760 CreateRegularSystemLevelShortcut(FROM_HERE); |
| 761 | 761 |
| 762 // Delete the profile that has a shortcut, which will exercise the non-profile | 762 // Delete the profile that has a shortcut, which will exercise the non-profile |
| 763 // shortcut creation path in |DeleteDesktopShortcutsAndIconFile()|, which is | 763 // shortcut creation path in |DeleteDesktopShortcutsAndIconFile()|, which is |
| 764 // not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test. | 764 // not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test. |
| 765 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 765 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 766 RunPendingTasks(); | 766 RunPendingTasks(); |
| 767 | 767 |
| 768 // Verify that only the system-level shortcut still exists. | 768 // Verify that only the system-level shortcut still exists. |
| 769 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 769 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
| 770 EXPECT_FALSE(file_util::PathExists( | 770 EXPECT_FALSE(base::PathExists( |
| 771 GetDefaultShortcutPathForProfile(string16()))); | 771 GetDefaultShortcutPathForProfile(string16()))); |
| 772 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 772 EXPECT_FALSE(base::PathExists(profile_1_shortcut_path)); |
| 773 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 773 EXPECT_FALSE(base::PathExists(profile_2_shortcut_path)); |
| 774 } | 774 } |
| OLD | NEW |