| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RunInstaller(CommandLine(path)); |
| 186 | |
| 187 std::string version; | 186 std::string version; |
| 188 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) | 187 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) |
| 189 << "Install failed: unable to get version."; | 188 << "Install failed: unable to get version."; |
| 190 VerifyInstall(over_install); | 189 VerifyInstall(over_install); |
| 191 } | 190 } |
| 192 | 191 |
| 193 CommandLine ChromeMiniInstaller::GetBaseMultiInstallCommand() { | 192 CommandLine ChromeMiniInstaller::GetBaseMultiInstallCommand() { |
| 194 FilePath mini_installer; | 193 FilePath mini_installer; |
| 195 if (!GetMiniInstaller(&mini_installer)) | 194 if (!GetMiniInstaller(&mini_installer)) |
| 196 return CommandLine(CommandLine::NO_PROGRAM); | 195 return CommandLine(CommandLine::NO_PROGRAM); |
| 197 CommandLine cmd(mini_installer); | 196 CommandLine cmd(mini_installer); |
| 198 cmd.AppendSwitch(installer::switches::kMultiInstall); | 197 cmd.AppendSwitch(installer::switches::kMultiInstall); |
| 199 return cmd; | 198 return cmd; |
| 200 } | 199 } |
| 201 | 200 |
| 202 void ChromeMiniInstaller::InstallChromeUsingMultiInstall() { | 201 void ChromeMiniInstaller::InstallChromeUsingMultiInstall() { |
| 203 CommandLine cmd = GetBaseMultiInstallCommand(); | 202 CommandLine cmd = GetBaseMultiInstallCommand(); |
| 204 cmd.AppendSwitch(installer::switches::kChrome); | 203 cmd.AppendSwitch(installer::switches::kChrome); |
| 205 RunInstaller(cmd); | 204 RunInstallerCommand(cmd); |
| 206 | 205 |
| 207 // Verify installation. | 206 // Verify installation. |
| 208 InstallationValidator::InstallationType type = | 207 InstallationValidator::InstallationType type = |
| 209 installer::ExpectValidInstallation(system_install_); | 208 installer::ExpectValidInstallation(system_install_); |
| 210 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 209 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 211 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); | 210 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 212 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); | 211 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); |
| 213 FindChromeShortcut(); | 212 FindChromeShortcut(); |
| 214 LaunchChrome(true); | 213 LaunchChrome(true); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void ChromeMiniInstaller::InstallChromeFrameUsingMultiInstall() { | 216 void ChromeMiniInstaller::InstallChromeFrameUsingMultiInstall() { |
| 218 CommandLine cmd = GetBaseMultiInstallCommand(); | 217 CommandLine cmd = GetBaseMultiInstallCommand(); |
| 219 RunInstaller(cmd); | 218 cmd.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 219 cmd.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 220 cmd.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 221 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 222 RunInstallerCommand(cmd); |
| 220 | 223 |
| 221 // Verify installation. | 224 // Verify installation. |
| 222 InstallationValidator::InstallationType type = | 225 InstallationValidator::InstallationType type = |
| 223 installer::ExpectValidInstallation(system_install_); | 226 installer::ExpectValidInstallation(system_install_); |
| 224 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 227 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 225 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); | 228 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 226 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); | 229 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 227 // Launch IE | 230 // Launch IE |
| 228 LaunchIE(L"gcf:about:version"); | 231 LaunchIE(L"gcf:about:version"); |
| 229 if (system_install_) { | 232 if (system_install_) { |
| 230 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); | 233 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); |
| 231 } else { | 234 } else { |
| 232 MiniInstallerTestUtil::VerifyProcessLaunch( | 235 MiniInstallerTestUtil::VerifyProcessLaunch( |
| 233 installer::kChromeFrameHelperExe, true); | 236 installer::kChromeFrameHelperExe, true); |
| 234 } | 237 } |
| 235 FindChromeShortcut(); | 238 FindChromeShortcut(); |
| 236 } | 239 } |
| 237 | 240 |
| 238 void ChromeMiniInstaller::InstallChromeAndChromeFrame(bool ready_mode) { | 241 void ChromeMiniInstaller::InstallChromeAndChromeFrame(bool ready_mode) { |
| 239 CommandLine cmd = GetBaseMultiInstallCommand(); | 242 CommandLine cmd = GetBaseMultiInstallCommand(); |
| 240 cmd.AppendSwitch(installer::switches::kChrome); | 243 cmd.AppendSwitch(installer::switches::kChrome); |
| 241 cmd.AppendSwitch(installer::switches::kChromeFrame); | 244 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 242 if (ready_mode) | 245 if (ready_mode) |
| 243 cmd.AppendSwitch(installer::switches::kChromeFrameReadyMode); | 246 cmd.AppendSwitch(installer::switches::kChromeFrameReadyMode); |
| 244 RunInstaller(cmd); | 247 RunInstallerCommand(cmd); |
| 245 // Verify installation. | 248 // Verify installation. |
| 246 InstallationValidator::InstallationType type = | 249 InstallationValidator::InstallationType type = |
| 247 installer::ExpectValidInstallation(system_install_); | 250 installer::ExpectValidInstallation(system_install_); |
| 248 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 251 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 249 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); | 252 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 250 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); | 253 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); |
| 251 if (ready_mode) { | 254 if (ready_mode) { |
| 252 EXPECT_TRUE(type & | 255 EXPECT_TRUE(type & |
| 253 InstallationValidator::ProductBits::CHROME_FRAME_READY_MODE); | 256 InstallationValidator::ProductBits::CHROME_FRAME_READY_MODE); |
| 254 } | 257 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 MiniInstallerTestUtil::CloseProcesses( | 349 MiniInstallerTestUtil::CloseProcesses( |
| 347 mini_installer_constants::kIEProcessName); | 350 mini_installer_constants::kIEProcessName); |
| 348 } else { | 351 } else { |
| 349 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); | 352 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
| 350 } | 353 } |
| 351 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 354 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 352 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { | 355 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { |
| 353 std::string build_number; | 356 std::string build_number; |
| 354 ASSERT_TRUE(GetChromeVersionFromRegistry(&build_number)); | 357 ASSERT_TRUE(GetChromeVersionFromRegistry(&build_number)); |
| 355 FilePath install_path; | 358 FilePath install_path; |
| 356 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 359 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 357 install_path = install_path.AppendASCII(build_number); | 360 install_path = install_path.AppendASCII(build_number); |
| 358 ASSERT_TRUE(file_util::Delete(install_path, true)); | 361 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 359 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { | 362 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { |
| 360 DeletePvRegistryKey(); | 363 DeletePvRegistryKey(); |
| 361 printf("Deleted registry. Now trying to launch chrome\n"); | 364 printf("Deleted registry. Now trying to launch chrome\n"); |
| 362 } | 365 } |
| 363 FilePath current_path; | 366 FilePath current_path; |
| 364 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); | 367 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); |
| 365 LaunchChrome(false); | 368 LaunchChrome(false); |
| 366 LOG(INFO) << "Installing Chrome again to see if it can be repaired."; | 369 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 | 456 |
| 454 DeleteUserDataFolder(); | 457 DeleteUserDataFolder(); |
| 455 MiniInstallerTestUtil::CloseProcesses( | 458 MiniInstallerTestUtil::CloseProcesses( |
| 456 mini_installer_constants::kIEProcessName); | 459 mini_installer_constants::kIEProcessName); |
| 457 } | 460 } |
| 458 | 461 |
| 459 // Will clean up the machine if Chrome install is messed up. | 462 // Will clean up the machine if Chrome install is messed up. |
| 460 void ChromeMiniInstaller::CleanChromeInstall() { | 463 void ChromeMiniInstaller::CleanChromeInstall() { |
| 461 DeletePvRegistryKey(); | 464 DeletePvRegistryKey(); |
| 462 FilePath install_path; | 465 FilePath install_path; |
| 463 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 466 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 464 ASSERT_TRUE(file_util::Delete(install_path, true)); | 467 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 465 } | 468 } |
| 466 | 469 |
| 467 bool ChromeMiniInstaller::CloseUninstallWindow() { | 470 bool ChromeMiniInstaller::CloseUninstallWindow() { |
| 468 HWND hndl = NULL; | 471 HWND hndl = NULL; |
| 469 int timer = 0; | 472 int timer = 0; |
| 470 std::wstring window_name; | 473 std::wstring window_name; |
| 471 if (is_chrome_frame_) | 474 if (is_chrome_frame_) |
| 472 window_name = mini_installer_constants::kChromeFrameAppName; | 475 window_name = mini_installer_constants::kChromeFrameAppName; |
| 473 else | 476 else |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 618 } |
| 616 if (return_val) { | 619 if (return_val) { |
| 617 LOG(INFO) << "Found Chrome shortcuts:\n" | 620 LOG(INFO) << "Found Chrome shortcuts:\n" |
| 618 << path.value() << "\n" | 621 << path.value() << "\n" |
| 619 << uninstall_lnk.value(); | 622 << uninstall_lnk.value(); |
| 620 } else { | 623 } else { |
| 621 LOG(INFO) << "No Chrome shortcuts found."; | 624 LOG(INFO) << "No Chrome shortcuts found."; |
| 622 } | 625 } |
| 623 } | 626 } |
| 624 | 627 |
| 625 bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) { | 628 bool ChromeMiniInstaller::GetInstallDirectory(FilePath* path) { |
| 626 BrowserDistribution* dist = GetCurrentBrowserDistribution(); | 629 BrowserDistribution* dist = GetCurrentBrowserDistribution(); |
| 627 *path = installer::GetChromeInstallPath(system_install_, dist); | 630 *path = installer::GetChromeInstallPath(system_install_, dist); |
| 628 FilePath parent; | 631 FilePath parent; |
| 629 if (system_install_) { | 632 if (system_install_) { |
| 630 PathService::Get(base::DIR_PROGRAM_FILES, &parent); | 633 PathService::Get(base::DIR_PROGRAM_FILES, &parent); |
| 631 return file_util::ContainsPath(parent, *path); | 634 return file_util::ContainsPath(parent, *path); |
| 632 } else { | 635 } else { |
| 633 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); | 636 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); |
| 634 return file_util::ContainsPath(parent, *path); | 637 return file_util::ContainsPath(parent, *path); |
| 635 } | 638 } |
| 636 } | 639 } |
| 637 | 640 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 // Launches the chrome installer and waits for it to end. | 674 // Launches the chrome installer and waits for it to end. |
| 672 void ChromeMiniInstaller::RunInstaller(const CommandLine& command) { | 675 void ChromeMiniInstaller::RunInstaller(const CommandLine& command) { |
| 673 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); | 676 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); |
| 674 CommandLine installer(command); | 677 CommandLine installer(command); |
| 675 if (is_chrome_frame_) { | 678 if (is_chrome_frame_) { |
| 676 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); | 679 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 677 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); | 680 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 678 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); | 681 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 679 installer.AppendSwitch(installer::switches::kChromeFrame); | 682 installer.AppendSwitch(installer::switches::kChromeFrame); |
| 680 } | 683 } |
| 684 RunInstallerCommand(installer); |
| 685 } |
| 686 |
| 687 void ChromeMiniInstaller::RunInstallerCommand(const CommandLine& command) { |
| 688 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); |
| 689 CommandLine installer(command); |
| 681 if (system_install_) { | 690 if (system_install_) { |
| 682 installer.AppendSwitch(installer::switches::kSystemLevel); | 691 installer.AppendSwitch(installer::switches::kSystemLevel); |
| 683 } | 692 } |
| 684 | 693 |
| 685 LOG(INFO) << "Running installer command: " | 694 LOG(INFO) << "Running installer command: " |
| 686 << installer.GetCommandLineString(); | 695 << installer.GetCommandLineString(); |
| 687 base::ProcessHandle app_handle; | 696 base::ProcessHandle app_handle; |
| 688 ASSERT_TRUE( | 697 ASSERT_TRUE( |
| 689 base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) | 698 base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) |
| 690 << "Installer failed."; | 699 << "Installer failed."; |
| 691 ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000)) | 700 ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000)) |
| 692 << "Installer did not complete."; | 701 << "Installer did not complete."; |
| 693 } | 702 } |
| 694 | 703 |
| 695 void ChromeMiniInstaller::LaunchChrome(bool kill) { | 704 void ChromeMiniInstaller::LaunchChrome(bool kill) { |
| 696 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 705 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 697 | 706 |
| 698 FilePath install_path; | 707 FilePath install_path; |
| 699 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | 708 ASSERT_TRUE(GetInstallDirectory(&install_path)); |
| 700 install_path = install_path.Append(installer::kChromeExe); | 709 install_path = install_path.Append(installer::kChromeExe); |
| 701 CommandLine browser(install_path); | 710 CommandLine browser(install_path); |
| 702 | 711 |
| 703 FilePath exe = browser.GetProgram(); | 712 FilePath exe = browser.GetProgram(); |
| 704 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); | 713 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); |
| 705 base::ProcessHandle chrome; | 714 base::ProcessHandle chrome; |
| 706 ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome)) | 715 ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome)) |
| 707 << "Could not launch process: " << exe.value(); | 716 << "Could not launch process: " << exe.value(); |
| 708 | 717 |
| 709 if (kill) { | 718 if (kill) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 } | 911 } |
| 903 | 912 |
| 904 if (installer.empty()) { | 913 if (installer.empty()) { |
| 905 LOG(WARNING) << "Failed to find installer with pattern: " << pattern; | 914 LOG(WARNING) << "Failed to find installer with pattern: " << pattern; |
| 906 return false; | 915 return false; |
| 907 } | 916 } |
| 908 | 917 |
| 909 *path = installer; | 918 *path = installer; |
| 910 return true; | 919 return true; |
| 911 } | 920 } |
| OLD | NEW |