Chromium Code Reviews| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/process.h" | 12 #include "base/process.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 18 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
| 20 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| 21 #include "chrome/installer/util/helper.h" | |
| 22 #include "chrome/installer/util/install_util.h" | |
| 21 #include "chrome/installer/util/installation_validation_helper.h" | 23 #include "chrome/installer/util/installation_validation_helper.h" |
| 24 #include "chrome/installer/util/util_constants.h" | |
| 25 #include "chrome/test/base/chrome_process_util.h" | |
| 22 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" | 26 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" |
| 23 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" | 27 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 29 |
| 26 using base::win::RegKey; | 30 using base::win::RegKey; |
| 31 using installer::InstallationValidator; | |
| 27 | 32 |
| 28 namespace { | 33 namespace { |
| 29 | 34 |
| 30 struct FilePathInfo { | 35 struct FilePathInfo { |
| 31 file_util::FileEnumerator::FindInfo info; | 36 file_util::FileEnumerator::FindInfo info; |
| 32 FilePath path; | 37 FilePath path; |
| 33 }; | 38 }; |
| 34 | 39 |
| 35 bool CompareDate(const FilePathInfo& a, | 40 bool CompareDate(const FilePathInfo& a, |
| 36 const FilePathInfo& b) { | 41 const FilePathInfo& b) { |
| 37 #if defined(OS_POSIX) | 42 #if defined(OS_POSIX) |
| 38 return a.info.stat.st_mtime > b.info.stat.st_mtime; | 43 return a.info.stat.st_mtime > b.info.stat.st_mtime; |
| 39 #elif defined(OS_WIN) | 44 #elif defined(OS_WIN) |
| 40 if (a.info.ftLastWriteTime.dwHighDateTime == | 45 if (a.info.ftLastWriteTime.dwHighDateTime == |
| 41 b.info.ftLastWriteTime.dwHighDateTime) { | 46 b.info.ftLastWriteTime.dwHighDateTime) { |
| 42 return a.info.ftLastWriteTime.dwLowDateTime > | 47 return a.info.ftLastWriteTime.dwLowDateTime > |
| 43 b.info.ftLastWriteTime.dwLowDateTime; | 48 b.info.ftLastWriteTime.dwLowDateTime; |
| 44 } else { | 49 } else { |
| 45 return a.info.ftLastWriteTime.dwHighDateTime > | 50 return a.info.ftLastWriteTime.dwHighDateTime > |
| 46 b.info.ftLastWriteTime.dwHighDateTime; | 51 b.info.ftLastWriteTime.dwHighDateTime; |
| 47 } | 52 } |
| 48 #endif | 53 #endif |
| 49 } | 54 } |
| 50 | 55 |
| 56 class ChromeProcessFilter : public base::ProcessFilter { | |
|
kkania
2011/09/28 18:02:43
this isn't used, remove
Huyen
2011/09/28 18:55:48
Done.
| |
| 57 public: | |
| 58 explicit ChromeProcessFilter(base::ProcessId pid) | |
| 59 : process_id(pid) {} | |
| 60 | |
| 61 virtual bool Includes(const base::ProcessEntry& entry) const { | |
| 62 return process_id == entry.pid(); | |
| 63 } | |
| 64 | |
| 65 private: | |
| 66 const base::ProcessId process_id; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(ChromeProcessFilter); | |
| 69 }; | |
| 70 | |
| 51 // Get list of file |type| matching |pattern| in |root|. | 71 // Get list of file |type| matching |pattern| in |root|. |
| 52 // The list is sorted in last modified date order. | 72 // The list is sorted in last modified date order. |
| 53 // Return true if files/directories are found. | 73 // Return true if files/directories are found. |
| 54 bool FindMatchingFiles(const FilePath& root, | 74 bool FindMatchingFiles(const FilePath& root, |
| 55 const FilePath::StringType& pattern, | 75 const FilePath::StringType& pattern, |
| 56 file_util::FileEnumerator::FileType type, | 76 file_util::FileEnumerator::FileType type, |
| 57 std::vector<FilePath>* paths) { | 77 std::vector<FilePath>* paths) { |
| 58 file_util::FileEnumerator files(root, false, type, pattern); | 78 file_util::FileEnumerator files(root, false, type, pattern); |
| 59 std::vector<FilePathInfo> matches; | 79 std::vector<FilePathInfo> matches; |
| 60 for (FilePath current = files.Next(); !current.empty(); | 80 for (FilePath current = files.Next(); !current.empty(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 83 std::vector<FilePath> paths; | 103 std::vector<FilePath> paths; |
| 84 if (FindMatchingFiles(root, pattern, type, &paths)) { | 104 if (FindMatchingFiles(root, pattern, type, &paths)) { |
| 85 *path = paths[0]; | 105 *path = paths[0]; |
| 86 return true; | 106 return true; |
| 87 } | 107 } |
| 88 return false; | 108 return false; |
| 89 } | 109 } |
| 90 | 110 |
| 91 } // namespace | 111 } // namespace |
| 92 | 112 |
| 93 ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type, | 113 ChromeMiniInstaller::ChromeMiniInstaller(bool system_install, |
| 94 bool is_chrome_frame) | 114 bool is_chrome_frame) |
| 95 : is_chrome_frame_(is_chrome_frame), | 115 : is_chrome_frame_(is_chrome_frame), |
| 96 install_type_(install_type) {} | 116 system_install_(system_install) {} |
| 97 | 117 |
| 98 void ChromeMiniInstaller::SetBuildUnderTest( | 118 void ChromeMiniInstaller::SetBuildUnderTest( |
| 99 const std::wstring& build) { | 119 const std::wstring& build) { |
| 100 if (!LocateInstallers(build)) { | 120 if (!LocateInstallers(build)) { |
| 101 LOG(WARNING) << "Could not find one or more installers."; | 121 LOG(WARNING) << "Could not find one or more installers."; |
| 102 } | 122 } |
| 103 } | 123 } |
| 104 | 124 |
| 105 // Installs Chrome. | 125 // Installs Chrome. |
| 106 void ChromeMiniInstaller::Install() { | 126 void ChromeMiniInstaller::Install() { |
| 107 FilePath installer_path = MiniInstallerTestUtil::GetFilePath( | 127 InstallMiniInstaller(false, mini_installer_); |
| 108 mini_installer_constants::kChromeMiniInstallerExecutable); | |
| 109 InstallMiniInstaller(false, installer_path); | |
| 110 } | 128 } |
| 111 | 129 |
| 112 // This method will get the previous latest full installer from | 130 // This method will get the previous latest full installer from |
| 113 // nightly location, install it and over install with specified install_type. | 131 // nightly location, install it and over install with specified install_type. |
| 114 void ChromeMiniInstaller::OverInstallOnFullInstaller( | 132 void ChromeMiniInstaller::OverInstallOnFullInstaller( |
| 115 const std::wstring& install_type, bool should_start_ie) { | 133 const std::wstring& install_type, bool should_start_ie) { |
| 116 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() && | 134 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() && |
| 117 !previous_installer_.empty()); | 135 !previous_installer_.empty()); |
| 118 | 136 |
| 119 if (should_start_ie) | 137 if (should_start_ie) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 // This method will get the latest full installer from nightly location | 175 // This method will get the latest full installer from nightly location |
| 158 // and installs it. | 176 // and installs it. |
| 159 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { | 177 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { |
| 160 if (!full_installer_.empty()) | 178 if (!full_installer_.empty()) |
| 161 InstallMiniInstaller(over_install, full_installer_); | 179 InstallMiniInstaller(over_install, full_installer_); |
| 162 } | 180 } |
| 163 | 181 |
| 164 // Installs the Chrome mini-installer, checks the registry and shortcuts. | 182 // Installs the Chrome mini-installer, checks the registry and shortcuts. |
| 165 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, | 183 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, |
| 166 const FilePath& path) { | 184 const FilePath& path) { |
| 167 LOG(INFO) << "Chrome will be installed at " | 185 LOG(INFO) << "Install level is: " |
| 168 << install_type_ << "level."; | 186 << (system_install_ ? "system" : "user"); |
| 169 LOG(INFO) << "Will proceed with the test only if this path exists: " | 187 LaunchInstaller(CommandLine(path)); |
| 170 << path.value(); | |
| 171 | 188 |
| 172 ASSERT_TRUE(file_util::PathExists(path)) << path.value() | 189 std::wstring version; |
| 173 << " does not exist."; | 190 ASSERT_TRUE(GetChromeVersionFromRegistry(&version)) |
| 174 LaunchInstaller(path, path.BaseName().value().c_str()); | 191 << "Install failed: unable to get version."; |
| 192 VerifyInstall(over_install); | |
| 193 } | |
| 194 | |
| 195 void ChromeMiniInstaller::InstallUsingMultiInstall() { | |
| 196 ASSERT_TRUE(file_util::PathExists(mini_installer_)); | |
| 197 CommandLine cmd(mini_installer_); | |
| 198 cmd.AppendSwitch(installer::switches::kMultiInstall); | |
| 199 cmd.AppendSwitch(installer::switches::kChrome); | |
| 200 LaunchInstaller(cmd); | |
| 201 | |
| 202 // Verify installation. | |
| 203 InstallationValidator::InstallationType type = | |
| 204 installer::ExpectValidInstallation(system_install_); | |
| 175 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 205 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 176 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())) << dist->GetVersionKey() | 206 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); |
| 177 << " does not exist."; | 207 if (is_chrome_frame_) { |
| 178 VerifyInstall(over_install); | 208 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); |
| 209 VerifyChromeFrameInstall(); | |
| 210 } else { | |
| 211 EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); | |
| 212 } | |
| 213 FindChromeShortcut(); | |
| 214 LaunchChrome(false); | |
| 179 } | 215 } |
| 180 | 216 |
| 181 // This method tests the standalone installer by verifying the steps listed at: | 217 // This method tests the standalone installer by verifying the steps listed at: |
| 182 // https://sites.google.com/a/google.com/chrome-pmo/ | 218 // https://sites.google.com/a/google.com/chrome-pmo/ |
| 183 // standalone-installers/testing-standalone-installers | 219 // standalone-installers/testing-standalone-installers |
| 184 // This method applies appropriate tags to standalone installer and deletes | 220 // This method applies appropriate tags to standalone installer and deletes |
| 185 // old installer before running the new tagged installer. It also verifies | 221 // old installer before running the new tagged installer. It also verifies |
| 186 // that the installed version is correct. | 222 // that the installed version is correct. |
| 187 void ChromeMiniInstaller::InstallStandaloneInstaller() { | 223 void ChromeMiniInstaller::InstallStandaloneInstaller() { |
| 188 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); | 224 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 211 tagged_installer.value().c_str(), | 247 tagged_installer.value().c_str(), |
| 212 mini_installer_constants::kChromeApplyTagParameters)); | 248 mini_installer_constants::kChromeApplyTagParameters)); |
| 213 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); | 249 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); |
| 214 return command; | 250 return command; |
| 215 } | 251 } |
| 216 | 252 |
| 217 // Installs chromesetup.exe, waits for the install to finish and then | 253 // Installs chromesetup.exe, waits for the install to finish and then |
| 218 // checks the registry and shortcuts. | 254 // checks the registry and shortcuts. |
| 219 void ChromeMiniInstaller::InstallMetaInstaller() { | 255 void ChromeMiniInstaller::InstallMetaInstaller() { |
| 220 // Install Google Chrome through meta installer. | 256 // Install Google Chrome through meta installer. |
| 221 LaunchInstaller(FilePath(mini_installer_constants::kChromeMetaInstallerExe), | 257 CommandLine installer(FilePath::FromWStringHack( |
|
kkania
2011/09/28 18:02:43
just do FilePath(...) instead of FromWStringHack
Huyen
2011/09/28 18:55:48
FilePath doesn't have a constructor for wchar_t.
| |
| 222 mini_installer_constants::kChromeSetupExecutable); | 258 mini_installer_constants::kChromeMetaInstallerExe)); |
| 259 LaunchInstaller(installer); | |
| 223 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( | 260 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( |
| 224 mini_installer_constants::kChromeMetaInstallerExecutable)); | 261 mini_installer_constants::kChromeMetaInstallerExecutable)); |
| 262 | |
| 225 std::wstring chrome_google_update_state_key( | 263 std::wstring chrome_google_update_state_key( |
| 226 google_update::kRegPathClients); | 264 google_update::kRegPathClients); |
| 227 chrome_google_update_state_key.append(L"\\"); | 265 chrome_google_update_state_key.append(L"\\"); |
| 228 | 266 |
| 229 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 267 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 230 chrome_google_update_state_key.append(dist->GetAppGuid()); | 268 chrome_google_update_state_key.append(dist->GetAppGuid()); |
| 231 | 269 |
| 232 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); | 270 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); |
| 233 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); | 271 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); |
| 234 FindChromeShortcut(); | 272 FindChromeShortcut(); |
| 235 LaunchAndCloseChrome(false); | 273 LaunchChrome(true); |
| 236 } | 274 } |
| 237 | 275 |
| 238 // If the build type is Google Chrome, then it first installs meta installer | 276 // If the build type is Google Chrome, then it first installs meta installer |
| 239 // and then over installs with mini_installer. It also verifies if Chrome can | 277 // and then over installs with mini_installer. It also verifies if Chrome can |
| 240 // be launched successfully after overinstall. | 278 // be launched successfully after overinstall. |
| 241 void ChromeMiniInstaller::OverInstall() { | 279 void ChromeMiniInstaller::OverInstall() { |
| 242 InstallMetaInstaller(); | 280 InstallMetaInstaller(); |
| 243 std::wstring reg_key_value_returned; | 281 std::wstring reg_key_value_returned; |
| 244 // gets the registry key value before overinstall. | 282 // gets the registry key value before overinstall. |
| 245 GetChromeVersionFromRegistry(®_key_value_returned); | 283 GetChromeVersionFromRegistry(®_key_value_returned); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 267 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 305 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 268 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { | 306 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { |
| 269 DeleteFolder(L"version_folder"); | 307 DeleteFolder(L"version_folder"); |
| 270 printf("Deleted folder. Now trying to launch chrome\n"); | 308 printf("Deleted folder. Now trying to launch chrome\n"); |
| 271 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { | 309 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { |
| 272 DeletePvRegistryKey(); | 310 DeletePvRegistryKey(); |
| 273 printf("Deleted registry. Now trying to launch chrome\n"); | 311 printf("Deleted registry. Now trying to launch chrome\n"); |
| 274 } | 312 } |
| 275 FilePath current_path; | 313 FilePath current_path; |
| 276 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); | 314 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); |
| 277 VerifyChromeLaunch(false); | 315 LaunchChrome(false); |
| 278 printf("\nInstalling Chrome again to see if it can be repaired\n\n"); | 316 LOG(INFO) << "Installing Chrome again to see if it can be repaired."; |
| 279 InstallFullInstaller(true); | 317 InstallFullInstaller(true); |
| 280 printf("Chrome repair successful.\n"); | 318 LOG(INFO) << "Chrome repair successful."; |
| 281 // Set the current directory back to original path. | 319 // Set the current directory back to original path. |
| 282 file_util::SetCurrentDirectory(current_path); | 320 file_util::SetCurrentDirectory(current_path); |
| 283 } | 321 } |
| 284 | 322 |
| 285 // This method first checks if Chrome is running. | 323 // This method first checks if Chrome is running. |
| 286 // If yes, will close all the processes. | 324 // If yes, will close all the processes. |
| 287 // Then will find and spawn uninstall path. | 325 // Then will find and spawn uninstall path. |
| 288 // Handles uninstall confirm dialog. | 326 // Handles uninstall confirm dialog. |
| 289 // Waits until setup.exe ends. | 327 // Waits until setup.exe ends. |
| 290 // Checks if registry key exist even after uninstall. | 328 // Checks if registry key exist even after uninstall. |
| 291 // Deletes App dir. | 329 // Deletes App dir. |
| 292 // Closes feedback form. | 330 // Closes feedback form. |
| 293 void ChromeMiniInstaller::UnInstall() { | 331 void ChromeMiniInstaller::UnInstall() { |
| 294 std::wstring product_name; | |
| 295 if (is_chrome_frame_) | |
| 296 product_name = mini_installer_constants::kChromeFrameProductName; | |
| 297 else | |
| 298 product_name = mini_installer_constants::kChromeProductName; | |
| 299 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 332 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 300 if (!CheckRegistryKey(dist->GetVersionKey())) { | 333 std::wstring version; |
| 301 printf("%ls is not installed.\n", product_name.c_str()); | 334 std::string result; |
| 335 | |
| 336 if (!GetChromeVersionFromRegistry(&version)) | |
| 302 return; | 337 return; |
| 303 } | 338 |
| 339 // Close running products. | |
| 304 if (is_chrome_frame_) { | 340 if (is_chrome_frame_) { |
| 305 MiniInstallerTestUtil::CloseProcesses( | 341 MiniInstallerTestUtil::CloseProcesses( |
| 306 mini_installer_constants::kIEProcessName); | 342 mini_installer_constants::kIEProcessName); |
| 307 } else { | 343 } else { |
| 308 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); | 344 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
| 309 } | 345 } |
| 310 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 346 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 311 std::wstring uninstall_path = GetUninstallPath(); | 347 // Get uninstall command. |
| 312 if (uninstall_path.empty()) { | 348 CommandLine cmd = InstallUtil::GetChromeUninstallCmd( |
| 313 printf("\n %ls install is in a weird state. Cleaning the machine...\n", | 349 system_install_, dist->GetType()); |
| 314 product_name.c_str()); | 350 |
| 315 CleanChromeInstall(); | 351 ASSERT_FALSE(cmd.GetCommandLineString().empty()) |
|
kkania
2011/09/28 18:02:43
don't need this
Huyen
2011/09/28 18:55:48
Done.
| |
| 316 return; | 352 << "Unable to get uninstall command."; |
| 317 } | 353 |
| 318 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); | 354 LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString(); |
| 319 std::wstring uninstall_args(L"\""); | 355 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram())) |
| 320 uninstall_args.append(uninstall_path); | 356 << "Uninstall executable does not exist."; |
| 321 uninstall_args.append(L"\" --uninstall --force-uninstall"); | 357 |
| 358 cmd.AppendSwitch(installer::switches::kUninstall); | |
| 359 cmd.AppendSwitch(installer::switches::kForceUninstall); | |
| 322 if (is_chrome_frame_) | 360 if (is_chrome_frame_) |
| 323 uninstall_args.append(L" --chrome-frame"); | 361 cmd.AppendSwitch(installer::switches::kChromeFrame); |
| 324 if (install_type_ == mini_installer_constants::kSystemInstall) | 362 if (system_install_) |
| 325 uninstall_args = uninstall_args + L" --system-level"; | 363 cmd.AppendSwitch(installer::switches::kSystemLevel); |
| 326 | 364 |
| 327 base::ProcessHandle setup_handle; | 365 base::ProcessHandle setup_handle; |
| 328 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle); | 366 ASSERT_TRUE(base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle)) |
| 367 << "Failed to launch uninstall command."; | |
| 329 | 368 |
| 330 if (is_chrome_frame_) | 369 if (is_chrome_frame_) |
| 331 ASSERT_TRUE(CloseUninstallWindow()); | 370 ASSERT_TRUE(CloseUninstallWindow()); |
| 332 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); | 371 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); |
| 333 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); | 372 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())) |
| 373 << "It appears Chrome was not completely uninstalled."; | |
| 334 | 374 |
| 335 DeleteUserDataFolder(); | 375 DeleteUserDataFolder(); |
| 336 // Close IE survey window that gets launched on uninstall. | 376 // Close IE survey window that gets launched on uninstall. |
| 337 if (!is_chrome_frame_) { | 377 if (!is_chrome_frame_) { |
| 338 FindChromeShortcut(); | 378 FindChromeShortcut(); |
| 339 MiniInstallerTestUtil::CloseProcesses( | 379 MiniInstallerTestUtil::CloseProcesses( |
| 340 mini_installer_constants::kIEExecutable); | 380 mini_installer_constants::kIEExecutable); |
| 341 ASSERT_EQ(0, | 381 ASSERT_EQ(0, |
| 342 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); | 382 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); |
| 343 } | 383 } |
| 344 } | 384 } |
| 345 | 385 |
| 346 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { | 386 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { |
| 387 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
| 347 std::wstring product_name = | 388 std::wstring product_name = |
| 348 mini_installer_constants::kChromeFrameProductName; | 389 mini_installer_constants::kChromeFrameProductName; |
| 349 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
| 350 if (!CheckRegistryKey(dist->GetVersionKey())) { | 390 if (!CheckRegistryKey(dist->GetVersionKey())) { |
| 351 printf("%ls is not installed.\n", product_name.c_str()); | 391 printf("%ls is not installed.\n", product_name.c_str()); |
| 352 return; | 392 return; |
| 353 } | 393 } |
| 354 | 394 |
| 355 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | 395 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 356 std::wstring uninstall_path = GetUninstallPath(); | |
| 357 | 396 |
| 358 if (uninstall_path.empty()) { | 397 CommandLine cmd = InstallUtil::GetChromeUninstallCmd( |
| 359 printf("\n %ls install is in a weird state. Cleaning the machine...\n", | 398 system_install_, dist->GetType()); |
| 360 product_name.c_str()); | 399 |
| 400 if (cmd.GetCommandLineString().empty()) { | |
|
kkania
2011/09/28 18:02:43
if (cmd.GetProgram().empty())
Huyen
2011/09/28 18:55:48
Done.
| |
| 401 LOG(ERROR) << "Unable to get uninstall command."; | |
| 361 CleanChromeInstall(); | 402 CleanChromeInstall(); |
| 362 return; | |
| 363 } | 403 } |
| 364 | 404 |
| 365 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); | 405 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram())); |
| 366 std::wstring uninstall_args(L"\""); | |
| 367 uninstall_args.append(uninstall_path); | |
| 368 uninstall_args.append(L"\" --uninstall --force-uninstall"); | |
| 369 uninstall_args.append(L" --chrome-frame"); | |
| 370 | 406 |
| 371 if (install_type_ == mini_installer_constants::kSystemInstall) | 407 cmd.AppendSwitch(installer::switches::kUninstall); |
| 372 uninstall_args = uninstall_args + L" --system-level"; | 408 cmd.AppendSwitch(installer::switches::kForceUninstall); |
| 409 cmd.AppendSwitch(installer::switches::kChromeFrame); | |
| 410 | |
| 411 if (system_install_) | |
| 412 cmd.AppendSwitch(installer::switches::kSystemLevel); | |
| 373 | 413 |
| 374 base::ProcessHandle setup_handle; | 414 base::ProcessHandle setup_handle; |
| 375 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle); | 415 base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle); |
| 376 | 416 |
| 377 ASSERT_TRUE(CloseUninstallWindow()); | 417 ASSERT_TRUE(CloseUninstallWindow()); |
| 378 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); | 418 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); |
| 379 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); | 419 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); |
| 380 | 420 |
| 381 DeleteUserDataFolder(); | 421 DeleteUserDataFolder(); |
| 382 MiniInstallerTestUtil::CloseProcesses( | 422 MiniInstallerTestUtil::CloseProcesses( |
| 383 mini_installer_constants::kIEProcessName); | 423 mini_installer_constants::kIEProcessName); |
| 384 } | 424 } |
| 385 | 425 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 KEY_ALL_ACCESS) == ERROR_SUCCESS) && | 517 KEY_ALL_ACCESS) == ERROR_SUCCESS) && |
| 478 (timer < 20000)) { | 518 (timer < 20000)) { |
| 479 base::PlatformThread::Sleep(200); | 519 base::PlatformThread::Sleep(200); |
| 480 timer = timer + 200; | 520 timer = timer + 200; |
| 481 } | 521 } |
| 482 return CheckRegistryKey(key_path); | 522 return CheckRegistryKey(key_path); |
| 483 } | 523 } |
| 484 | 524 |
| 485 // Deletes Installer folder from Applications directory. | 525 // Deletes Installer folder from Applications directory. |
| 486 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { | 526 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { |
| 487 FilePath install_path(GetChromeInstallDirectoryLocation()); | 527 FilePath install_path; |
| 528 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); | |
| 488 std::wstring temp_chrome_dir; | 529 std::wstring temp_chrome_dir; |
| 489 if (is_chrome_frame_) { | 530 if (is_chrome_frame_) { |
| 490 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir; | 531 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir; |
| 491 } else { | |
| 492 temp_chrome_dir = mini_installer_constants::kChromeAppDir; | |
| 493 } | 532 } |
| 494 | 533 |
| 495 if (wcscmp(folder_name, L"version_folder") == 0) { | 534 if (wcscmp(folder_name, L"version_folder") == 0) { |
| 496 std::wstring build_number; | 535 std::wstring build_number; |
| 497 GetChromeVersionFromRegistry(&build_number); | 536 GetChromeVersionFromRegistry(&build_number); |
| 498 temp_chrome_dir = temp_chrome_dir + build_number; | 537 temp_chrome_dir = temp_chrome_dir + build_number; |
| 499 install_path = install_path.Append(temp_chrome_dir); | 538 install_path = install_path.Append(temp_chrome_dir); |
| 500 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) { | 539 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) { |
| 501 install_path = install_path.Append(folder_name).StripTrailingSeparators(); | 540 install_path = install_path.Append(folder_name).StripTrailingSeparators(); |
| 502 } | 541 } |
| 503 printf("This path will be deleted: %ls\n", install_path.value().c_str()); | 542 ASSERT_TRUE(file_util::PathExists(install_path)) |
| 543 << "Could not find path to delete:" << install_path.value(); | |
| 544 LOG(INFO) << "This path will be deleted: " << install_path.value(); | |
| 504 ASSERT_TRUE(file_util::Delete(install_path, true)); | 545 ASSERT_TRUE(file_util::Delete(install_path, true)); |
| 505 } | 546 } |
| 506 | 547 |
| 507 // Will delete user data profile. | 548 // Will delete user data profile. |
| 508 void ChromeMiniInstaller::DeleteUserDataFolder() { | 549 void ChromeMiniInstaller::DeleteUserDataFolder() { |
| 509 FilePath path = GetUserDataDirPath(); | 550 FilePath path = GetUserDataDirPath(); |
| 510 if (file_util::PathExists(path)) | 551 if (file_util::PathExists(path)) |
| 511 ASSERT_TRUE(file_util::Delete(path, true)); | 552 ASSERT_TRUE(file_util::Delete(path, true)); |
| 512 } | 553 } |
| 513 | 554 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 if (file_util::PathExists(path)) { | 595 if (file_util::PathExists(path)) { |
| 555 return_val = true; | 596 return_val = true; |
| 556 uninstall_lnk = path; | 597 uninstall_lnk = path; |
| 557 path = path.Append(mini_installer_constants::kChromeLaunchShortcut); | 598 path = path.Append(mini_installer_constants::kChromeLaunchShortcut); |
| 558 uninstall_lnk = uninstall_lnk.Append( | 599 uninstall_lnk = uninstall_lnk.Append( |
| 559 mini_installer_constants::kChromeUninstallShortcut); | 600 mini_installer_constants::kChromeUninstallShortcut); |
| 560 ASSERT_TRUE(file_util::PathExists(path)); | 601 ASSERT_TRUE(file_util::PathExists(path)); |
| 561 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); | 602 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); |
| 562 } | 603 } |
| 563 if (return_val) { | 604 if (return_val) { |
| 564 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", | 605 LOG(INFO) << "Found Chrome shortcuts:\n" |
| 565 path.value().c_str(), uninstall_lnk.value().c_str()); | 606 << path.value() << "\n" |
| 607 << uninstall_lnk.value(); | |
| 566 } else { | 608 } else { |
| 567 printf("Chrome shortcuts not found\n\n"); | 609 LOG(INFO) << "No Chrome shortcuts found."; |
| 568 } | 610 } |
| 569 } | 611 } |
| 570 | 612 |
| 571 // This method returns path to either program files | 613 bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) { |
| 572 // or documents and setting based on the install type. | 614 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 573 std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { | 615 *path = installer::GetChromeInstallPath(system_install_, dist); |
| 574 FilePath path; | 616 FilePath parent; |
| 575 if (install_type_ == mini_installer_constants::kSystemInstall) | 617 if (system_install_) { |
| 576 PathService::Get(base::DIR_PROGRAM_FILES, &path); | 618 PathService::Get(base::DIR_PROGRAM_FILES, &parent); |
| 577 else | 619 return file_util::ContainsPath(parent, *path); |
| 578 PathService::Get(base::DIR_LOCAL_APP_DATA, &path); | 620 } else { |
| 579 return path.value(); | 621 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent); |
| 622 return file_util::ContainsPath(parent, *path); | |
| 623 } | |
| 580 } | 624 } |
| 581 | 625 |
| 582 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { | 626 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { |
| 583 FilePath path_name; | 627 FilePath path_name; |
| 584 if (install_type_ == mini_installer_constants::kSystemInstall) | 628 if (system_install_) |
| 585 PathService::Get(base::DIR_COMMON_START_MENU, &path_name); | 629 PathService::Get(base::DIR_COMMON_START_MENU, &path_name); |
| 586 else | 630 else |
| 587 PathService::Get(base::DIR_START_MENU, &path_name); | 631 PathService::Get(base::DIR_START_MENU, &path_name); |
| 588 return path_name; | 632 return path_name; |
| 589 } | 633 } |
| 590 | 634 |
| 591 // Gets the path for uninstall. | |
| 592 std::wstring ChromeMiniInstaller::GetUninstallPath() { | |
| 593 std::wstring path, reg_key_value; | |
| 594 if (!GetChromeVersionFromRegistry(®_key_value)) | |
| 595 return std::wstring(); | |
| 596 path = GetChromeInstallDirectoryLocation(); | |
| 597 if (is_chrome_frame_) { | |
| 598 file_util::AppendToPath(&path, | |
| 599 mini_installer_constants::kChromeFrameAppDir); | |
| 600 } else { | |
| 601 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | |
| 602 } | |
| 603 file_util::AppendToPath(&path, reg_key_value); | |
| 604 file_util::AppendToPath(&path, installer::kInstallerDir); | |
| 605 file_util::AppendToPath(&path, | |
| 606 mini_installer_constants::kChromeSetupExecutable); | |
| 607 if (!file_util::PathExists(FilePath(path))) { | |
| 608 printf("This uninstall path is not correct %ls. Will not proceed further", | |
| 609 path.c_str()); | |
| 610 return L""; | |
| 611 } | |
| 612 printf("uninstall path is %ls\n", path.c_str()); | |
| 613 return path; | |
| 614 } | |
| 615 | |
| 616 // Returns Chrome pv registry key value | 635 // Returns Chrome pv registry key value |
| 617 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( | 636 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( |
| 618 std::wstring* build_key_value) { | 637 std::wstring* build_key_value) { |
| 619 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 638 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 620 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); | 639 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); |
| 621 LONG result = key.ReadValue(L"pv", build_key_value); | 640 LONG result = key.ReadValue(L"pv", build_key_value); |
| 622 if (result != ERROR_SUCCESS) { | 641 if (result != ERROR_SUCCESS) { |
| 623 printf("registry read for chrome version failed. error: %d\n", result); | 642 LOG(WARNING) << "Registry read for Chrome version error: " << result; |
| 624 return false; | 643 return false; |
| 625 } | 644 } |
| 626 printf("Build key value is %ls\n\n", build_key_value->c_str()); | 645 LOG(INFO) << "Build key value is " << build_key_value; |
| 627 return true; | 646 return true; |
| 628 } | 647 } |
| 629 | 648 |
| 630 // Get HKEY based on install type. | 649 // Get HKEY based on install type. |
| 631 HKEY ChromeMiniInstaller::GetRootRegistryKey() { | 650 HKEY ChromeMiniInstaller::GetRootRegistryKey() { |
| 632 HKEY type = HKEY_CURRENT_USER; | 651 HKEY type = HKEY_CURRENT_USER; |
| 633 if (install_type_ == mini_installer_constants::kSystemInstall) | 652 if (system_install_) |
| 634 type = HKEY_LOCAL_MACHINE; | 653 type = HKEY_LOCAL_MACHINE; |
| 635 return type; | 654 return type; |
| 636 } | 655 } |
| 637 | 656 |
| 638 // Launches the chrome installer and waits for it to end. | 657 // Launches the chrome installer and waits for it to end. |
| 639 void ChromeMiniInstaller::LaunchInstaller(const FilePath& path, | 658 void ChromeMiniInstaller::LaunchInstaller(const CommandLine& command) { |
| 640 const wchar_t* process_name) { | 659 ASSERT_TRUE(file_util::PathExists(command.GetProgram())); |
| 641 ASSERT_TRUE(file_util::PathExists(path)); | 660 CommandLine installer(command); |
| 642 std::wstring launch_args; | |
| 643 if (is_chrome_frame_) { | 661 if (is_chrome_frame_) { |
| 644 launch_args.append(L" --do-not-create-shortcuts"); | 662 installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts); |
| 645 launch_args.append(L" --do-not-launch-chrome"); | 663 installer.AppendSwitch(installer::switches::kDoNotLaunchChrome); |
| 646 launch_args.append(L" --do-not-register-for-update-launch"); | 664 installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch); |
| 647 launch_args.append(L" --chrome-frame"); | 665 installer.AppendSwitch(installer::switches::kChromeFrame); |
| 648 } | 666 } |
| 649 if (install_type_ == mini_installer_constants::kSystemInstall) { | 667 if (system_install_) { |
| 650 launch_args.append(L" --system-level"); | 668 installer.AppendSwitch(installer::switches::kSystemLevel); |
| 651 } | 669 } |
| 652 | 670 |
| 671 LOG(INFO) << "Running installer command: " | |
| 672 << installer.GetCommandLineString(); | |
| 653 base::ProcessHandle app_handle; | 673 base::ProcessHandle app_handle; |
| 654 base::LaunchProcess(L"\"" + path.value() + L"\"" + launch_args, | 674 if (!base::LaunchProcess(installer, base::LaunchOptions(), &app_handle)) |
| 655 base::LaunchOptions(), &app_handle); | 675 LOG(ERROR) << "Installer failed."; |
|
kkania
2011/09/28 18:02:43
this should fail the test, not log. Remove the log
kkania
2011/09/28 18:02:43
macros can expand to multiple lines, so to be safe
Huyen
2011/09/28 18:55:48
Done.
| |
| 656 | 676 |
| 657 printf("Waiting while this process is running %ls ....\n", process_name); | 677 if (!base::WaitForSingleProcess(app_handle, 60 * 1000)) |
| 658 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); | 678 LOG(ERROR) << "Installer did not complete."; |
| 659 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle)); | |
| 660 } | 679 } |
| 661 | 680 |
| 662 // Gets the path to launch Chrome. | 681 void ChromeMiniInstaller::LaunchChrome(bool kill) { |
| 663 bool ChromeMiniInstaller::GetChromeLaunchPath(FilePath* launch_path) { | 682 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
| 664 std::wstring path; | |
| 665 path = GetChromeInstallDirectoryLocation(); | |
| 666 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | |
| 667 file_util::AppendToPath(&path, installer::kChromeExe); | |
| 668 *launch_path = FilePath(path); | |
| 669 return file_util::PathExists(*launch_path); | |
| 670 } | |
| 671 | 683 |
| 672 // Launch Chrome to see if it works after overinstall. Then close it. | 684 FilePath install_path; |
| 673 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { | 685 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path)); |
| 674 VerifyChromeLaunch(true); | 686 install_path = install_path.Append(installer::kChromeExe); |
| 675 if ((install_type_ == mini_installer_constants::kSystemInstall) && | 687 CommandLine browser(install_path); |
| 676 (!over_install)) { | 688 |
| 677 MiniInstallerTestUtil::VerifyProcessLaunch( | 689 FilePath exe = browser.GetProgram(); |
| 678 installer::kChromeExe, true); | 690 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString(); |
| 691 base::ProcessHandle chrome; | |
| 692 bool launched = base::LaunchProcess(browser, base::LaunchOptions(), &chrome); | |
| 693 if (!launched) { | |
| 694 LOG(ERROR) << "Could not launch process: " << exe.value(); | |
|
kkania
2011/09/28 18:02:43
change to error
Huyen
2011/09/28 18:55:48
you mean change to an assert?
| |
| 679 } | 695 } |
| 680 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); | |
| 681 } | |
| 682 | 696 |
| 683 // This method will get Chrome exe path and launch it. | 697 if (kill) { |
| 684 void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { | 698 ASSERT_TRUE(base::KillProcess(chrome, 0, true)); |
| 685 FilePath launch_path; | 699 } |
| 686 GetChromeLaunchPath(&launch_path); | |
| 687 LaunchBrowser(launch_path, L"", expected_status); | |
| 688 } | 700 } |
| 689 | 701 |
| 690 // Verifies Chrome/Chrome Frame install. | 702 // Verifies Chrome/Chrome Frame install. |
| 691 void ChromeMiniInstaller::VerifyInstall(bool over_install) { | 703 void ChromeMiniInstaller::VerifyInstall(bool over_install) { |
| 692 VerifyMachineState(); | |
| 693 if (is_chrome_frame_) { | |
| 694 VerifyChromeFrameInstall(); | |
| 695 } else { | |
| 696 if ((install_type_ == mini_installer_constants::kUserInstall) && | |
| 697 (!over_install)) { | |
| 698 MiniInstallerTestUtil::VerifyProcessLaunch( | |
| 699 installer::kChromeExe, true); | |
| 700 } | |
| 701 base::PlatformThread::Sleep(800); | |
| 702 FindChromeShortcut(); | |
| 703 LaunchAndCloseChrome(over_install); | |
| 704 } | |
| 705 } | |
| 706 | |
| 707 // This method verifies installation of Chrome/Chrome Frame via machine | |
| 708 // introspection. | |
| 709 void ChromeMiniInstaller::VerifyMachineState() { | |
| 710 using installer::InstallationValidator; | |
| 711 | |
| 712 InstallationValidator::InstallationType type = | 704 InstallationValidator::InstallationType type = |
| 713 installer::ExpectValidInstallation( | 705 installer::ExpectValidInstallation(system_install_); |
| 714 install_type_ == mini_installer_constants::kSystemInstall); | |
| 715 if (is_chrome_frame_) { | 706 if (is_chrome_frame_) { |
| 716 EXPECT_NE(0, | 707 EXPECT_NE(0, |
| 717 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE); | 708 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE); |
| 718 } else { | 709 } else { |
| 719 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE); | 710 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE); |
| 720 } | 711 } |
| 712 | |
| 713 if (is_chrome_frame_) | |
| 714 VerifyChromeFrameInstall(); | |
| 715 else if (!system_install_ && !over_install) | |
| 716 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); | |
| 717 | |
| 718 base::PlatformThread::Sleep(800); | |
| 719 FindChromeShortcut(); | |
| 720 LaunchChrome(true); | |
| 721 } | 721 } |
| 722 | 722 |
| 723 // This method will verify if ChromeFrame installed successfully. It will | 723 // This method will verify if ChromeFrame installed successfully. It will |
| 724 // launch IE with cf:about:version, then check if | 724 // launch IE with cf:about:version, then check if |
| 725 // chrome.exe process got spawned. | 725 // chrome.exe process got spawned. |
| 726 void ChromeMiniInstaller::VerifyChromeFrameInstall() { | 726 void ChromeMiniInstaller::VerifyChromeFrameInstall() { |
| 727 // Launch IE | 727 // Launch IE |
| 728 LaunchIE(L"gcf:about:version"); | 728 LaunchIE(L"gcf:about:version"); |
| 729 | 729 |
| 730 // Check if Chrome process got spawned. | 730 // Check if Chrome process got spawned. |
| 731 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); | 731 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) { | 734 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) { |
| 735 FilePath browser_path; | 735 FilePath browser_path; |
| 736 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); | 736 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); |
| 737 browser_path = browser_path.Append(mini_installer_constants::kIELocation); | 737 browser_path = browser_path.Append(mini_installer_constants::kIELocation); |
| 738 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); | 738 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); |
| 739 | 739 |
| 740 CommandLine cmd_line(browser_path); | 740 CommandLine cmd_line(browser_path); |
| 741 cmd_line.AppendArgNative(navigate_url); | 741 cmd_line.AppendArgNative(navigate_url); |
| 742 | 742 |
| 743 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); | 743 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); |
| 744 } | 744 } |
| 745 | 745 |
| 746 // This method will launch any requested browser. | |
| 747 void ChromeMiniInstaller::LaunchBrowser(const FilePath& path, | |
| 748 const std::wstring& args, | |
| 749 bool expected_status) { | |
| 750 LOG(INFO) << "Browser executable: " << path.value(); | |
| 751 bool launched = base::LaunchProcess( | |
| 752 L"\"" + path.value() + L"\"" + L" " + args, | |
| 753 base::LaunchOptions(), NULL); | |
| 754 if (!launched) { | |
| 755 LOG(ERROR) << "Could not launch process: " << path.BaseName().value(); | |
| 756 } | |
| 757 base::PlatformThread::Sleep(1000); | |
| 758 MiniInstallerTestUtil::VerifyProcessLaunch(path.BaseName().value().c_str(), | |
| 759 expected_status); | |
| 760 } | |
| 761 | |
| 762 // This method compares the registry keys after overinstall. | 746 // This method compares the registry keys after overinstall. |
| 763 bool ChromeMiniInstaller::VerifyOverInstall( | 747 bool ChromeMiniInstaller::VerifyOverInstall( |
| 764 const std::wstring& value_before_overinstall, | 748 const std::wstring& value_before_overinstall, |
| 765 const std::wstring& value_after_overinstall) { | 749 const std::wstring& value_after_overinstall) { |
| 766 int64 reg_key_value_before_overinstall; | 750 int64 reg_key_value_before_overinstall; |
| 767 base::StringToInt64(value_before_overinstall, | 751 base::StringToInt64(value_before_overinstall, |
| 768 ®_key_value_before_overinstall); | 752 ®_key_value_before_overinstall); |
| 769 int64 reg_key_value_after_overinstall; | 753 int64 reg_key_value_after_overinstall; |
| 770 base::StringToInt64(value_after_overinstall, | 754 base::StringToInt64(value_after_overinstall, |
| 771 ®_key_value_after_overinstall); | 755 ®_key_value_after_overinstall); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 791 else | 775 else |
| 792 return false; | 776 return false; |
| 793 } | 777 } |
| 794 | 778 |
| 795 // Search all the specified |build| directory to find the latest | 779 // Search all the specified |build| directory to find the latest |
| 796 // diff and full installers. |build| can be empty. | 780 // diff and full installers. |build| can be empty. |
| 797 bool ChromeMiniInstaller::LocateInstallers( | 781 bool ChromeMiniInstaller::LocateInstallers( |
| 798 const std::wstring& build) { | 782 const std::wstring& build) { |
| 799 FilePath::StringType full_installer_pattern = | 783 FilePath::StringType full_installer_pattern = |
| 800 FILE_PATH_LITERAL("*_chrome_installer*"); | 784 FILE_PATH_LITERAL("*_chrome_installer*"); |
| 801 FilePath::StringType diff_installer_pattern = FILE_PATH_LITERAL("*_from_*"); | 785 FilePath::StringType diff_installer_pattern = |
| 786 FILE_PATH_LITERAL("*_from_*"); | |
| 787 FilePath::StringType mini_installer_pattern = | |
| 788 FILE_PATH_LITERAL("mini_installer.exe"); | |
| 802 FilePath root(mini_installer_constants::kChromeInstallersLocation); | 789 FilePath root(mini_installer_constants::kChromeInstallersLocation); |
| 803 std::vector<FilePath> paths; | 790 std::vector<FilePath> paths; |
| 804 if (!FindMatchingFiles(root, build, | 791 if (!FindMatchingFiles(root, build, |
| 805 file_util::FileEnumerator::DIRECTORIES, &paths)) { | 792 file_util::FileEnumerator::DIRECTORIES, &paths)) { |
| 806 return false; | 793 return false; |
| 807 } | 794 } |
| 808 | 795 |
| 809 // Find full and diff installers; | 796 // Find full and diff installers; |
| 810 std::vector<FilePath>::const_iterator dir; | 797 std::vector<FilePath>::const_iterator dir; |
| 811 for (dir = paths.begin(); dir != paths.end(); ++dir) { | 798 for (dir = paths.begin(); dir != paths.end(); ++dir) { |
| 812 FilePath windir = dir->Append( | 799 FilePath windir = dir->Append( |
| 813 mini_installer_constants::kWinFolder); | 800 mini_installer_constants::kWinFolder); |
| 814 if (FindNewestMatchingFile(windir, full_installer_pattern, | 801 if (FindNewestMatchingFile(windir, full_installer_pattern, |
| 815 file_util::FileEnumerator::FILES, &full_installer_) && | 802 file_util::FileEnumerator::FILES, &full_installer_) && |
| 816 FindNewestMatchingFile(windir, diff_installer_pattern, | 803 FindNewestMatchingFile(windir, diff_installer_pattern, |
| 817 file_util::FileEnumerator::FILES, &diff_installer_)) { | 804 file_util::FileEnumerator::FILES, &diff_installer_) && |
| 805 FindNewestMatchingFile(windir, mini_installer_pattern, | |
| 806 file_util::FileEnumerator::FILES, &mini_installer_)) { | |
| 818 break; | 807 break; |
| 819 } | 808 } |
| 820 } | 809 } |
| 821 | 810 |
| 822 // Set current build directory. | |
| 823 if (full_installer_.empty() || diff_installer_.empty()) | 811 if (full_installer_.empty() || diff_installer_.empty()) |
| 824 return false; | 812 return false; |
| 825 | 813 |
| 826 current_build_ = | 814 current_build_ = |
| 827 full_installer_.DirName().DirName().BaseName().value(); | 815 full_installer_.DirName().DirName().BaseName().value(); |
| 828 | 816 |
| 829 // Find previous full installer. | 817 // Find previous full installer. |
| 830 std::vector<std::wstring> tokenized_name; | 818 std::vector<std::wstring> tokenized_name; |
| 831 Tokenize(diff_installer_.BaseName().value(), | 819 Tokenize(diff_installer_.BaseName().value(), |
| 832 L"_", &tokenized_name); | 820 L"_", &tokenized_name); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 858 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern, | 846 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern, |
| 859 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str()); | 847 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str()); |
| 860 standalone_installer = standalone_installer.Append(current_build_) | 848 standalone_installer = standalone_installer.Append(current_build_) |
| 861 .Append(mini_installer_constants::kWinFolder) | 849 .Append(mini_installer_constants::kWinFolder) |
| 862 .Append(standalone_installer_filename); | 850 .Append(standalone_installer_filename); |
| 863 | 851 |
| 864 standalone_installer_ = standalone_installer; | 852 standalone_installer_ = standalone_installer; |
| 865 | 853 |
| 866 return !standalone_installer_.empty(); | 854 return !standalone_installer_.empty(); |
| 867 } | 855 } |
| OLD | NEW |