| 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 "chrome/installer/util/shell_util.h" | 5 #include "chrome/installer/util/shell_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 other_ico_ = temp_dir_.GetPath().Append(kOtherIco); | 73 other_ico_ = temp_dir_.GetPath().Append(kOtherIco); |
| 74 EXPECT_EQ(0, base::WriteFile(other_ico_, "", 0)); | 74 EXPECT_EQ(0, base::WriteFile(other_ico_, "", 0)); |
| 75 | 75 |
| 76 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); | 76 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); |
| 77 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); | 77 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); |
| 78 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); | 78 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); |
| 79 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir()); | 79 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir()); |
| 80 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); | 80 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); |
| 81 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); | 81 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); |
| 82 user_desktop_override_.reset( | 82 user_desktop_override_.reset(new base::ScopedPathOverride( |
| 83 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, | 83 base::DIR_USER_DESKTOP, fake_user_desktop_.GetPath())); |
| 84 fake_user_desktop_.path())); | 84 common_desktop_override_.reset(new base::ScopedPathOverride( |
| 85 common_desktop_override_.reset( | 85 base::DIR_COMMON_DESKTOP, fake_common_desktop_.GetPath())); |
| 86 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP, | 86 user_quick_launch_override_.reset(new base::ScopedPathOverride( |
| 87 fake_common_desktop_.path())); | 87 base::DIR_USER_QUICK_LAUNCH, fake_user_quick_launch_.GetPath())); |
| 88 user_quick_launch_override_.reset( | 88 start_menu_override_.reset(new base::ScopedPathOverride( |
| 89 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH, | 89 base::DIR_START_MENU, fake_start_menu_.GetPath())); |
| 90 fake_user_quick_launch_.path())); | 90 common_start_menu_override_.reset(new base::ScopedPathOverride( |
| 91 start_menu_override_.reset( | 91 base::DIR_COMMON_START_MENU, fake_common_start_menu_.GetPath())); |
| 92 new base::ScopedPathOverride(base::DIR_START_MENU, | |
| 93 fake_start_menu_.path())); | |
| 94 common_start_menu_override_.reset( | |
| 95 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU, | |
| 96 fake_common_start_menu_.path())); | |
| 97 | 92 |
| 98 base::FilePath icon_path; | 93 base::FilePath icon_path; |
| 99 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &icon_path); | 94 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &icon_path); |
| 100 test_properties_.set_target(chrome_exe_); | 95 test_properties_.set_target(chrome_exe_); |
| 101 test_properties_.set_arguments(L"--test --chrome"); | 96 test_properties_.set_arguments(L"--test --chrome"); |
| 102 test_properties_.set_description(L"Makes polar bears dance."); | 97 test_properties_.set_description(L"Makes polar bears dance."); |
| 103 test_properties_.set_icon(icon_path, 7); | 98 test_properties_.set_icon(icon_path, 7); |
| 104 test_properties_.set_app_id(L"Polar.Bear"); | 99 test_properties_.set_app_id(L"Polar.Bear"); |
| 105 } | 100 } |
| 106 | 101 |
| 107 // Returns the expected path of a test shortcut. Returns an empty FilePath on | 102 // Returns the expected path of a test shortcut. Returns an empty FilePath on |
| 108 // failure. | 103 // failure. |
| 109 base::FilePath GetExpectedShortcutPath( | 104 base::FilePath GetExpectedShortcutPath( |
| 110 ShellUtil::ShortcutLocation location, | 105 ShellUtil::ShortcutLocation location, |
| 111 BrowserDistribution* dist, | 106 BrowserDistribution* dist, |
| 112 const ShellUtil::ShortcutProperties& properties) { | 107 const ShellUtil::ShortcutProperties& properties) { |
| 113 base::FilePath expected_path; | 108 base::FilePath expected_path; |
| 114 switch (location) { | 109 switch (location) { |
| 115 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: | 110 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: |
| 116 expected_path = (properties.level == ShellUtil::CURRENT_USER) ? | 111 expected_path = (properties.level == ShellUtil::CURRENT_USER) |
| 117 fake_user_desktop_.path() : fake_common_desktop_.path(); | 112 ? fake_user_desktop_.GetPath() |
| 113 : fake_common_desktop_.GetPath(); |
| 118 break; | 114 break; |
| 119 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: | 115 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: |
| 120 expected_path = fake_user_quick_launch_.path(); | 116 expected_path = fake_user_quick_launch_.GetPath(); |
| 121 break; | 117 break; |
| 122 case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT: | 118 case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT: |
| 123 expected_path = (properties.level == ShellUtil::CURRENT_USER) ? | 119 expected_path = (properties.level == ShellUtil::CURRENT_USER) |
| 124 fake_start_menu_.path() : fake_common_start_menu_.path(); | 120 ? fake_start_menu_.GetPath() |
| 121 : fake_common_start_menu_.GetPath(); |
| 125 break; | 122 break; |
| 126 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED: | 123 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED: |
| 127 expected_path = (properties.level == ShellUtil::CURRENT_USER) ? | 124 expected_path = (properties.level == ShellUtil::CURRENT_USER) |
| 128 fake_start_menu_.path() : fake_common_start_menu_.path(); | 125 ? fake_start_menu_.GetPath() |
| 126 : fake_common_start_menu_.GetPath(); |
| 129 expected_path = expected_path.Append( | 127 expected_path = expected_path.Append( |
| 130 dist_->GetStartMenuShortcutSubfolder( | 128 dist_->GetStartMenuShortcutSubfolder( |
| 131 BrowserDistribution::SUBFOLDER_CHROME)); | 129 BrowserDistribution::SUBFOLDER_CHROME)); |
| 132 break; | 130 break; |
| 133 default: | 131 default: |
| 134 ADD_FAILURE() << "Unknown location"; | 132 ADD_FAILURE() << "Unknown location"; |
| 135 return base::FilePath(); | 133 return base::FilePath(); |
| 136 } | 134 } |
| 137 | 135 |
| 138 base::string16 shortcut_name = properties.has_shortcut_name() | 136 base::string16 shortcut_name = properties.has_shortcut_name() |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 base::FilePath other_ico_; | 212 base::FilePath other_ico_; |
| 215 }; | 213 }; |
| 216 | 214 |
| 217 } // namespace | 215 } // namespace |
| 218 | 216 |
| 219 TEST_F(ShellUtilShortcutTest, GetShortcutPath) { | 217 TEST_F(ShellUtilShortcutTest, GetShortcutPath) { |
| 220 base::FilePath path; | 218 base::FilePath path; |
| 221 | 219 |
| 222 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 220 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 223 ShellUtil::CURRENT_USER, &path); | 221 ShellUtil::CURRENT_USER, &path); |
| 224 EXPECT_EQ(fake_user_desktop_.path(), path); | 222 EXPECT_EQ(fake_user_desktop_.GetPath(), path); |
| 225 | 223 |
| 226 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 224 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 227 ShellUtil::SYSTEM_LEVEL, &path); | 225 ShellUtil::SYSTEM_LEVEL, &path); |
| 228 EXPECT_EQ(fake_common_desktop_.path(), path); | 226 EXPECT_EQ(fake_common_desktop_.GetPath(), path); |
| 229 | 227 |
| 230 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, | 228 ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist_, |
| 231 ShellUtil::CURRENT_USER, &path); | 229 ShellUtil::CURRENT_USER, &path); |
| 232 EXPECT_EQ(fake_user_quick_launch_.path(), path); | 230 EXPECT_EQ(fake_user_quick_launch_.GetPath(), path); |
| 233 | 231 |
| 234 base::string16 start_menu_subfolder = | 232 base::string16 start_menu_subfolder = |
| 235 dist_->GetStartMenuShortcutSubfolder( | 233 dist_->GetStartMenuShortcutSubfolder( |
| 236 BrowserDistribution::SUBFOLDER_CHROME); | 234 BrowserDistribution::SUBFOLDER_CHROME); |
| 237 ShellUtil::GetShortcutPath( | 235 ShellUtil::GetShortcutPath( |
| 238 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 236 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 239 dist_, ShellUtil::CURRENT_USER, &path); | 237 dist_, ShellUtil::CURRENT_USER, &path); |
| 240 EXPECT_EQ(fake_start_menu_.path().Append(start_menu_subfolder), | 238 EXPECT_EQ(fake_start_menu_.GetPath().Append(start_menu_subfolder), path); |
| 241 path); | |
| 242 | 239 |
| 243 ShellUtil::GetShortcutPath( | 240 ShellUtil::GetShortcutPath( |
| 244 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 241 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 245 dist_, ShellUtil::SYSTEM_LEVEL, &path); | 242 dist_, ShellUtil::SYSTEM_LEVEL, &path); |
| 246 EXPECT_EQ(fake_common_start_menu_.path().Append(start_menu_subfolder), | 243 EXPECT_EQ(fake_common_start_menu_.GetPath().Append(start_menu_subfolder), |
| 247 path); | 244 path); |
| 248 } | 245 } |
| 249 | 246 |
| 250 TEST_F(ShellUtilShortcutTest, MoveExistingShortcut) { | 247 TEST_F(ShellUtilShortcutTest, MoveExistingShortcut) { |
| 251 test_properties_.set_shortcut_name(L"Bobo le shortcut"); | 248 test_properties_.set_shortcut_name(L"Bobo le shortcut"); |
| 252 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 249 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 253 base::FilePath old_shortcut_path(GetExpectedShortcutPath( | 250 base::FilePath old_shortcut_path(GetExpectedShortcutPath( |
| 254 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 251 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 255 dist_, test_properties_)); | 252 dist_, test_properties_)); |
| 256 | 253 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 test_properties_); | 354 test_properties_); |
| 358 } | 355 } |
| 359 | 356 |
| 360 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { | 357 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { |
| 361 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); | 358 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); |
| 362 | 359 |
| 363 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 360 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 364 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 361 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 365 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 362 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 366 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 363 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 367 ASSERT_TRUE(base::PathExists( | 364 ASSERT_TRUE( |
| 368 fake_common_desktop_.path().Append(shortcut_name))); | 365 base::PathExists(fake_common_desktop_.GetPath().Append(shortcut_name))); |
| 369 | 366 |
| 370 test_properties_.level = ShellUtil::CURRENT_USER; | 367 test_properties_.level = ShellUtil::CURRENT_USER; |
| 371 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 368 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 372 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 369 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 373 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 370 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 374 ASSERT_FALSE(base::PathExists( | 371 ASSERT_FALSE( |
| 375 fake_user_desktop_.path().Append(shortcut_name))); | 372 base::PathExists(fake_user_desktop_.GetPath().Append(shortcut_name))); |
| 376 } | 373 } |
| 377 | 374 |
| 378 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { | 375 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { |
| 379 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 376 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 380 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 377 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 381 dist_, test_properties_, | 378 dist_, test_properties_, |
| 382 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 379 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 383 ValidateChromeShortcut( | 380 ValidateChromeShortcut( |
| 384 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 381 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 385 dist_, test_properties_); | 382 dist_, test_properties_); |
| 386 } | 383 } |
| 387 | 384 |
| 388 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { | 385 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { |
| 389 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); | 386 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); |
| 390 | 387 |
| 391 test_properties_.level = ShellUtil::SYSTEM_LEVEL; | 388 test_properties_.level = ShellUtil::SYSTEM_LEVEL; |
| 392 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 389 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 393 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 390 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 394 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 391 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 395 ASSERT_TRUE(base::PathExists( | 392 ASSERT_TRUE( |
| 396 fake_common_desktop_.path().Append(shortcut_name))); | 393 base::PathExists(fake_common_desktop_.GetPath().Append(shortcut_name))); |
| 397 | 394 |
| 398 test_properties_.level = ShellUtil::CURRENT_USER; | 395 test_properties_.level = ShellUtil::CURRENT_USER; |
| 399 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 396 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 400 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 397 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 401 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 398 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 402 ASSERT_TRUE(base::PathExists( | 399 ASSERT_TRUE( |
| 403 fake_user_desktop_.path().Append(shortcut_name))); | 400 base::PathExists(fake_user_desktop_.GetPath().Append(shortcut_name))); |
| 404 } | 401 } |
| 405 | 402 |
| 406 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { | 403 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { |
| 407 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 404 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 408 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 405 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 409 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 406 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 410 base::FilePath shortcut_path = GetExpectedShortcutPath( | 407 base::FilePath shortcut_path = GetExpectedShortcutPath( |
| 411 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_); | 408 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_); |
| 412 ASSERT_TRUE(base::PathExists(shortcut_path)); | 409 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 413 | 410 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 720 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 724 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, | 721 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR_DEPRECATED, |
| 725 dist_, test_properties_, | 722 dist_, test_properties_, |
| 726 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 723 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 727 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 724 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 728 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR, | 725 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR, |
| 729 dist_, test_properties_, | 726 dist_, test_properties_, |
| 730 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 727 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 731 | 728 |
| 732 base::FilePath chrome_shortcut_folder( | 729 base::FilePath chrome_shortcut_folder( |
| 733 fake_start_menu_.path().Append( | 730 fake_start_menu_.GetPath().Append(dist_->GetStartMenuShortcutSubfolder( |
| 734 dist_->GetStartMenuShortcutSubfolder( | 731 BrowserDistribution::SUBFOLDER_CHROME))); |
| 735 BrowserDistribution::SUBFOLDER_CHROME))); | |
| 736 base::FilePath chrome_apps_shortcut_folder( | 732 base::FilePath chrome_apps_shortcut_folder( |
| 737 fake_start_menu_.path().Append( | 733 fake_start_menu_.GetPath().Append(dist_->GetStartMenuShortcutSubfolder( |
| 738 dist_->GetStartMenuShortcutSubfolder( | 734 BrowserDistribution::SUBFOLDER_APPS))); |
| 739 BrowserDistribution::SUBFOLDER_APPS))); | |
| 740 | 735 |
| 741 base::FileEnumerator chrome_file_counter(chrome_shortcut_folder, false, | 736 base::FileEnumerator chrome_file_counter(chrome_shortcut_folder, false, |
| 742 base::FileEnumerator::FILES); | 737 base::FileEnumerator::FILES); |
| 743 int count = 0; | 738 int count = 0; |
| 744 while (!chrome_file_counter.Next().empty()) | 739 while (!chrome_file_counter.Next().empty()) |
| 745 ++count; | 740 ++count; |
| 746 EXPECT_EQ(2, count); | 741 EXPECT_EQ(2, count); |
| 747 | 742 |
| 748 base::FileEnumerator chrome_apps_file_counter(chrome_apps_shortcut_folder, | 743 base::FileEnumerator chrome_apps_file_counter(chrome_apps_shortcut_folder, |
| 749 false, | 744 false, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 768 | 763 |
| 769 TEST_F(ShellUtilShortcutTest, | 764 TEST_F(ShellUtilShortcutTest, |
| 770 DeleteStartMenuRootShortcutWithoutRemovingFolder) { | 765 DeleteStartMenuRootShortcutWithoutRemovingFolder) { |
| 771 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 766 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 772 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, | 767 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, |
| 773 dist_, test_properties_, | 768 dist_, test_properties_, |
| 774 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 769 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 775 | 770 |
| 776 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); | 771 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); |
| 777 base::FilePath shortcut_path( | 772 base::FilePath shortcut_path( |
| 778 fake_start_menu_.path().Append(shortcut_name)); | 773 fake_start_menu_.GetPath().Append(shortcut_name)); |
| 779 | 774 |
| 780 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); | 775 ASSERT_TRUE(base::PathExists(fake_start_menu_.GetPath())); |
| 781 ASSERT_TRUE(base::PathExists(shortcut_path)); | 776 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 782 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 777 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 783 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist_, | 778 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist_, |
| 784 ShellUtil::CURRENT_USER, chrome_exe_)); | 779 ShellUtil::CURRENT_USER, chrome_exe_)); |
| 785 // The shortcut should be removed but the "Start Menu" root directory should | 780 // The shortcut should be removed but the "Start Menu" root directory should |
| 786 // remain. | 781 // remain. |
| 787 ASSERT_TRUE(base::PathExists(fake_start_menu_.path())); | 782 ASSERT_TRUE(base::PathExists(fake_start_menu_.GetPath())); |
| 788 ASSERT_FALSE(base::PathExists(shortcut_path)); | 783 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 789 } | 784 } |
| 790 | 785 |
| 791 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { | 786 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { |
| 792 base::ScopedTempDir other_exe_dir; | 787 base::ScopedTempDir other_exe_dir; |
| 793 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); | 788 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); |
| 794 base::FilePath other_chrome_exe = | 789 base::FilePath other_chrome_exe = |
| 795 other_exe_dir.GetPath().Append(installer::kChromeExe); | 790 other_exe_dir.GetPath().Append(installer::kChromeExe); |
| 796 EXPECT_EQ(0, base::WriteFile(other_chrome_exe, "", 0)); | 791 EXPECT_EQ(0, base::WriteFile(other_chrome_exe, "", 0)); |
| 797 | 792 |
| 798 test_properties_.set_target(other_chrome_exe); | 793 test_properties_.set_target(other_chrome_exe); |
| 799 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 794 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 800 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, | 795 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_, |
| 801 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 796 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 802 | 797 |
| 803 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); | 798 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); |
| 804 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 799 base::FilePath shortcut_path( |
| 800 fake_user_desktop_.GetPath().Append(shortcut_name)); |
| 805 ASSERT_TRUE(base::PathExists(shortcut_path)); | 801 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 806 | 802 |
| 807 // The shortcut shouldn't be removed as it was installed pointing to | 803 // The shortcut shouldn't be removed as it was installed pointing to |
| 808 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the | 804 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the |
| 809 // removed shortcut should point to |chrome_exe_|. | 805 // removed shortcut should point to |chrome_exe_|. |
| 810 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 806 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 811 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 807 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 812 chrome_exe_)); | 808 chrome_exe_)); |
| 813 ASSERT_TRUE(base::PathExists(shortcut_path)); | 809 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 814 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); | 810 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); | 994 ASSERT_TRUE(ShellUtil::GetOldUserSpecificRegistrySuffix(&suffix)); |
| 999 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); | 995 ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE)); |
| 1000 | 996 |
| 1001 wchar_t user_name[256]; | 997 wchar_t user_name[256]; |
| 1002 DWORD size = arraysize(user_name); | 998 DWORD size = arraysize(user_name); |
| 1003 ASSERT_NE(0, ::GetUserName(user_name, &size)); | 999 ASSERT_NE(0, ::GetUserName(user_name, &size)); |
| 1004 ASSERT_GE(size, 1U); | 1000 ASSERT_GE(size, 1U); |
| 1005 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); | 1001 ASSERT_STREQ(user_name, suffix.substr(1).c_str()); |
| 1006 } | 1002 } |
| 1007 | 1003 |
| OLD | NEW |