Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc

Issue 15986006: Don't create an unbadged shortcut when first profile is created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 file_util::CreateDirectoryW(profile_path); 84 file_util::CreateDirectoryW(profile_path);
85 return profile_path; 85 return profile_path;
86 } 86 }
87 87
88 void RunPendingTasks() { 88 void RunPendingTasks() {
89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
90 MessageLoop::current()->Run(); 90 MessageLoop::current()->Run();
91 } 91 }
92 92
93 void SetupDefaultProfileShortcut(const tracked_objects::Location& location) { 93 void SetupDefaultProfileShortcut(const tracked_objects::Location& location) {
94 ASSERT_EQ(0, profile_info_cache_->GetNumberOfProfiles())
95 << location.ToString();
94 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)) 96 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_))
95 << location.ToString(); 97 << location.ToString();
96 // A non-badged shortcut for chrome is automatically created with the
97 // first profile (for the case when the user deletes their only profile).
98 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, 98 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_,
99 string16(), 0, false); 99 string16(), 0, false);
100 // Also create a non-badged shortcut for Chrome, which is conveniently done
101 // by |CreateProfileShortcut()| since there is only one profile.
102 profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_);
100 RunPendingTasks(); 103 RunPendingTasks();
101 // We now have 1 profile, so we expect a new shortcut with no profile 104 // Verify that there's now a shortcut with no profile information.
102 // information.
103 ValidateNonProfileShortcut(location); 105 ValidateNonProfileShortcut(location);
104 } 106 }
105 107
106 void SetupAndCreateTwoShortcuts(const tracked_objects::Location& location) { 108 void SetupAndCreateTwoShortcuts(const tracked_objects::Location& location) {
107 ASSERT_EQ(0, profile_info_cache_->GetNumberOfProfiles()) 109 SetupDefaultProfileShortcut(location);
108 << location.ToString();
109 ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_))
110 << location.ToString();
111
112 profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_,
113 string16(), 0, false);
114 CreateProfileWithShortcut(location, profile_2_name_, profile_2_path_); 110 CreateProfileWithShortcut(location, profile_2_name_, profile_2_path_);
115 ValidateProfileShortcut(location, profile_1_name_, profile_1_path_); 111 ValidateProfileShortcut(location, profile_1_name_, profile_1_path_);
116 } 112 }
117 113
118 // Returns the default shortcut path for this profile. 114 // Returns the default shortcut path for this profile.
119 base::FilePath GetDefaultShortcutPathForProfile( 115 base::FilePath GetDefaultShortcutPathForProfile(
120 const string16& profile_name) { 116 const string16& profile_name) {
121 return GetUserShortcutsDirectory().Append( 117 return GetUserShortcutsDirectory().Append(
122 profiles::internal::GetShortcutFilenameForProfile(profile_name, 118 profiles::internal::GetShortcutFilenameForProfile(profile_name,
123 GetDistribution())); 119 GetDistribution()));
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); 765 profile_info_cache_->DeleteProfileFromCache(profile_2_path_);
770 RunPendingTasks(); 766 RunPendingTasks();
771 767
772 // Verify that only the system-level shortcut still exists. 768 // Verify that only the system-level shortcut still exists.
773 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); 769 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path));
774 EXPECT_FALSE(file_util::PathExists( 770 EXPECT_FALSE(file_util::PathExists(
775 GetDefaultShortcutPathForProfile(string16()))); 771 GetDefaultShortcutPathForProfile(string16())));
776 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); 772 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path));
777 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); 773 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path));
778 } 774 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698