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> | 5 #include <objbase.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 installer::kLnkExt); | 119 installer::kLnkExt); |
120 base::string16 alternate_shortcut_name( | 120 base::string16 alternate_shortcut_name( |
121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + | 121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + |
122 installer::kLnkExt); | 122 installer::kLnkExt); |
123 | 123 |
124 user_desktop_shortcut_ = | 124 user_desktop_shortcut_ = |
125 fake_user_desktop_.path().Append(shortcut_name); | 125 fake_user_desktop_.path().Append(shortcut_name); |
126 user_quick_launch_shortcut_ = | 126 user_quick_launch_shortcut_ = |
127 fake_user_quick_launch_.path().Append(shortcut_name); | 127 fake_user_quick_launch_.path().Append(shortcut_name); |
128 user_start_menu_shortcut_ = | 128 user_start_menu_shortcut_ = |
129 fake_start_menu_.path().Append(shortcut_name); | |
130 user_start_menu_subdir_shortcut_ = | |
129 fake_start_menu_.path().Append( | 131 fake_start_menu_.path().Append( |
130 dist_->GetStartMenuShortcutSubfolder( | 132 dist_->GetStartMenuShortcutSubfolder( |
131 BrowserDistribution::SUBFOLDER_CHROME)) | 133 BrowserDistribution::SUBFOLDER_CHROME)) |
132 .Append(shortcut_name); | 134 .Append(shortcut_name); |
133 system_desktop_shortcut_ = | 135 system_desktop_shortcut_ = |
134 fake_common_desktop_.path().Append(shortcut_name); | 136 fake_common_desktop_.path().Append(shortcut_name); |
135 system_start_menu_shortcut_ = | 137 system_start_menu_shortcut_ = |
136 fake_common_start_menu_.path().Append( | 138 fake_common_start_menu_.path().Append(shortcut_name); |
137 dist_->GetStartMenuShortcutSubfolder( | |
138 BrowserDistribution::SUBFOLDER_CHROME)) | |
139 .Append(shortcut_name); | |
140 user_alternate_desktop_shortcut_ = | 139 user_alternate_desktop_shortcut_ = |
141 fake_user_desktop_.path().Append(alternate_shortcut_name); | 140 fake_user_desktop_.path().Append(alternate_shortcut_name); |
142 } | 141 } |
143 | 142 |
144 void TearDown() override { | 143 void TearDown() override { |
145 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, | 144 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, |
146 // the call itself might still have pinned the Start Menu shortcuts). | 145 // the call itself might still have pinned the Start Menu shortcuts). |
147 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_); | 146 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_); |
148 base::win::UnpinShortcutFromTaskbar(system_start_menu_shortcut_); | 147 base::win::UnpinShortcutFromTaskbar(system_start_menu_shortcut_); |
149 base::win::UnpinShortcutFromStart(user_start_menu_shortcut_); | 148 base::win::UnpinShortcutFromStart(user_start_menu_shortcut_); |
149 base::win::UnpinShortcutFromStart(user_start_menu_subdir_shortcut_); | |
150 base::win::UnpinShortcutFromStart(system_start_menu_shortcut_); | 150 base::win::UnpinShortcutFromStart(system_start_menu_shortcut_); |
151 CoUninitialize(); | 151 CoUninitialize(); |
152 } | 152 } |
153 | 153 |
154 installer::MasterPreferences* GetFakeMasterPrefs( | 154 installer::MasterPreferences* GetFakeMasterPrefs( |
155 bool do_not_create_desktop_shortcut, | 155 bool do_not_create_desktop_shortcut, |
156 bool do_not_create_quick_launch_shortcut, | 156 bool do_not_create_quick_launch_shortcut, |
157 bool alternate_desktop_shortcut) { | 157 bool alternate_desktop_shortcut) { |
158 const struct { | 158 const struct { |
159 const char* pref_name; | 159 const char* pref_name; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 base::ScopedTempDir fake_common_start_menu_; | 195 base::ScopedTempDir fake_common_start_menu_; |
196 scoped_ptr<base::ScopedPathOverride> user_desktop_override_; | 196 scoped_ptr<base::ScopedPathOverride> user_desktop_override_; |
197 scoped_ptr<base::ScopedPathOverride> common_desktop_override_; | 197 scoped_ptr<base::ScopedPathOverride> common_desktop_override_; |
198 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_; | 198 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_; |
199 scoped_ptr<base::ScopedPathOverride> start_menu_override_; | 199 scoped_ptr<base::ScopedPathOverride> start_menu_override_; |
200 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_; | 200 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_; |
201 | 201 |
202 base::FilePath user_desktop_shortcut_; | 202 base::FilePath user_desktop_shortcut_; |
203 base::FilePath user_quick_launch_shortcut_; | 203 base::FilePath user_quick_launch_shortcut_; |
204 base::FilePath user_start_menu_shortcut_; | 204 base::FilePath user_start_menu_shortcut_; |
205 base::FilePath user_start_menu_subdir_shortcut_; | |
205 base::FilePath system_desktop_shortcut_; | 206 base::FilePath system_desktop_shortcut_; |
206 base::FilePath system_start_menu_shortcut_; | 207 base::FilePath system_start_menu_shortcut_; |
207 base::FilePath user_alternate_desktop_shortcut_; | 208 base::FilePath user_alternate_desktop_shortcut_; |
208 }; | 209 }; |
209 | 210 |
210 } // namespace | 211 } // namespace |
211 | 212 |
212 // Test that VisualElementsManifest.xml is not created when VisualElements are | 213 // Test that VisualElementsManifest.xml is not created when VisualElements are |
213 // not present. | 214 // not present. |
214 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { | 215 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName())); | 371 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName())); |
371 | 372 |
372 installer::CreateOrUpdateShortcuts( | 373 installer::CreateOrUpdateShortcuts( |
373 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, | 374 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, |
374 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); | 375 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); |
375 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); | 376 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); |
376 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); | 377 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); |
377 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); | 378 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); |
378 } | 379 } |
379 | 380 |
381 TEST_F(InstallShortcutTest, MigrateExisting) { | |
gab
2015/09/28 15:44:51
Other test cases are:
- MigrateNonExisting
- Ins
bcwhite
2015/10/09 01:43:11
Investigating these...
| |
382 base::win::ShortcutProperties dummy_properties; | |
383 base::FilePath dummy_target; | |
384 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); | |
385 dummy_properties.set_target(expected_properties_.target); | |
386 dummy_properties.set_working_dir(fake_user_desktop_.path()); | |
387 dummy_properties.set_arguments(L"--dummy --args"); | |
388 dummy_properties.set_app_id(L"El.Dummiest"); | |
389 | |
390 ASSERT_TRUE(base::CreateDirectory( | |
391 user_start_menu_subdir_shortcut_.DirName())); | |
392 ASSERT_FALSE(base::PathExists(user_start_menu_subdir_shortcut_)); | |
393 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( | |
394 user_start_menu_subdir_shortcut_, dummy_properties, | |
395 base::win::SHORTCUT_CREATE_ALWAYS)); | |
396 ASSERT_TRUE(base::PathExists(user_start_menu_subdir_shortcut_)); | |
397 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); | |
398 | |
399 installer::CreateOrUpdateShortcuts( | |
400 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, | |
401 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); | |
402 ASSERT_FALSE(base::PathExists(user_start_menu_subdir_shortcut_)); | |
403 ASSERT_TRUE(base::PathExists(user_start_menu_shortcut_)); | |
404 } | |
405 | |
380 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { | 406 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { |
381 base::win::ShortcutProperties dummy_properties; | 407 base::win::ShortcutProperties dummy_properties; |
382 base::FilePath dummy_target; | 408 base::FilePath dummy_target; |
383 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); | 409 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); |
384 dummy_properties.set_target(dummy_target); | 410 dummy_properties.set_target(dummy_target); |
385 | 411 |
386 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( | 412 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( |
387 system_desktop_shortcut_, dummy_properties, | 413 system_desktop_shortcut_, dummy_properties, |
388 base::win::SHORTCUT_CREATE_ALWAYS)); | 414 base::win::SHORTCUT_CREATE_ALWAYS)); |
389 ASSERT_TRUE(base::CreateDirectory( | 415 ASSERT_TRUE(base::CreateDirectory( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 466 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
441 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 467 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
442 } | 468 } |
443 | 469 |
444 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { | 470 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { |
445 base::string16 val(L"Google Chrome"); | 471 base::string16 val(L"Google Chrome"); |
446 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; | 472 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; |
447 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 473 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
448 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 474 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
449 } | 475 } |
OLD | NEW |