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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 const tracked_objects::Location& location) { | 216 const tracked_objects::Location& location) { |
217 BrowserDistribution* distribution = GetDistribution(); | 217 BrowserDistribution* distribution = GetDistribution(); |
218 installer::Product product(distribution); | 218 installer::Product product(distribution); |
219 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); | 219 ShellUtil::ShortcutProperties properties(ShellUtil::SYSTEM_LEVEL); |
220 product.AddDefaultShortcutProperties(GetExePath(), &properties); | 220 product.AddDefaultShortcutProperties(GetExePath(), &properties); |
221 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 221 EXPECT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
222 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, | 222 ShellUtil::SHORTCUT_LOCATION_DESKTOP, distribution, properties, |
223 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); | 223 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)) << location.ToString(); |
224 const base::FilePath system_level_shortcut_path = | 224 const base::FilePath system_level_shortcut_path = |
225 GetSystemShortcutsDirectory().Append( | 225 GetSystemShortcutsDirectory().Append( |
226 distribution->GetAppShortCutName() + installer::kLnkExt); | 226 distribution-> |
| 227 GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 228 installer::kLnkExt); |
227 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)) | 229 EXPECT_TRUE(base::PathExists(system_level_shortcut_path)) |
228 << location.ToString(); | 230 << location.ToString(); |
229 return system_level_shortcut_path; | 231 return system_level_shortcut_path; |
230 } | 232 } |
231 | 233 |
232 void RenameProfile(const tracked_objects::Location& location, | 234 void RenameProfile(const tracked_objects::Location& location, |
233 const base::FilePath& profile_path, | 235 const base::FilePath& profile_path, |
234 const string16& new_profile_name) { | 236 const string16& new_profile_name) { |
235 const size_t profile_index = | 237 const size_t profile_index = |
236 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); | 238 profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 profiles::internal::GetShortcutFilenameForProfile(kLongProfileName, | 306 profiles::internal::GetShortcutFilenameForProfile(kLongProfileName, |
305 GetDistribution()); | 307 GetDistribution()); |
306 EXPECT_LT(file_name.size(), kLongProfileName.size()); | 308 EXPECT_LT(file_name.size(), kLongProfileName.size()); |
307 } | 309 } |
308 | 310 |
309 TEST_F(ProfileShortcutManagerTest, ShortcutFilenameStripsReservedCharacters) { | 311 TEST_F(ProfileShortcutManagerTest, ShortcutFilenameStripsReservedCharacters) { |
310 const string16 kProfileName = L"<Harry/>"; | 312 const string16 kProfileName = L"<Harry/>"; |
311 const string16 kSanitizedProfileName = L"Harry"; | 313 const string16 kSanitizedProfileName = L"Harry"; |
312 BrowserDistribution* distribution = GetDistribution(); | 314 BrowserDistribution* distribution = GetDistribution(); |
313 const string16 expected_name = kSanitizedProfileName + L" - " + | 315 const string16 expected_name = kSanitizedProfileName + L" - " + |
314 distribution->GetAppShortCutName() + installer::kLnkExt; | 316 distribution->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
| 317 installer::kLnkExt; |
315 EXPECT_EQ(expected_name, | 318 EXPECT_EQ(expected_name, |
316 profiles::internal::GetShortcutFilenameForProfile(kProfileName, | 319 profiles::internal::GetShortcutFilenameForProfile(kProfileName, |
317 distribution)); | 320 distribution)); |
318 } | 321 } |
319 | 322 |
320 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { | 323 TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { |
321 BrowserDistribution* distribution = GetDistribution(); | 324 BrowserDistribution* distribution = GetDistribution(); |
322 EXPECT_EQ(distribution->GetAppShortCutName() + installer::kLnkExt, | 325 EXPECT_EQ( |
323 profiles::internal::GetShortcutFilenameForProfile(string16(), | 326 distribution->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
324 distribution)); | 327 installer::kLnkExt, |
| 328 profiles::internal::GetShortcutFilenameForProfile(string16(), |
| 329 distribution)); |
325 } | 330 } |
326 | 331 |
327 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { | 332 TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { |
328 const string16 kProfileName = L"MyProfileX"; | 333 const string16 kProfileName = L"MyProfileX"; |
329 const base::FilePath profile_path = | 334 const base::FilePath profile_path = |
330 profile_info_cache_->GetUserDataDir().Append(kProfileName); | 335 profile_info_cache_->GetUserDataDir().Append(kProfileName); |
331 EXPECT_EQ(L"--profile-directory=\"" + kProfileName + L"\"", | 336 EXPECT_EQ(L"--profile-directory=\"" + kProfileName + L"\"", |
332 profiles::internal::CreateProfileShortcutFlags(profile_path)); | 337 profiles::internal::CreateProfileShortcutFlags(profile_path)); |
333 } | 338 } |
334 | 339 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 577 |
573 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { | 578 TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { |
574 SetupDefaultProfileShortcut(FROM_HERE); | 579 SetupDefaultProfileShortcut(FROM_HERE); |
575 | 580 |
576 // Delete the shortcut that got created for this profile and instead make | 581 // Delete the shortcut that got created for this profile and instead make |
577 // a new one without any command-line flags. | 582 // a new one without any command-line flags. |
578 ASSERT_TRUE(base::DeleteFile(GetDefaultShortcutPathForProfile(string16()), | 583 ASSERT_TRUE(base::DeleteFile(GetDefaultShortcutPathForProfile(string16()), |
579 false)); | 584 false)); |
580 const base::FilePath regular_shortcut_path = | 585 const base::FilePath regular_shortcut_path = |
581 CreateRegularShortcutWithName(FROM_HERE, | 586 CreateRegularShortcutWithName(FROM_HERE, |
582 GetDistribution()->GetAppShortCutName()); | 587 GetDistribution()->GetShortcutName( |
| 588 BrowserDistribution::SHORTCUT_CHROME)); |
583 | 589 |
584 // Add another profile and check that the shortcut was replaced with | 590 // Add another profile and check that the shortcut was replaced with |
585 // a badged shortcut with the right command line for the profile | 591 // a badged shortcut with the right command line for the profile |
586 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 592 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
587 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); | 593 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); |
588 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 594 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
589 } | 595 } |
590 | 596 |
591 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { | 597 TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { |
592 SetupDefaultProfileShortcut(FROM_HERE); | 598 SetupDefaultProfileShortcut(FROM_HERE); |
593 | 599 |
594 // Delete the shortcut that got created for this profile and instead make | 600 // Delete the shortcut that got created for this profile and instead make |
595 // two new ones without any command-line flags. | 601 // two new ones without any command-line flags. |
596 ASSERT_TRUE(base::DeleteFile(GetDefaultShortcutPathForProfile(string16()), | 602 ASSERT_TRUE(base::DeleteFile(GetDefaultShortcutPathForProfile(string16()), |
597 false)); | 603 false)); |
598 const base::FilePath regular_shortcut_path = | 604 const base::FilePath regular_shortcut_path = |
599 CreateRegularShortcutWithName(FROM_HERE, | 605 CreateRegularShortcutWithName(FROM_HERE, |
600 GetDistribution()->GetAppShortCutName()); | 606 GetDistribution()->GetShortcutName( |
| 607 BrowserDistribution::SHORTCUT_CHROME)); |
601 const base::FilePath customized_regular_shortcut_path = | 608 const base::FilePath customized_regular_shortcut_path = |
602 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); | 609 CreateRegularShortcutWithName(FROM_HERE, L"MyChrome"); |
603 | 610 |
604 // Add another profile and check that one shortcut was renamed and that the | 611 // Add another profile and check that one shortcut was renamed and that the |
605 // other shortcut was updated but kept the same name. | 612 // other shortcut was updated but kept the same name. |
606 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 613 CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); |
607 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); | 614 EXPECT_FALSE(base::PathExists(regular_shortcut_path)); |
608 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, | 615 ValidateProfileShortcutAtPath(FROM_HERE, customized_regular_shortcut_path, |
609 profile_1_path_); | 616 profile_1_path_); |
610 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); | 617 ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); | 865 EXPECT_NE(unbadged_icon_1, new_badged_icon_1); |
859 | 866 |
860 // Ensure the icon doesn't change on avatar change without 2 profiles. | 867 // Ensure the icon doesn't change on avatar change without 2 profiles. |
861 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 868 profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
862 RunPendingTasks(); | 869 RunPendingTasks(); |
863 | 870 |
864 std::string unbadged_icon_1_a; | 871 std::string unbadged_icon_1_a; |
865 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); | 872 EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); |
866 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); | 873 EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); |
867 } | 874 } |
OLD | NEW |