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 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 GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name | |
228 + installer::kLnkExt); | |
gab
2013/05/24 15:01:35
'+' on previous line
and indent 4 spaces in
calamity
2013/05/31 00:11:18
Done.
| |
227 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)) | 229 EXPECT_TRUE(file_util::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->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name |
317 + installer::kLnkExt; | |
gab
2013/05/24 15:01:35
'+' on previous line
+indent 4 spaces in.
calamity
2013/05/31 00:11:18
Done.
| |
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->GetShortcutInfo(BrowserDistribution::SHORTCUT_CHROME).name |
324 distribution)); | 327 + installer::kLnkExt, |
gab
2013/05/24 15:01:35
nit: '+' on previous line
calamity
2013/05/31 00:11:18
Done.
| |
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(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), | 583 ASSERT_TRUE(file_util::Delete(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()->GetShortcutInfo( |
588 BrowserDistribution::SHORTCUT_CHROME).name); | |
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(file_util::PathExists(regular_shortcut_path)); | 593 EXPECT_FALSE(file_util::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(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), | 602 ASSERT_TRUE(file_util::Delete(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()->GetShortcutInfo( |
607 BrowserDistribution::SHORTCUT_CHROME).name); | |
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(file_util::PathExists(regular_shortcut_path)); | 614 EXPECT_FALSE(file_util::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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 773 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
767 RunPendingTasks(); | 774 RunPendingTasks(); |
768 | 775 |
769 // Verify that only the system-level shortcut still exists. | 776 // Verify that only the system-level shortcut still exists. |
770 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); | 777 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); |
771 EXPECT_FALSE(file_util::PathExists( | 778 EXPECT_FALSE(file_util::PathExists( |
772 GetDefaultShortcutPathForProfile(string16()))); | 779 GetDefaultShortcutPathForProfile(string16()))); |
773 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 780 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); |
774 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 781 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); |
775 } | 782 } |
OLD | NEW |