| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/base_paths_win.h" | 10 #include "base/base_paths_win.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { | 301 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelWithSystemLevelPresent) { |
| 302 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 302 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 303 | 303 |
| 304 test_properties_->level = ShellUtil::SYSTEM_LEVEL; | 304 test_properties_->level = ShellUtil::SYSTEM_LEVEL; |
| 305 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 305 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 306 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 306 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 307 *test_properties_, | 307 *test_properties_, |
| 308 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 308 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 309 ASSERT_TRUE(file_util::PathExists( | 309 ASSERT_TRUE(base::PathExists( |
| 310 fake_common_desktop_.path().Append(shortcut_name))); | 310 fake_common_desktop_.path().Append(shortcut_name))); |
| 311 | 311 |
| 312 test_properties_->level = ShellUtil::CURRENT_USER; | 312 test_properties_->level = ShellUtil::CURRENT_USER; |
| 313 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 313 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 314 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 314 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 315 *test_properties_, | 315 *test_properties_, |
| 316 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 316 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 317 ASSERT_FALSE(file_util::PathExists( | 317 ASSERT_FALSE(base::PathExists( |
| 318 fake_user_desktop_.path().Append(shortcut_name))); | 318 fake_user_desktop_.path().Append(shortcut_name))); |
| 319 } | 319 } |
| 320 | 320 |
| 321 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { | 321 TEST_F(ShellUtilShortcutTest, CreateIfNoSystemLevelStartMenu) { |
| 322 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 322 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 323 ShellUtil::SHORTCUT_LOCATION_START_MENU, | 323 ShellUtil::SHORTCUT_LOCATION_START_MENU, |
| 324 dist_, *test_properties_, | 324 dist_, *test_properties_, |
| 325 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); | 325 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL)); |
| 326 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, | 326 ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, |
| 327 *test_properties_); | 327 *test_properties_); |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { | 330 TEST_F(ShellUtilShortcutTest, CreateAlwaysUserWithSystemLevelPresent) { |
| 331 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 331 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 332 | 332 |
| 333 test_properties_->level = ShellUtil::SYSTEM_LEVEL; | 333 test_properties_->level = ShellUtil::SYSTEM_LEVEL; |
| 334 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 334 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 335 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 335 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 336 *test_properties_, | 336 *test_properties_, |
| 337 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 337 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 338 ASSERT_TRUE(file_util::PathExists( | 338 ASSERT_TRUE(base::PathExists( |
| 339 fake_common_desktop_.path().Append(shortcut_name))); | 339 fake_common_desktop_.path().Append(shortcut_name))); |
| 340 | 340 |
| 341 test_properties_->level = ShellUtil::CURRENT_USER; | 341 test_properties_->level = ShellUtil::CURRENT_USER; |
| 342 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 342 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 343 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 343 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 344 *test_properties_, | 344 *test_properties_, |
| 345 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 345 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 346 ASSERT_TRUE(file_util::PathExists( | 346 ASSERT_TRUE(base::PathExists( |
| 347 fake_user_desktop_.path().Append(shortcut_name))); | 347 fake_user_desktop_.path().Append(shortcut_name))); |
| 348 } | 348 } |
| 349 | 349 |
| 350 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { | 350 TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { |
| 351 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 351 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 352 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 352 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 353 *test_properties_, | 353 *test_properties_, |
| 354 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 354 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 355 | 355 |
| 356 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 356 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 357 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 357 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 358 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 358 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 359 | 359 |
| 360 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 360 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 361 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 361 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 362 chrome_exe_)); | 362 chrome_exe_)); |
| 363 ASSERT_FALSE(file_util::PathExists(shortcut_path)); | 363 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 364 ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName())); | 364 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 365 } | 365 } |
| 366 | 366 |
| 367 TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { | 367 TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { |
| 368 test_properties_->level = ShellUtil::SYSTEM_LEVEL; | 368 test_properties_->level = ShellUtil::SYSTEM_LEVEL; |
| 369 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 369 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 370 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 370 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 371 *test_properties_, | 371 *test_properties_, |
| 372 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 372 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 373 | 373 |
| 374 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 374 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 375 base::FilePath shortcut_path( | 375 base::FilePath shortcut_path( |
| 376 fake_common_desktop_.path().Append(shortcut_name)); | 376 fake_common_desktop_.path().Append(shortcut_name)); |
| 377 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 377 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 378 | 378 |
| 379 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 379 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 380 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, | 380 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, |
| 381 chrome_exe_)); | 381 chrome_exe_)); |
| 382 ASSERT_FALSE(file_util::PathExists(shortcut_path)); | 382 ASSERT_FALSE(base::PathExists(shortcut_path)); |
| 383 ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName())); | 383 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 384 } | 384 } |
| 385 | 385 |
| 386 TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) { | 386 TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) { |
| 387 const wchar_t kShortcutName1[] = L"Chrome 1"; | 387 const wchar_t kShortcutName1[] = L"Chrome 1"; |
| 388 const wchar_t kShortcutName2[] = L"Chrome 2"; | 388 const wchar_t kShortcutName2[] = L"Chrome 2"; |
| 389 | 389 |
| 390 test_properties_->set_shortcut_name(kShortcutName1); | 390 test_properties_->set_shortcut_name(kShortcutName1); |
| 391 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 391 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 392 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 392 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 393 *test_properties_, | 393 *test_properties_, |
| 394 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 394 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 395 string16 shortcut1_name( | 395 string16 shortcut1_name( |
| 396 string16(kShortcutName1).append(installer::kLnkExt)); | 396 string16(kShortcutName1).append(installer::kLnkExt)); |
| 397 base::FilePath shortcut1_path( | 397 base::FilePath shortcut1_path( |
| 398 fake_user_desktop_.path().Append(shortcut1_name)); | 398 fake_user_desktop_.path().Append(shortcut1_name)); |
| 399 ASSERT_TRUE(file_util::PathExists(shortcut1_path)); | 399 ASSERT_TRUE(base::PathExists(shortcut1_path)); |
| 400 | 400 |
| 401 test_properties_->set_shortcut_name(kShortcutName2); | 401 test_properties_->set_shortcut_name(kShortcutName2); |
| 402 test_properties_->set_arguments(L"--profile-directory=\"Profile 2\""); | 402 test_properties_->set_arguments(L"--profile-directory=\"Profile 2\""); |
| 403 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 403 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 404 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 404 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 405 *test_properties_, | 405 *test_properties_, |
| 406 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 406 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 407 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); | 407 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); |
| 408 base::FilePath shortcut2_path( | 408 base::FilePath shortcut2_path( |
| 409 fake_user_desktop_.path().Append(shortcut2_name)); | 409 fake_user_desktop_.path().Append(shortcut2_name)); |
| 410 ASSERT_TRUE(file_util::PathExists(shortcut2_path)); | 410 ASSERT_TRUE(base::PathExists(shortcut2_path)); |
| 411 | 411 |
| 412 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 412 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 413 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 413 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 414 chrome_exe_)); | 414 chrome_exe_)); |
| 415 ASSERT_FALSE(file_util::PathExists(shortcut1_path)); | 415 ASSERT_FALSE(base::PathExists(shortcut1_path)); |
| 416 ASSERT_FALSE(file_util::PathExists(shortcut2_path)); | 416 ASSERT_FALSE(base::PathExists(shortcut2_path)); |
| 417 ASSERT_TRUE(file_util::PathExists(shortcut1_path.DirName())); | 417 ASSERT_TRUE(base::PathExists(shortcut1_path.DirName())); |
| 418 } | 418 } |
| 419 | 419 |
| 420 TEST_F(ShellUtilShortcutTest, UpdateChromeShortcut) { | 420 TEST_F(ShellUtilShortcutTest, UpdateChromeShortcut) { |
| 421 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 421 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 422 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 422 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 423 *test_properties_, | 423 *test_properties_, |
| 424 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 424 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 425 | 425 |
| 426 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 426 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 427 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 427 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 428 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 428 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 429 | 429 |
| 430 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); | 430 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); |
| 431 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 431 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 432 updated_properties.set_target(new_exe); | 432 updated_properties.set_target(new_exe); |
| 433 | 433 |
| 434 ASSERT_TRUE(ShellUtil::UpdateShortcuts( | 434 ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
| 435 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 435 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 436 chrome_exe_, updated_properties)); | 436 chrome_exe_, updated_properties)); |
| 437 | 437 |
| 438 // TODO(huangs): Fix ValidateChromeShortcut() and use it. | 438 // TODO(huangs): Fix ValidateChromeShortcut() and use it. |
| 439 base::FilePath target_path; | 439 base::FilePath target_path; |
| 440 ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL)); | 440 ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL)); |
| 441 ASSERT_EQ(new_exe, target_path); | 441 ASSERT_EQ(new_exe, target_path); |
| 442 } | 442 } |
| 443 | 443 |
| 444 TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcut) { | 444 TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcut) { |
| 445 test_properties_->level = ShellUtil::SYSTEM_LEVEL; | 445 test_properties_->level = ShellUtil::SYSTEM_LEVEL; |
| 446 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 446 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 447 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 447 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 448 *test_properties_, | 448 *test_properties_, |
| 449 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 449 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 450 | 450 |
| 451 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 451 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 452 base::FilePath shortcut_path( | 452 base::FilePath shortcut_path( |
| 453 fake_common_desktop_.path().Append(shortcut_name)); | 453 fake_common_desktop_.path().Append(shortcut_name)); |
| 454 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 454 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 455 | 455 |
| 456 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); | 456 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); |
| 457 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 457 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 458 updated_properties.set_target(new_exe); | 458 updated_properties.set_target(new_exe); |
| 459 | 459 |
| 460 ASSERT_TRUE(ShellUtil::UpdateShortcuts( | 460 ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
| 461 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, | 461 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, |
| 462 chrome_exe_, updated_properties)); | 462 chrome_exe_, updated_properties)); |
| 463 | 463 |
| 464 // TODO(huangs): Fix ValidateChromeShortcut() and use it. | 464 // TODO(huangs): Fix ValidateChromeShortcut() and use it. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 484 string16 shortcut2_args = L"--profile-directory=\"Profile 2\""; | 484 string16 shortcut2_args = L"--profile-directory=\"Profile 2\""; |
| 485 test_properties_->set_shortcut_name(kShortcutName2); | 485 test_properties_->set_shortcut_name(kShortcutName2); |
| 486 test_properties_->set_arguments(shortcut2_args); | 486 test_properties_->set_arguments(shortcut2_args); |
| 487 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 487 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 488 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 488 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 489 *test_properties_, | 489 *test_properties_, |
| 490 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 490 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 491 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); | 491 string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt)); |
| 492 base::FilePath shortcut2_path( | 492 base::FilePath shortcut2_path( |
| 493 fake_user_desktop_.path().Append(shortcut2_name)); | 493 fake_user_desktop_.path().Append(shortcut2_name)); |
| 494 ASSERT_TRUE(file_util::PathExists(shortcut2_path)); | 494 ASSERT_TRUE(base::PathExists(shortcut2_path)); |
| 495 | 495 |
| 496 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); | 496 base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe"); |
| 497 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); | 497 ShellUtil::ShortcutProperties updated_properties(ShellUtil::CURRENT_USER); |
| 498 updated_properties.set_target(new_exe); | 498 updated_properties.set_target(new_exe); |
| 499 | 499 |
| 500 ASSERT_TRUE(ShellUtil::UpdateShortcuts( | 500 ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
| 501 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 501 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 502 chrome_exe_, updated_properties)); | 502 chrome_exe_, updated_properties)); |
| 503 | 503 |
| 504 // TODO(huangs): Fix ValidateChromeShortcut() and use it. | 504 // TODO(huangs): Fix ValidateChromeShortcut() and use it. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 527 | 527 |
| 528 base::FilePath shortcut_folder( | 528 base::FilePath shortcut_folder( |
| 529 fake_start_menu_.path().Append(dist_->GetAppShortCutName())); | 529 fake_start_menu_.path().Append(dist_->GetAppShortCutName())); |
| 530 base::FileEnumerator file_counter(shortcut_folder, false, | 530 base::FileEnumerator file_counter(shortcut_folder, false, |
| 531 base::FileEnumerator::FILES); | 531 base::FileEnumerator::FILES); |
| 532 int count = 0; | 532 int count = 0; |
| 533 while (!file_counter.Next().empty()) | 533 while (!file_counter.Next().empty()) |
| 534 ++count; | 534 ++count; |
| 535 EXPECT_EQ(2, count); | 535 EXPECT_EQ(2, count); |
| 536 | 536 |
| 537 ASSERT_TRUE(file_util::PathExists(shortcut_folder)); | 537 ASSERT_TRUE(base::PathExists(shortcut_folder)); |
| 538 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 538 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 539 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, | 539 ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, |
| 540 chrome_exe_)); | 540 chrome_exe_)); |
| 541 ASSERT_FALSE(file_util::PathExists(shortcut_folder)); | 541 ASSERT_FALSE(base::PathExists(shortcut_folder)); |
| 542 } | 542 } |
| 543 | 543 |
| 544 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { | 544 TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { |
| 545 base::ScopedTempDir other_exe_dir; | 545 base::ScopedTempDir other_exe_dir; |
| 546 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); | 546 ASSERT_TRUE(other_exe_dir.CreateUniqueTempDir()); |
| 547 base::FilePath other_chrome_exe = | 547 base::FilePath other_chrome_exe = |
| 548 other_exe_dir.path().Append(installer::kChromeExe); | 548 other_exe_dir.path().Append(installer::kChromeExe); |
| 549 EXPECT_EQ(0, file_util::WriteFile(other_chrome_exe, "", 0)); | 549 EXPECT_EQ(0, file_util::WriteFile(other_chrome_exe, "", 0)); |
| 550 | 550 |
| 551 test_properties_->set_target(other_chrome_exe); | 551 test_properties_->set_target(other_chrome_exe); |
| 552 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( | 552 ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut( |
| 553 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, | 553 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, |
| 554 *test_properties_, | 554 *test_properties_, |
| 555 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); | 555 ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS)); |
| 556 | 556 |
| 557 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); | 557 string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt); |
| 558 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); | 558 base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name)); |
| 559 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 559 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 560 | 560 |
| 561 // The shortcut shouldn't be removed as it was installed pointing to | 561 // The shortcut shouldn't be removed as it was installed pointing to |
| 562 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the | 562 // |other_chrome_exe| and RemoveChromeShortcut() is being told that the |
| 563 // removed shortcut should point to |chrome_exe_|. | 563 // removed shortcut should point to |chrome_exe_|. |
| 564 ASSERT_TRUE(ShellUtil::RemoveShortcuts( | 564 ASSERT_TRUE(ShellUtil::RemoveShortcuts( |
| 565 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, | 565 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
| 566 chrome_exe_)); | 566 chrome_exe_)); |
| 567 ASSERT_TRUE(file_util::PathExists(shortcut_path)); | 567 ASSERT_TRUE(base::PathExists(shortcut_path)); |
| 568 ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName())); | 568 ASSERT_TRUE(base::PathExists(shortcut_path.DirName())); |
| 569 } | 569 } |
| 570 | 570 |
| 571 TEST(ShellUtilTest, BuildAppModelIdBasic) { | 571 TEST(ShellUtilTest, BuildAppModelIdBasic) { |
| 572 std::vector<string16> components; | 572 std::vector<string16> components; |
| 573 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 573 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 574 const string16 base_app_id(dist->GetBaseAppId()); | 574 const string16 base_app_id(dist->GetBaseAppId()); |
| 575 components.push_back(base_app_id); | 575 components.push_back(base_app_id); |
| 576 ASSERT_EQ(base_app_id, ShellUtil::BuildAppModelId(components)); | 576 ASSERT_EQ(base_app_id, ShellUtil::BuildAppModelId(components)); |
| 577 } | 577 } |
| 578 | 578 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", | 640 const string16 expected[] = { L"", L"MY", L"MZXQ", L"MZXW6", L"MZXW6YQ", |
| 641 L"MZXW6YTB", L"MZXW6YTBOI"}; | 641 L"MZXW6YTB", L"MZXW6YTBOI"}; |
| 642 | 642 |
| 643 // Run the tests, with one more letter in the input every pass. | 643 // Run the tests, with one more letter in the input every pass. |
| 644 for (int i = 0; i < arraysize(expected); ++i) { | 644 for (int i = 0; i < arraysize(expected); ++i) { |
| 645 ASSERT_EQ(expected[i], | 645 ASSERT_EQ(expected[i], |
| 646 ShellUtil::ByteArrayToBase32(test_array, i)); | 646 ShellUtil::ByteArrayToBase32(test_array, i)); |
| 647 } | 647 } |
| 648 } | 648 } |
| OLD | NEW |