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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 expected_properties_.set_description(chrome_properties.description); | 87 expected_properties_.set_description(chrome_properties.description); |
88 expected_properties_.set_dual_mode(false); | 88 expected_properties_.set_dual_mode(false); |
89 expected_start_menu_properties_ = expected_properties_; | 89 expected_start_menu_properties_ = expected_properties_; |
90 expected_start_menu_properties_.set_dual_mode(true); | 90 expected_start_menu_properties_.set_dual_mode(true); |
91 | 91 |
92 prefs_.reset(GetFakeMasterPrefs(false, false, false)); | 92 prefs_.reset(GetFakeMasterPrefs(false, false, false)); |
93 | 93 |
94 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); | 94 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); |
95 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); | 95 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); |
96 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); | 96 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); |
97 ASSERT_TRUE(fake_default_user_quick_launch_.CreateUniqueTempDir()); | |
98 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); | 97 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); |
99 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); | 98 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); |
100 user_desktop_override_.reset( | 99 user_desktop_override_.reset( |
101 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, | 100 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, |
102 fake_user_desktop_.path())); | 101 fake_user_desktop_.path())); |
103 common_desktop_override_.reset( | 102 common_desktop_override_.reset( |
104 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP, | 103 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP, |
105 fake_common_desktop_.path())); | 104 fake_common_desktop_.path())); |
106 user_quick_launch_override_.reset( | 105 user_quick_launch_override_.reset( |
107 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH, | 106 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH, |
108 fake_user_quick_launch_.path())); | 107 fake_user_quick_launch_.path())); |
109 default_user_quick_launch_override_.reset( | |
110 new base::ScopedPathOverride(base::DIR_DEFAULT_USER_QUICK_LAUNCH, | |
111 fake_default_user_quick_launch_.path())); | |
112 start_menu_override_.reset( | 108 start_menu_override_.reset( |
113 new base::ScopedPathOverride(base::DIR_START_MENU, | 109 new base::ScopedPathOverride(base::DIR_START_MENU, |
114 fake_start_menu_.path())); | 110 fake_start_menu_.path())); |
115 common_start_menu_override_.reset( | 111 common_start_menu_override_.reset( |
116 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU, | 112 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU, |
117 fake_common_start_menu_.path())); | 113 fake_common_start_menu_.path())); |
118 | 114 |
119 base::string16 shortcut_name( | 115 base::string16 shortcut_name( |
120 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + | 116 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + |
121 installer::kLnkExt); | 117 installer::kLnkExt); |
122 base::string16 alternate_shortcut_name( | 118 base::string16 alternate_shortcut_name( |
123 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + | 119 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + |
124 installer::kLnkExt); | 120 installer::kLnkExt); |
125 | 121 |
126 user_desktop_shortcut_ = | 122 user_desktop_shortcut_ = |
127 fake_user_desktop_.path().Append(shortcut_name); | 123 fake_user_desktop_.path().Append(shortcut_name); |
128 user_quick_launch_shortcut_ = | 124 user_quick_launch_shortcut_ = |
129 fake_user_quick_launch_.path().Append(shortcut_name); | 125 fake_user_quick_launch_.path().Append(shortcut_name); |
130 user_start_menu_shortcut_ = | 126 user_start_menu_shortcut_ = |
131 fake_start_menu_.path().Append( | 127 fake_start_menu_.path().Append( |
132 dist_->GetStartMenuShortcutSubfolder( | 128 dist_->GetStartMenuShortcutSubfolder( |
133 BrowserDistribution::SUBFOLDER_CHROME)) | 129 BrowserDistribution::SUBFOLDER_CHROME)) |
134 .Append(shortcut_name); | 130 .Append(shortcut_name); |
135 system_desktop_shortcut_ = | 131 system_desktop_shortcut_ = |
136 fake_common_desktop_.path().Append(shortcut_name); | 132 fake_common_desktop_.path().Append(shortcut_name); |
137 system_quick_launch_shortcut_ = | |
138 fake_default_user_quick_launch_.path().Append(shortcut_name); | |
139 system_start_menu_shortcut_ = | 133 system_start_menu_shortcut_ = |
140 fake_common_start_menu_.path().Append( | 134 fake_common_start_menu_.path().Append( |
141 dist_->GetStartMenuShortcutSubfolder( | 135 dist_->GetStartMenuShortcutSubfolder( |
142 BrowserDistribution::SUBFOLDER_CHROME)) | 136 BrowserDistribution::SUBFOLDER_CHROME)) |
143 .Append(shortcut_name); | 137 .Append(shortcut_name); |
144 user_alternate_desktop_shortcut_ = | 138 user_alternate_desktop_shortcut_ = |
145 fake_user_desktop_.path().Append(alternate_shortcut_name); | 139 fake_user_desktop_.path().Append(alternate_shortcut_name); |
146 } | 140 } |
147 | 141 |
148 virtual void TearDown() OVERRIDE { | 142 virtual void TearDown() OVERRIDE { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 182 |
189 BrowserDistribution* dist_; | 183 BrowserDistribution* dist_; |
190 base::FilePath chrome_exe_; | 184 base::FilePath chrome_exe_; |
191 scoped_ptr<installer::Product> product_; | 185 scoped_ptr<installer::Product> product_; |
192 scoped_ptr<installer::MasterPreferences> prefs_; | 186 scoped_ptr<installer::MasterPreferences> prefs_; |
193 | 187 |
194 base::ScopedTempDir temp_dir_; | 188 base::ScopedTempDir temp_dir_; |
195 base::ScopedTempDir fake_user_desktop_; | 189 base::ScopedTempDir fake_user_desktop_; |
196 base::ScopedTempDir fake_common_desktop_; | 190 base::ScopedTempDir fake_common_desktop_; |
197 base::ScopedTempDir fake_user_quick_launch_; | 191 base::ScopedTempDir fake_user_quick_launch_; |
198 base::ScopedTempDir fake_default_user_quick_launch_; | |
199 base::ScopedTempDir fake_start_menu_; | 192 base::ScopedTempDir fake_start_menu_; |
200 base::ScopedTempDir fake_common_start_menu_; | 193 base::ScopedTempDir fake_common_start_menu_; |
201 scoped_ptr<base::ScopedPathOverride> user_desktop_override_; | 194 scoped_ptr<base::ScopedPathOverride> user_desktop_override_; |
202 scoped_ptr<base::ScopedPathOverride> common_desktop_override_; | 195 scoped_ptr<base::ScopedPathOverride> common_desktop_override_; |
203 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_; | 196 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_; |
204 scoped_ptr<base::ScopedPathOverride> default_user_quick_launch_override_; | |
205 scoped_ptr<base::ScopedPathOverride> start_menu_override_; | 197 scoped_ptr<base::ScopedPathOverride> start_menu_override_; |
206 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_; | 198 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_; |
207 | 199 |
208 base::FilePath user_desktop_shortcut_; | 200 base::FilePath user_desktop_shortcut_; |
209 base::FilePath user_quick_launch_shortcut_; | 201 base::FilePath user_quick_launch_shortcut_; |
210 base::FilePath user_start_menu_shortcut_; | 202 base::FilePath user_start_menu_shortcut_; |
211 base::FilePath system_desktop_shortcut_; | 203 base::FilePath system_desktop_shortcut_; |
212 base::FilePath system_quick_launch_shortcut_; | |
213 base::FilePath system_start_menu_shortcut_; | 204 base::FilePath system_start_menu_shortcut_; |
214 base::FilePath user_alternate_desktop_shortcut_; | 205 base::FilePath user_alternate_desktop_shortcut_; |
215 }; | 206 }; |
216 | 207 |
217 } // namespace | 208 } // namespace |
218 | 209 |
219 // Test that VisualElementsManifest.xml is not created when VisualElements are | 210 // Test that VisualElementsManifest.xml is not created when VisualElements are |
220 // not present. | 211 // not present. |
221 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { | 212 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { |
222 ASSERT_TRUE( | 213 ASSERT_TRUE( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 installer::CreateOrUpdateShortcuts( | 248 installer::CreateOrUpdateShortcuts( |
258 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, | 249 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, |
259 installer::INSTALL_SHORTCUT_CREATE_ALL); | 250 installer::INSTALL_SHORTCUT_CREATE_ALL); |
260 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); | 251 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); |
261 base::win::ValidateShortcut(user_quick_launch_shortcut_, | 252 base::win::ValidateShortcut(user_quick_launch_shortcut_, |
262 expected_properties_); | 253 expected_properties_); |
263 base::win::ValidateShortcut(user_start_menu_shortcut_, | 254 base::win::ValidateShortcut(user_start_menu_shortcut_, |
264 expected_start_menu_properties_); | 255 expected_start_menu_properties_); |
265 } | 256 } |
266 | 257 |
267 // Disabled failing test; http://crbug.com/329239. | 258 TEST_F(InstallShortcutTest, CreateAllShortcutsSystemLevel) { |
268 TEST_F(InstallShortcutTest, DISABLED_CreateAllShortcutsSystemLevel) { | |
269 installer::CreateOrUpdateShortcuts( | 259 installer::CreateOrUpdateShortcuts( |
270 chrome_exe_, *product_, *prefs_, installer::ALL_USERS, | 260 chrome_exe_, *product_, *prefs_, installer::ALL_USERS, |
271 installer::INSTALL_SHORTCUT_CREATE_ALL); | 261 installer::INSTALL_SHORTCUT_CREATE_ALL); |
272 base::win::ValidateShortcut(system_desktop_shortcut_, expected_properties_); | 262 base::win::ValidateShortcut(system_desktop_shortcut_, expected_properties_); |
273 base::win::ValidateShortcut(system_quick_launch_shortcut_, | |
274 expected_properties_); | |
275 base::win::ValidateShortcut(system_start_menu_shortcut_, | 263 base::win::ValidateShortcut(system_start_menu_shortcut_, |
276 expected_start_menu_properties_); | 264 expected_start_menu_properties_); |
277 } | 265 } |
278 | 266 |
279 TEST_F(InstallShortcutTest, CreateAllShortcutsAlternateDesktopName) { | 267 TEST_F(InstallShortcutTest, CreateAllShortcutsAlternateDesktopName) { |
280 scoped_ptr<installer::MasterPreferences> prefs_alt_desktop( | 268 scoped_ptr<installer::MasterPreferences> prefs_alt_desktop( |
281 GetFakeMasterPrefs(false, false, true)); | 269 GetFakeMasterPrefs(false, false, true)); |
282 installer::CreateOrUpdateShortcuts( | 270 installer::CreateOrUpdateShortcuts( |
283 chrome_exe_, *product_, *prefs_alt_desktop, installer::CURRENT_USER, | 271 chrome_exe_, *product_, *prefs_alt_desktop, installer::CURRENT_USER, |
284 installer::INSTALL_SHORTCUT_CREATE_ALL); | 272 installer::INSTALL_SHORTCUT_CREATE_ALL); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 357 |
370 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { | 358 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { |
371 base::win::ShortcutProperties dummy_properties; | 359 base::win::ShortcutProperties dummy_properties; |
372 base::FilePath dummy_target; | 360 base::FilePath dummy_target; |
373 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); | 361 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); |
374 dummy_properties.set_target(dummy_target); | 362 dummy_properties.set_target(dummy_target); |
375 | 363 |
376 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( | 364 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( |
377 system_desktop_shortcut_, dummy_properties, | 365 system_desktop_shortcut_, dummy_properties, |
378 base::win::SHORTCUT_CREATE_ALWAYS)); | 366 base::win::SHORTCUT_CREATE_ALWAYS)); |
379 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( | |
380 system_quick_launch_shortcut_, dummy_properties, | |
381 base::win::SHORTCUT_CREATE_ALWAYS)); | |
382 ASSERT_TRUE(base::CreateDirectory( | 367 ASSERT_TRUE(base::CreateDirectory( |
383 system_start_menu_shortcut_.DirName())); | 368 system_start_menu_shortcut_.DirName())); |
384 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( | 369 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( |
385 system_start_menu_shortcut_, dummy_properties, | 370 system_start_menu_shortcut_, dummy_properties, |
386 base::win::SHORTCUT_CREATE_ALWAYS)); | 371 base::win::SHORTCUT_CREATE_ALWAYS)); |
387 | 372 |
388 installer::CreateOrUpdateShortcuts( | 373 installer::CreateOrUpdateShortcuts( |
389 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, | 374 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, |
390 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); | 375 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); |
391 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_)); | 376 ASSERT_FALSE(base::PathExists(user_desktop_shortcut_)); |
392 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); | |
393 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); | 377 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); |
| 378 // There is no system-level quick launch shortcut, so creating the user-level |
| 379 // one should always succeed. |
| 380 ASSERT_TRUE(base::PathExists(user_quick_launch_shortcut_)); |
394 } | 381 } |
395 | 382 |
396 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelNoSystemShortcutsExist) { | 383 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelNoSystemShortcutsExist) { |
397 installer::CreateOrUpdateShortcuts( | 384 installer::CreateOrUpdateShortcuts( |
398 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, | 385 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, |
399 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); | 386 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); |
400 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); | 387 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); |
401 base::win::ValidateShortcut(user_quick_launch_shortcut_, | 388 base::win::ValidateShortcut(user_quick_launch_shortcut_, |
402 expected_properties_); | 389 expected_properties_); |
403 base::win::ValidateShortcut(user_start_menu_shortcut_, | 390 base::win::ValidateShortcut(user_start_menu_shortcut_, |
(...skipping 27 matching lines...) Expand all Loading... |
431 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 418 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
432 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 419 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
433 } | 420 } |
434 | 421 |
435 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { | 422 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { |
436 base::string16 val(L"Google Chrome"); | 423 base::string16 val(L"Google Chrome"); |
437 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; | 424 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; |
438 installer::EscapeXmlAttributeValueInSingleQuotes(&val); | 425 installer::EscapeXmlAttributeValueInSingleQuotes(&val); |
439 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); | 426 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); |
440 } | 427 } |
OLD | NEW |