| 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 686 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
| 687 EXPECT_FALSE(file_util::PathExists( | 687 EXPECT_FALSE(file_util::PathExists( |
| 688 GetDefaultShortcutPathForProfile(string16()))); | 688 GetDefaultShortcutPathForProfile(string16()))); |
| 689 | 689 |
| 690 // Create another profile with a shortcut and ensure both profiles receive | 690 // Create another profile with a shortcut and ensure both profiles receive |
| 691 // user-level profile shortcuts and the system-level one still exists. | 691 // user-level profile shortcuts and the system-level one still exists. |
| 692 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 692 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 693 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 693 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
| 694 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 694 ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
| 695 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 695 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
| 696 |
| 697 // Create a third profile without a shortcut and ensure it doesn't get one. |
| 698 profile_info_cache_->AddProfileToCache(profile_3_path_, profile_3_name_, |
| 699 string16(), 0, false); |
| 700 RunPendingTasks(); |
| 701 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
| 702 |
| 703 // Ensure that changing the avatar icon and the name does not result in a |
| 704 // shortcut being created. |
| 705 profile_info_cache_->SetAvatarIconOfProfileAtIndex( |
| 706 profile_info_cache_->GetIndexOfProfileWithPath(profile_3_path_), 3); |
| 707 RunPendingTasks(); |
| 708 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
| 709 |
| 710 const string16 new_profile_3_name = L"New Name 3"; |
| 711 profile_info_cache_->SetNameOfProfileAtIndex( |
| 712 profile_info_cache_->GetIndexOfProfileWithPath(profile_3_path_), |
| 713 new_profile_3_name); |
| 714 RunPendingTasks(); |
| 715 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
| 716 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_3_name)); |
| 717 |
| 718 // Rename the second profile and ensure its shortcut got renamed. |
| 719 const string16 new_profile_2_name = L"New Name 2"; |
| 720 profile_info_cache_->SetNameOfProfileAtIndex( |
| 721 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_), |
| 722 new_profile_2_name); |
| 723 RunPendingTasks(); |
| 724 EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name)); |
| 725 ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_); |
| 696 } | 726 } |
| 697 | 727 |
| 698 TEST_F(ProfileShortcutManagerTest, | 728 TEST_F(ProfileShortcutManagerTest, |
| 699 DeleteSecondToLastProfileWithSystemLevelShortcut) { | 729 DeleteSecondToLastProfileWithSystemLevelShortcut) { |
| 700 SetupAndCreateTwoShortcuts(FROM_HERE); | 730 SetupAndCreateTwoShortcuts(FROM_HERE); |
| 701 | 731 |
| 702 const base::FilePath system_level_shortcut_path = | 732 const base::FilePath system_level_shortcut_path = |
| 703 CreateRegularSystemLevelShortcut(FROM_HERE); | 733 CreateRegularSystemLevelShortcut(FROM_HERE); |
| 704 | 734 |
| 705 // Delete a profile and verify that only the system-level shortcut still | 735 // Delete a profile and verify that only the system-level shortcut still |
| (...skipping 30 matching lines...) Expand all Loading... |
| 736 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 766 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
| 737 RunPendingTasks(); | 767 RunPendingTasks(); |
| 738 | 768 |
| 739 // Verify that only the system-level shortcut still exists. | 769 // Verify that only the system-level shortcut still exists. |
| 740 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 770 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
| 741 EXPECT_FALSE(file_util::PathExists( | 771 EXPECT_FALSE(file_util::PathExists( |
| 742 GetDefaultShortcutPathForProfile(string16()))); | 772 GetDefaultShortcutPathForProfile(string16()))); |
| 743 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 773 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); |
| 744 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 774 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); |
| 745 } | 775 } |
| OLD | NEW |