| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <shellapi.h> | 6 #include <shellapi.h> |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 | 8 |
| 9 #include <fstream> | 9 #include <fstream> |
| 10 | 10 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 default_profile_shortcut_name); | 203 default_profile_shortcut_name); |
| 204 FilePath second_profile_shortcut_path = user_desktop_path.Append( | 204 FilePath second_profile_shortcut_path = user_desktop_path.Append( |
| 205 second_profile_shortcut_name); | 205 second_profile_shortcut_name); |
| 206 | 206 |
| 207 // Test simple creation of a user-level shortcut. | 207 // Test simple creation of a user-level shortcut. |
| 208 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, | 208 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 209 exe_path.value(), | 209 exe_path.value(), |
| 210 description, | 210 description, |
| 211 L"", | 211 L"", |
| 212 L"", | 212 L"", |
| 213 exe_path.value(), |
| 214 dist->GetIconIndex(), |
| 213 ShellUtil::CURRENT_USER, | 215 ShellUtil::CURRENT_USER, |
| 214 false, | 216 false, |
| 215 true)); | 217 true)); |
| 216 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 218 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 217 user_shortcut_path.value(), | 219 user_shortcut_path.value(), |
| 218 description, | 220 description, |
| 219 0)); | 221 0)); |
| 220 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, | 222 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, |
| 221 ShellUtil::CURRENT_USER, | 223 ShellUtil::CURRENT_USER, |
| 222 false)); | 224 false)); |
| 223 | 225 |
| 224 // Test simple creation of a system-level shortcut. | 226 // Test simple creation of a system-level shortcut. |
| 225 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, | 227 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 226 exe_path.value(), | 228 exe_path.value(), |
| 227 description, | 229 description, |
| 228 L"", | 230 L"", |
| 229 L"", | 231 L"", |
| 232 exe_path.value(), |
| 233 dist->GetIconIndex(), |
| 230 ShellUtil::SYSTEM_LEVEL, | 234 ShellUtil::SYSTEM_LEVEL, |
| 231 false, | 235 false, |
| 232 true)); | 236 true)); |
| 233 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 237 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 234 system_shortcut_path.value(), | 238 system_shortcut_path.value(), |
| 235 description, | 239 description, |
| 236 0)); | 240 0)); |
| 237 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, | 241 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, |
| 238 ShellUtil::SYSTEM_LEVEL, | 242 ShellUtil::SYSTEM_LEVEL, |
| 239 false)); | 243 false)); |
| 240 | 244 |
| 241 // Test creation of a user-level shortcut when a system-level shortcut | 245 // Test creation of a user-level shortcut when a system-level shortcut |
| 242 // is already present (should fail). | 246 // is already present (should fail). |
| 243 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, | 247 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 244 exe_path.value(), | 248 exe_path.value(), |
| 245 description, | 249 description, |
| 246 L"", | 250 L"", |
| 247 L"", | 251 L"", |
| 252 exe_path.value(), |
| 253 dist->GetIconIndex(), |
| 248 ShellUtil::SYSTEM_LEVEL, | 254 ShellUtil::SYSTEM_LEVEL, |
| 249 false, | 255 false, |
| 250 true)); | 256 true)); |
| 251 EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut(dist, | 257 EXPECT_FALSE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 252 exe_path.value(), | 258 exe_path.value(), |
| 253 description, | 259 description, |
| 254 L"", | 260 L"", |
| 255 L"", | 261 L"", |
| 262 exe_path.value(), |
| 263 dist->GetIconIndex(), |
| 256 ShellUtil::CURRENT_USER, | 264 ShellUtil::CURRENT_USER, |
| 257 false, | 265 false, |
| 258 true)); | 266 true)); |
| 259 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 267 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 260 system_shortcut_path.value(), | 268 system_shortcut_path.value(), |
| 261 description, | 269 description, |
| 262 0)); | 270 0)); |
| 263 EXPECT_FALSE(file_util::PathExists(user_shortcut_path)); | 271 EXPECT_FALSE(file_util::PathExists(user_shortcut_path)); |
| 264 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, | 272 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, |
| 265 ShellUtil::SYSTEM_LEVEL, | 273 ShellUtil::SYSTEM_LEVEL, |
| 266 false)); | 274 false)); |
| 267 | 275 |
| 268 // Test creation of a system-level shortcut when a user-level shortcut | 276 // Test creation of a system-level shortcut when a user-level shortcut |
| 269 // is already present (should succeed). | 277 // is already present (should succeed). |
| 270 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, | 278 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 271 exe_path.value(), | 279 exe_path.value(), |
| 272 description, | 280 description, |
| 273 L"", | 281 L"", |
| 274 L"", | 282 L"", |
| 283 exe_path.value(), |
| 284 dist->GetIconIndex(), |
| 275 ShellUtil::CURRENT_USER, | 285 ShellUtil::CURRENT_USER, |
| 276 false, | 286 false, |
| 277 true)); | 287 true)); |
| 278 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, | 288 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut(dist, |
| 279 exe_path.value(), | 289 exe_path.value(), |
| 280 description, | 290 description, |
| 281 L"", | 291 L"", |
| 282 L"", | 292 L"", |
| 293 exe_path.value(), |
| 294 dist->GetIconIndex(), |
| 283 ShellUtil::SYSTEM_LEVEL, | 295 ShellUtil::SYSTEM_LEVEL, |
| 284 false, | 296 false, |
| 285 true)); | 297 true)); |
| 286 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 298 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 287 user_shortcut_path.value(), | 299 user_shortcut_path.value(), |
| 288 description, | 300 description, |
| 289 0)); | 301 0)); |
| 290 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 302 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 291 system_shortcut_path.value(), | 303 system_shortcut_path.value(), |
| 292 description, | 304 description, |
| 293 0)); | 305 0)); |
| 294 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, | 306 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, |
| 295 ShellUtil::CURRENT_USER, | 307 ShellUtil::CURRENT_USER, |
| 296 false)); | 308 false)); |
| 297 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, | 309 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcut(dist, |
| 298 ShellUtil::SYSTEM_LEVEL, | 310 ShellUtil::SYSTEM_LEVEL, |
| 299 false)); | 311 false)); |
| 300 | 312 |
| 301 // Test creation of two profile-specific shortcuts (these are always | 313 // Test creation of two profile-specific shortcuts (these are always |
| 302 // user-level). | 314 // user-level). |
| 303 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 315 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
| 304 dist, | 316 dist, |
| 305 exe_path.value(), | 317 exe_path.value(), |
| 306 description, | 318 description, |
| 307 default_profile_user_name, | 319 default_profile_user_name, |
| 308 L"--profile-directory=\"Default\"", | 320 L"--profile-directory=\"Default\"", |
| 321 exe_path.value(), |
| 322 dist->GetIconIndex(), |
| 309 ShellUtil::CURRENT_USER, | 323 ShellUtil::CURRENT_USER, |
| 310 false, | 324 false, |
| 311 true)); | 325 true)); |
| 312 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 326 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 313 default_profile_shortcut_path.value(), | 327 default_profile_shortcut_path.value(), |
| 314 description, | 328 description, |
| 315 0)); | 329 0)); |
| 316 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( | 330 EXPECT_TRUE(ShellUtil::CreateChromeDesktopShortcut( |
| 317 dist, | 331 dist, |
| 318 exe_path.value(), | 332 exe_path.value(), |
| 319 description, | 333 description, |
| 320 second_profile_user_name, | 334 second_profile_user_name, |
| 321 L"--profile-directory=\"Profile 1\"", | 335 L"--profile-directory=\"Profile 1\"", |
| 336 exe_path.value(), |
| 337 dist->GetIconIndex(), |
| 322 ShellUtil::CURRENT_USER, | 338 ShellUtil::CURRENT_USER, |
| 323 false, | 339 false, |
| 324 true)); | 340 true)); |
| 325 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), | 341 EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(), |
| 326 second_profile_shortcut_path.value(), | 342 second_profile_shortcut_path.value(), |
| 327 description, | 343 description, |
| 328 0)); | 344 0)); |
| 329 std::vector<string16> profile_names; | 345 std::vector<string16> profile_names; |
| 330 profile_names.push_back(default_profile_shortcut_name); | 346 profile_names.push_back(default_profile_shortcut_name); |
| 331 profile_names.push_back(second_profile_shortcut_name); | 347 profile_names.push_back(second_profile_shortcut_name); |
| 332 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( | 348 EXPECT_TRUE(ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( |
| 333 profile_names)); | 349 profile_names)); |
| 334 } | 350 } |
| OLD | NEW |