| 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 "chrome/test/mini_installer_test/chrome_mini_installer.h" | 5 #include "chrome/test/mini_installer_test/chrome_mini_installer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 FilePath full_installer; | 175 FilePath full_installer; |
| 176 ASSERT_TRUE(GetFullInstaller(&full_installer)); | 176 ASSERT_TRUE(GetFullInstaller(&full_installer)); |
| 177 InstallMiniInstaller(over_install, full_installer); | 177 InstallMiniInstaller(over_install, full_installer); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Installs the Chrome mini-installer, checks the registry and shortcuts. | 180 // Installs the Chrome mini-installer, checks the registry and shortcuts. |
| 181 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, | 181 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, |
| 182 const FilePath& path) { | 182 const FilePath& path) { |
| 183 LOG(INFO) << "Install level is: " | 183 LOG(INFO) << "Install level is: " |
| 184 << (system_install_ ? "system" : "user"); | 184 << (system_install_ ? "system" : "user"); |
| 185 RunInstaller(CommandLine(path)); | 185 ASSERT_TRUE(file_util::PathExists(path)); |
| 186 | 186 CommandLine installer(path); |
| 187 if (is_chrome_frame_) { |
| 188 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 189 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 190 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 191 installer.AppendSwitch(installer::switches::kChromeFrame); |
| 192 } |
| 193 RunInstaller(installer); |
| 187 std::string version; | 194 std::string version; |
| 188 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) | 195 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) |
| 189 << "Install failed: unable to get version."; | 196 << "Install failed: unable to get version."; |
| 190 VerifyInstall(over_install); | 197 VerifyInstall(over_install); |
| 191 } | 198 } |
| 192 | 199 |
| 193 CommandLine ChromeMiniInstaller::GetBaseMultiInstallCommand() { | 200 CommandLine ChromeMiniInstaller::GetBaseMultiInstallCommand() { |
| 194 FilePath mini_installer; | 201 FilePath mini_installer; |
| 195 if (!GetMiniInstaller(&mini_installer)) | 202 if (!GetMiniInstaller(&mini_installer)) |
| 196 return CommandLine(CommandLine::NO_PROGRAM); | 203 return CommandLine(CommandLine::NO_PROGRAM); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 209 installer::ExpectValidInstallation(system_install_); | 216 installer::ExpectValidInstallation(system_install_); |
| 210 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 217 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 211 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); | 218 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 212 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); | 219 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); |
| 213 FindChromeShortcut(); | 220 FindChromeShortcut(); |
| 214 LaunchChrome(true); | 221 LaunchChrome(true); |
| 215 } | 222 } |
| 216 | 223 |
| 217 void ChromeMiniInstaller::InstallChromeFrameUsingMultiInstall() { | 224 void ChromeMiniInstaller::InstallChromeFrameUsingMultiInstall() { |
| 218 CommandLine cmd = GetBaseMultiInstallCommand(); | 225 CommandLine cmd = GetBaseMultiInstallCommand(); |
| 226 cmd.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 227 cmd.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 228 cmd.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 229 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 219 RunInstaller(cmd); | 230 RunInstaller(cmd); |
| 220 | 231 |
| 221 // Verify installation. | 232 // Verify installation. |
| 222 InstallationValidator::InstallationType type = | 233 InstallationValidator::InstallationType type = |
| 223 installer::ExpectValidInstallation(system_install_); | 234 installer::ExpectValidInstallation(system_install_); |
| 224 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 235 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 225 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); | 236 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 226 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); | 237 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 227 // Launch IE | 238 // Launch IE |
| 228 LaunchIE(L"gcf:about:version"); | 239 LaunchIE(L"gcf:about:version"); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); | 306 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); |
| 296 return command; | 307 return command; |
| 297 } | 308 } |
| 298 | 309 |
| 299 // Installs chromesetup.exe, waits for the install to finish and then | 310 // Installs chromesetup.exe, waits for the install to finish and then |
| 300 // checks the registry and shortcuts. | 311 // checks the registry and shortcuts. |
| 301 void ChromeMiniInstaller::InstallMetaInstaller() { | 312 void ChromeMiniInstaller::InstallMetaInstaller() { |
| 302 // Install Google Chrome through meta installer. | 313 // Install Google Chrome through meta installer. |
| 303 CommandLine installer(FilePath::FromWStringHack( | 314 CommandLine installer(FilePath::FromWStringHack( |
| 304 mini_installer_constants::kChromeMetaInstallerExe)); | 315 mini_installer_constants::kChromeMetaInstallerExe)); |
| 316 ASSERT_TRUE(file_util::PathExists(installer.GetProgram())); |
| 317 if (is_chrome_frame_) { |
| 318 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 319 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 320 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 321 installer.AppendSwitch(installer::switches::kChromeFrame); |
| 322 } |
| 305 RunInstaller(installer); | 323 RunInstaller(installer); |
| 324 |
| 306 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( | 325 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( |
| 307 mini_installer_constants::kChromeMetaInstallerExecutable)); | 326 mini_installer_constants::kChromeMetaInstallerExecutable)); |
| 308 | 327 |
| 309 std::wstring chrome_google_update_state_key( | 328 std::wstring chrome_google_update_state_key( |
| 310 google_update::kRegPathClients); | 329 google_update::kRegPathClients); |
| 311 chrome_google_update_state_key.append(L"\\"); | 330 chrome_google_update_state_key.append(L"\\"); |
| 312 | 331 |
| 313 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 332 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 314 chrome_google_update_state_key.append(dist->GetAppGuid()); | 333 chrome_google_update_state_key.append(dist->GetAppGuid()); |
| 315 | 334 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 346 MiniInstallerTestUtil::CloseProcesses( | 365 MiniInstallerTestUtil::CloseProcesses( |
| 347 mini_installer_constants::kIEProcessName); | 366 mini_installer_constants::kIEProcessName); |
| 348 } else { | 367 } else { |
| 349 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); | 368 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
| 350 } | 369 } |
| 351 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 370 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 352 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { | 371 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { |
| 353 std::string build_number; | 372 std::string build_number; |
| 354 ASSERT_TRUE(GetChromeVersionFromRegistry(&build_number)); | 373 ASSERT_TRUE(GetChromeVersionFromRegistry(&build_number)); |
| 355 FilePath install_path; | 374 FilePath install_path; |
| 356 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 375 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 357 install_path = install_path.AppendASCII(build_number); | 376 install_path = install_path.AppendASCII(build_number); |
| 358 ASSERT_TRUE(file_util::Delete(install_path, true)); | 377 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 359 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { | 378 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { |
| 360 DeletePvRegistryKey(); | 379 DeletePvRegistryKey(); |
| 361 printf("Deleted registry. Now trying to launch chrome\n"); | 380 printf("Deleted registry. Now trying to launch chrome\n"); |
| 362 } | 381 } |
| 363 FilePath current_path; | 382 FilePath current_path; |
| 364 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); | 383 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); |
| 365 LaunchChrome(false); | 384 LaunchChrome(false); |
| 366 LOG(INFO) << "Installing Chrome again to see if it can be repaired."; | 385 LOG(INFO) << "Installing Chrome again to see if it can be repaired."; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 472 |
| 454 DeleteUserDataFolder(); | 473 DeleteUserDataFolder(); |
| 455 MiniInstallerTestUtil::CloseProcesses( | 474 MiniInstallerTestUtil::CloseProcesses( |
| 456 mini_installer_constants::kIEProcessName); | 475 mini_installer_constants::kIEProcessName); |
| 457 } | 476 } |
| 458 | 477 |
| 459 // Will clean up the machine if Chrome install is messed up. | 478 // Will clean up the machine if Chrome install is messed up. |
| 460 void ChromeMiniInstaller::CleanChromeInstall() { | 479 void ChromeMiniInstaller::CleanChromeInstall() { |
| 461 DeletePvRegistryKey(); | 480 DeletePvRegistryKey(); |
| 462 FilePath install_path; | 481 FilePath install_path; |
| 463 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 482 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 464 ASSERT_TRUE(file_util::Delete(install_path, true)); | 483 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 465 } | 484 } |
| 466 | 485 |
| 467 bool ChromeMiniInstaller::CloseUninstallWindow() { | 486 bool ChromeMiniInstaller::CloseUninstallWindow() { |
| 468 HWND hndl = NULL; | 487 HWND hndl = NULL; |
| 469 int timer = 0; | 488 int timer = 0; |
| 470 std::wstring window_name; | 489 std::wstring window_name; |
| 471 if (is_chrome_frame_) | 490 if (is_chrome_frame_) |
| 472 window_name = mini_installer_constants::kChromeFrameAppName; | 491 window_name = mini_installer_constants::kChromeFrameAppName; |
| 473 else | 492 else |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 634 } |
| 616 if (return_val) { | 635 if (return_val) { |
| 617 LOG(INFO) << "Found Chrome shortcuts:\n" | 636 LOG(INFO) << "Found Chrome shortcuts:\n" |
| 618 << path.value() << "\n" | 637 << path.value() << "\n" |
| 619 << uninstall_lnk.value(); | 638 << uninstall_lnk.value(); |
| 620 } else { | 639 } else { |
| 621 LOG(INFO) << "No Chrome shortcuts found."; | 640 LOG(INFO) << "No Chrome shortcuts found."; |
| 622 } | 641 } |
| 623 } | 642 } |
| 624 | 643 |
| 625 bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) { | 644 bool ChromeMiniInstaller::GetInstallDirectory(FilePath* path) { |
| 626 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 645 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 627 *path = installer::GetChromeInstallPath(system_install_, dist); | 646 *path = installer::GetChromeInstallPath(system_install_, dist); |
| 628 FilePath parent; | 647 FilePath parent; |
| 629 if (system_install_) { | 648 if (system_install_) { |
| 630 PathService::Get(base::DIR_PROGRAM_FILES, &parent); | 649 PathService::Get(base::DIR_PROGRAM_FILES, &parent); |
| 631 return file_util::ContainsPath(parent, *path); | 650 return file_util::ContainsPath(parent, *path); |
| 632 } else { | 651 } else { |
| 633 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); | 652 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); |
| 634 return file_util::ContainsPath(parent, *path); | 653 return file_util::ContainsPath(parent, *path); |
| 635 } | 654 } |
| 636 } | 655 } |
| 637 | 656 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 661 } | 680 } |
| 662 | 681 |
| 663 // Get HKEY based on install type. | 682 // Get HKEY based on install type. |
| 664 HKEY ChromeMiniInstaller::GetRootRegistryKey() { | 683 HKEY ChromeMiniInstaller::GetRootRegistryKey() { |
| 665 HKEY type = HKEY_CURRENT_USER; | 684 HKEY type = HKEY_CURRENT_USER; |
| 666 if (system_install_) | 685 if (system_install_) |
| 667 type = HKEY_LOCAL_MACHINE; | 686 type = HKEY_LOCAL_MACHINE; |
| 668 return type; | 687 return type; |
| 669 } | 688 } |
| 670 | 689 |
| 671 // Launches the chrome installer and waits for it to end. | |
| 672 void ChromeMiniInstaller::RunInstaller(const CommandLine& command) { | 690 void ChromeMiniInstaller::RunInstaller(const CommandLine& command) { |
| 673 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); | 691 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); |
| 674 CommandLine installer(command); | 692 CommandLine installer(command); |
| 675 if (is_chrome_frame_) { | |
| 676 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); | |
| 677 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); | |
| 678 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); | |
| 679 installer.AppendSwitch(installer::switches::kChromeFrame); | |
| 680 } | |
| 681 if (system_install_) { | 693 if (system_install_) { |
| 682 installer.AppendSwitch(installer::switches::kSystemLevel); | 694 installer.AppendSwitch(installer::switches::kSystemLevel); |
| 683 } | 695 } |
| 684 | 696 |
| 685 LOG(INFO) << "Running installer command: " | 697 LOG(INFO) << "Running installer command: " |
| 686 << installer.GetCommandLineString(); | 698 << installer.GetCommandLineString(); |
| 687 base::ProcessHandle app_handle; | 699 base::ProcessHandle app_handle; |
| 688 ASSERT_TRUE( | 700 ASSERT_TRUE( |
| 689 base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) | 701 base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) |
| 690 << "Installer failed."; | 702 << "Installer failed."; |
| 691 ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000)) | 703 ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000)) |
| 692 << "Installer did not complete."; | 704 << "Installer did not complete."; |
| 693 } | 705 } |
| 694 | 706 |
| 695 void ChromeMiniInstaller::LaunchChrome(bool kill) { | 707 void ChromeMiniInstaller::LaunchChrome(bool kill) { |
| 696 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 708 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 697 | 709 |
| 698 FilePath install_path; | 710 FilePath install_path; |
| 699 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 711 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 700 install_path = install_path.Append(installer::kChromeExe); | 712 install_path = install_path.Append(installer::kChromeExe); |
| 701 CommandLine browser(install_path); | 713 CommandLine browser(install_path); |
| 702 | 714 |
| 703 FilePath exe = browser.GetProgram(); | 715 FilePath exe = browser.GetProgram(); |
| 704 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); | 716 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); |
| 705 base::ProcessHandle chrome; | 717 base::ProcessHandle chrome; |
| 706 ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome)) | 718 ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome)) |
| 707 << "Could not launch process: " << exe.value(); | 719 << "Could not launch process: " << exe.value(); |
| 708 | 720 |
| 709 if (kill) { | 721 if (kill) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 } | 914 } |
| 903 | 915 |
| 904 if (installer.empty()) { | 916 if (installer.empty()) { |
| 905 LOG(WARNING) << "Failed to find installer with pattern: " << pattern; | 917 LOG(WARNING) << "Failed to find installer with pattern: " << pattern; |
| 906 return false; | 918 return false; |
| 907 } | 919 } |
| 908 | 920 |
| 909 *path = installer; | 921 *path = installer; |
| 910 return true; | 922 return true; |
| 911 } | 923 } |
| OLD | NEW |