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

Side by Side Diff: chrome/installer/setup/install_unittest.cc

Issue 2456853002: Remove shortcut path fixups introduced to repair breakages caused by r378802. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/util/install_util.h » ('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 "chrome/installer/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <objbase.h> 7 #include <objbase.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/path_service.h"
19 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
22 #include "base/test/scoped_path_override.h" 20 #include "base/test/scoped_path_override.h"
23 #include "base/test/test_shortcut_win.h" 21 #include "base/test/test_shortcut_win.h"
24 #include "base/version.h" 22 #include "base/version.h"
25 #include "base/win/shortcut.h" 23 #include "base/win/shortcut.h"
26 #include "chrome/installer/setup/install_worker.h" 24 #include "chrome/installer/setup/install_worker.h"
27 #include "chrome/installer/setup/setup_constants.h" 25 #include "chrome/installer/setup/setup_constants.h"
28 #include "chrome/installer/util/browser_distribution.h" 26 #include "chrome/installer/util/browser_distribution.h"
29 #include "chrome/installer/util/install_util.h" 27 #include "chrome/installer/util/install_util.h"
30 #include "chrome/installer/util/installer_state.h" 28 #include "chrome/installer/util/installer_state.h"
31 #include "chrome/installer/util/master_preferences.h" 29 #include "chrome/installer/util/master_preferences.h"
32 #include "chrome/installer/util/master_preferences_constants.h" 30 #include "chrome/installer/util/master_preferences_constants.h"
33 #include "chrome/installer/util/product.h" 31 #include "chrome/installer/util/product.h"
34 #include "chrome/installer/util/shell_util.h" 32 #include "chrome/installer/util/shell_util.h"
35 #include "chrome/installer/util/util_constants.h" 33 #include "chrome/installer/util/util_constants.h"
36 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
37 35
38 namespace { 36 namespace {
39 37
40 base::FilePath GetNormalizedFilePath(const base::FilePath& path) {
41 base::FilePath normalized_path;
42 EXPECT_TRUE(base::NormalizeFilePath(path, &normalized_path));
43 return normalized_path;
44 }
45
46 class CreateVisualElementsManifestTest : public testing::Test { 38 class CreateVisualElementsManifestTest : public testing::Test {
47 protected: 39 protected:
48 void SetUp() override { 40 void SetUp() override {
49 // Create a temp directory for testing. 41 // Create a temp directory for testing.
50 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 42 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
51 43
52 version_ = base::Version("0.0.0.0"); 44 version_ = base::Version("0.0.0.0");
53 45
54 version_dir_ = test_dir_.GetPath().AppendASCII(version_.GetString()); 46 version_dir_ = test_dir_.GetPath().AppendASCII(version_.GetString());
55 ASSERT_TRUE(base::CreateDirectory(version_dir_)); 47 ASSERT_TRUE(base::CreateDirectory(version_dir_));
(...skipping 15 matching lines...) Expand all
71 63
72 // The path to |test_dir_|\|version_|. 64 // The path to |test_dir_|\|version_|.
73 base::FilePath version_dir_; 65 base::FilePath version_dir_;
74 66
75 // The path to VisualElementsManifest.xml. 67 // The path to VisualElementsManifest.xml.
76 base::FilePath manifest_path_; 68 base::FilePath manifest_path_;
77 }; 69 };
78 70
79 class InstallShortcutTest : public testing::Test { 71 class InstallShortcutTest : public testing::Test {
80 protected: 72 protected:
81 struct UpdateShortcutsTestCase {
82 // Shortcut target path, relative to |temp_dir_|.
83 const base::FilePath::CharType* target_path;
84
85 // Shortcut icon path, relative to |temp_dir_|. Can be null to create a
86 // shortcut without an icon.
87 const base::FilePath::CharType* icon_path;
88
89 // Whether the shortcut's target path should be updated by
90 // UpdatePerUserShortcutsInLocation().
91 bool should_update;
92 };
93
94 void SetUp() override { 73 void SetUp() override {
95 EXPECT_EQ(S_OK, CoInitialize(NULL)); 74 EXPECT_EQ(S_OK, CoInitialize(NULL));
96 75
97 dist_ = BrowserDistribution::GetDistribution(); 76 dist_ = BrowserDistribution::GetDistribution();
98 ASSERT_TRUE(dist_ != NULL); 77 ASSERT_TRUE(dist_ != NULL);
99 product_.reset(new installer::Product(dist_)); 78 product_.reset(new installer::Product(dist_));
100 79
101 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 80 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
102 chrome_exe_ = temp_dir_.GetPath().Append(installer::kChromeExe); 81 chrome_exe_ = temp_dir_.GetPath().Append(installer::kChromeExe);
103 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0)); 82 EXPECT_EQ(0, base::WriteFile(chrome_exe_, "", 0));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 master_prefs += (i == 0 ? "\"" : ",\""); 162 master_prefs += (i == 0 ? "\"" : ",\"");
184 master_prefs += desired_prefs[i].pref_name; 163 master_prefs += desired_prefs[i].pref_name;
185 master_prefs += "\":"; 164 master_prefs += "\":";
186 master_prefs += desired_prefs[i].is_desired ? "true" : "false"; 165 master_prefs += desired_prefs[i].is_desired ? "true" : "false";
187 } 166 }
188 master_prefs += "}}"; 167 master_prefs += "}}";
189 168
190 return new installer::MasterPreferences(master_prefs); 169 return new installer::MasterPreferences(master_prefs);
191 } 170 }
192 171
193 // Creates the shortcuts defined by |test_cases|. Tries to update the target
194 // path of these shortcuts to |new_target_path_relative| using
195 // UpdatePerUserShortcutsInLocation(). Verifies that the right shortcuts have
196 // been updated.
197 void TestUpdateShortcuts(const UpdateShortcutsTestCase* test_cases,
198 size_t num_test_cases,
199 const base::FilePath& new_target_path_relative) {
200 // Create shortcuts.
201 for (size_t i = 0; i < num_test_cases; ++i) {
202 // Make sure that the target exists.
203 const base::FilePath target_path =
204 temp_dir_.GetPath().Append(test_cases[i].target_path);
205 if (!base::PathExists(target_path)) {
206 ASSERT_TRUE(base::CreateDirectory(target_path.DirName()));
207 base::File file(target_path, base::File::FLAG_CREATE_ALWAYS |
208 base::File::FLAG_WRITE);
209 ASSERT_TRUE(file.IsValid());
210 static const char kDummyData[] = "dummy";
211 ASSERT_EQ(arraysize(kDummyData),
212 static_cast<size_t>(file.WriteAtCurrentPos(
213 kDummyData, arraysize(kDummyData))));
214 }
215
216 // Create the shortcut.
217 base::win::ShortcutProperties properties;
218 properties.set_target(target_path);
219 properties.set_icon(temp_dir_.GetPath().Append(test_cases[i].icon_path),
220 1);
221 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
222 user_desktop_shortcut_.InsertBeforeExtension(
223 base::SizeTToString16(i)),
224 properties, base::win::SHORTCUT_CREATE_ALWAYS));
225 }
226
227 // Update shortcuts.
228 const base::FilePath new_target_path =
229 temp_dir_.GetPath().Append(new_target_path_relative);
230 installer::UpdatePerUserShortcutsInLocation(
231 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
232 new_target_path.DirName().DirName(), new_target_path.BaseName(),
233 new_target_path);
234
235 // Verify that shortcuts were updated correctly.
236 for (size_t i = 0; i < num_test_cases; ++i) {
237 base::FilePath target_path;
238 ASSERT_TRUE(base::win::ResolveShortcut(
239 user_desktop_shortcut_.InsertBeforeExtension(
240 base::SizeTToString16(i)),
241 &target_path, nullptr));
242
243 if (test_cases[i].should_update) {
244 EXPECT_EQ(GetNormalizedFilePath(new_target_path),
245 GetNormalizedFilePath(target_path));
246 } else {
247 EXPECT_EQ(GetNormalizedFilePath(
248 temp_dir_.GetPath().Append(test_cases[i].target_path)),
249 GetNormalizedFilePath(target_path));
250 }
251 }
252 }
253
254 base::win::ShortcutProperties expected_properties_; 172 base::win::ShortcutProperties expected_properties_;
255 base::win::ShortcutProperties expected_start_menu_properties_; 173 base::win::ShortcutProperties expected_start_menu_properties_;
256 174
257 BrowserDistribution* dist_; 175 BrowserDistribution* dist_;
258 base::FilePath chrome_exe_; 176 base::FilePath chrome_exe_;
259 std::unique_ptr<installer::Product> product_; 177 std::unique_ptr<installer::Product> product_;
260 std::unique_ptr<installer::MasterPreferences> prefs_; 178 std::unique_ptr<installer::MasterPreferences> prefs_;
261 179
262 base::ScopedTempDir temp_dir_; 180 base::ScopedTempDir temp_dir_;
263 base::ScopedTempDir fake_user_desktop_; 181 base::ScopedTempDir fake_user_desktop_;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 installer::CreateOrUpdateShortcuts( 452 installer::CreateOrUpdateShortcuts(
535 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 453 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
536 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); 454 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL);
537 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_)); 455 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_));
538 base::win::ValidateShortcut(user_quick_launch_shortcut_, 456 base::win::ValidateShortcut(user_quick_launch_shortcut_,
539 expected_properties_); 457 expected_properties_);
540 base::win::ValidateShortcut(user_start_menu_shortcut_, 458 base::win::ValidateShortcut(user_start_menu_shortcut_,
541 expected_start_menu_properties_); 459 expected_start_menu_properties_);
542 } 460 }
543 461
544 TEST_F(InstallShortcutTest, UpdatePerUserChromeUserLevelShortcuts) {
545 static const UpdateShortcutsTestCase kTestCases[] = {
546 // Shortcut target in the Chrome Canary install directory. No icon.
547 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
548 "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
549 nullptr, false},
550 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
551 "SxS\\Temp\\scoped_dir\\chrome.exe"),
552 nullptr, false},
553 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
554 "SxS\\Application\\chrome.exe"),
555 nullptr, false},
556 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
557 "SxS\\Application\\something_else.exe"),
558 nullptr, false},
559
560 // Shortcut target in the user-level Chrome install directory. No icon.
561 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
562 "d_dir\\new_chrome.exe"),
563 nullptr, true},
564 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
565 "d_dir\\chrome.exe"),
566 nullptr, true},
567 {FILE_PATH_LITERAL(
568 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
569 nullptr, true},
570 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
571 "\\something_else.exe"),
572 nullptr, false},
573
574 // Shortcut target in the system-level Chrome install directory. No icon.
575 {FILE_PATH_LITERAL("Program Files "
576 "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
577 "exe"),
578 nullptr, false},
579 {FILE_PATH_LITERAL(
580 "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
581 nullptr, false},
582 {FILE_PATH_LITERAL(
583 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
584 nullptr, false},
585 {FILE_PATH_LITERAL("Program Files "
586 "(x86)\\Google\\Chrome\\Application\\something_else."
587 "exe"),
588 nullptr, false},
589
590 // Dummy shortcut target. Icon in the Chrome Canary install directory.
591 {FILE_PATH_LITERAL("dummy.exe"),
592 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
593 "SxS\\Application\\chrome.exe"),
594 false},
595 {FILE_PATH_LITERAL("dummy.exe"),
596 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
597 "SxS\\Application\\User Data\\Profile 1\\Google "
598 "Profile.ico"),
599 false},
600
601 // Dummy shortcut target. Icon in the user-level Chrome install directory.
602 {FILE_PATH_LITERAL("dummy.exe"),
603 FILE_PATH_LITERAL(
604 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
605 true},
606 {FILE_PATH_LITERAL("dummy.exe"),
607 FILE_PATH_LITERAL(
608 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
609 "Data\\Profile 1\\Google Profile.ico"),
610 true},
611
612 // Dummy shortcut target. Icon in the system-level Chrome install
613 // directory.
614 {FILE_PATH_LITERAL("dummy.exe"),
615 FILE_PATH_LITERAL(
616 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
617 false},
618
619 // Shortcuts that don't belong to Chrome.
620 {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
621 {FILE_PATH_LITERAL("something_else.exe"),
622 FILE_PATH_LITERAL(
623 "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
624 false},
625 };
626
627 TestUpdateShortcuts(
628 kTestCases, arraysize(kTestCases),
629 base::FilePath(FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrom"
630 "e\\Application\\chrome.exe")));
631 }
632
633 TEST_F(InstallShortcutTest, UpdatePerUserCanaryShortcuts) {
634 static const UpdateShortcutsTestCase kTestCases[] = {
635 // Shortcut target in the Chrome Canary install directory. No icon.
636 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
637 "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
638 nullptr, true},
639 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
640 "SxS\\Temp\\scoped_dir\\chrome.exe"),
641 nullptr, true},
642 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
643 "SxS\\Application\\chrome.exe"),
644 nullptr, true},
645 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
646 "SxS\\Application\\something_else.exe"),
647 nullptr, false},
648
649 // Shortcut target in the user-level Chrome install directory. No icon.
650 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
651 "d_dir\\new_chrome.exe"),
652 nullptr, false},
653 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
654 "d_dir\\chrome.exe"),
655 nullptr, false},
656 {FILE_PATH_LITERAL(
657 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
658 nullptr, false},
659 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
660 "\\something_else.exe"),
661 nullptr, false},
662
663 // Shortcut target in the system-level Chrome install directory. No icon.
664 {FILE_PATH_LITERAL("Program Files "
665 "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
666 "exe"),
667 nullptr, false},
668 {FILE_PATH_LITERAL(
669 "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
670 nullptr, false},
671 {FILE_PATH_LITERAL(
672 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
673 nullptr, false},
674 {FILE_PATH_LITERAL("Program Files "
675 "(x86)\\Google\\Chrome\\Application\\something_else."
676 "exe"),
677 nullptr, false},
678
679 // Dummy shortcut target. Icon in the Chrome Canary install directory.
680 {FILE_PATH_LITERAL("dummy.exe"),
681 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
682 "SxS\\Application\\chrome.exe"),
683 true},
684 {FILE_PATH_LITERAL("dummy.exe"),
685 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
686 "SxS\\Application\\User Data\\Profile 1\\Google "
687 "Profile.ico"),
688 true},
689
690 // Dummy shortcut target. Icon in the user-level Chrome install directory.
691 {FILE_PATH_LITERAL("dummy.exe"),
692 FILE_PATH_LITERAL(
693 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
694 false},
695 {FILE_PATH_LITERAL("dummy.exe"),
696 FILE_PATH_LITERAL(
697 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
698 "Data\\Profile 1\\Google Profile.ico"),
699 false},
700
701 // Dummy shortcut target. Icon in the system-level Chrome install
702 // directory.
703 {FILE_PATH_LITERAL("dummy.exe"),
704 FILE_PATH_LITERAL(
705 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
706 false},
707
708 // Shortcuts that don't belong to Chrome.
709 {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
710 {FILE_PATH_LITERAL("something_else.exe"),
711 FILE_PATH_LITERAL(
712 "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
713 false},
714 };
715
716 TestUpdateShortcuts(
717 kTestCases, arraysize(kTestCases),
718 base::FilePath(FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrom"
719 "e SxS\\Application\\chrome.exe")));
720 }
721
722 TEST_F(InstallShortcutTest, UpdatePerUserChromeSystemLevelShortcuts) {
723 static const UpdateShortcutsTestCase kTestCases[] = {
724 // Shortcut target in the Chrome Canary install directory. No icon.
725 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
726 "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
727 nullptr, false},
728 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
729 "SxS\\Temp\\scoped_dir\\chrome.exe"),
730 nullptr, false},
731 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
732 "SxS\\Application\\chrome.exe"),
733 nullptr, false},
734 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
735 "SxS\\Application\\something_else.exe"),
736 nullptr, false},
737
738 // Shortcut target in the user-level Chrome install directory. No icon.
739 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
740 "d_dir\\new_chrome.exe"),
741 nullptr, false},
742 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
743 "d_dir\\chrome.exe"),
744 nullptr, false},
745 {FILE_PATH_LITERAL(
746 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
747 nullptr, false},
748 {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
749 "\\something_else.exe"),
750 nullptr, false},
751
752 // Shortcut target in the system-level Chrome install directory. No icon.
753 {FILE_PATH_LITERAL("Program Files "
754 "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
755 "exe"),
756 nullptr, true},
757 {FILE_PATH_LITERAL(
758 "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
759 nullptr, true},
760 {FILE_PATH_LITERAL(
761 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
762 nullptr, true},
763 {FILE_PATH_LITERAL("Program Files "
764 "(x86)\\Google\\Chrome\\Application\\something_else."
765 "exe"),
766 nullptr, false},
767
768 // Dummy shortcut target. Icon in the Chrome Canary install directory.
769 {FILE_PATH_LITERAL("dummy.exe"),
770 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
771 "SxS\\Application\\chrome.exe"),
772 false},
773 {FILE_PATH_LITERAL("dummy.exe"),
774 FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
775 "SxS\\Application\\User Data\\Profile 1\\Google "
776 "Profile.ico"),
777 false},
778
779 // Dummy shortcut target. Icon in the user-level Chrome install directory.
780 {FILE_PATH_LITERAL("dummy.exe"),
781 FILE_PATH_LITERAL(
782 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
783 false},
784 {FILE_PATH_LITERAL("dummy.exe"),
785 FILE_PATH_LITERAL(
786 "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
787 "Data\\Profile 1\\Google Profile.ico"),
788 false},
789
790 // Dummy shortcut target. Icon in the system-level Chrome install
791 // directory.
792 {FILE_PATH_LITERAL("dummy.exe"),
793 FILE_PATH_LITERAL(
794 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
795 true},
796
797 // Shortcuts that don't belong to Chrome.
798 {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
799 {FILE_PATH_LITERAL("something_else.exe"),
800 FILE_PATH_LITERAL(
801 "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
802 false},
803 };
804
805 TestUpdateShortcuts(
806 kTestCases, arraysize(kTestCases),
807 base::FilePath(FILE_PATH_LITERAL(
808 "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")));
809 }
810
811 TEST(EscapeXmlAttributeValueTest, EscapeCrazyValue) { 462 TEST(EscapeXmlAttributeValueTest, EscapeCrazyValue) {
812 base::string16 val(L"This has 'crazy' \"chars\" && < and > signs."); 463 base::string16 val(L"This has 'crazy' \"chars\" && < and > signs.");
813 static const wchar_t kExpectedEscapedVal[] = 464 static const wchar_t kExpectedEscapedVal[] =
814 L"This has &apos;crazy&apos; \"chars\" &amp;&amp; &lt; and > signs."; 465 L"This has &apos;crazy&apos; \"chars\" &amp;&amp; &lt; and > signs.";
815 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 466 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
816 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 467 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
817 } 468 }
818 469
819 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { 470 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
820 base::string16 val(L"Google Chrome"); 471 base::string16 val(L"Google Chrome");
821 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; 472 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
822 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 473 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
823 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 474 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
824 } 475 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/util/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698