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/test/mini_installer_test/installer_test_util.h" | 5 #include "chrome/test/mini_installer_test/installer_test_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return false; | 172 return false; |
173 } | 173 } |
174 CommandLine command(installer); | 174 CommandLine command(installer); |
175 command.AppendArguments(switches.GetSwitches(), false); | 175 command.AppendArguments(switches.GetSwitches(), false); |
176 LOG(INFO) << "Running installer command: " | 176 LOG(INFO) << "Running installer command: " |
177 << command.GetCommandLineString(); | 177 << command.GetCommandLineString(); |
178 return installer_test::RunAndWaitForCommandToFinish(command); | 178 return installer_test::RunAndWaitForCommandToFinish(command); |
179 } | 179 } |
180 | 180 |
181 bool LaunchChrome(bool close_after_launch, bool system_level) { | 181 bool LaunchChrome(bool close_after_launch, bool system_level) { |
182 base::CleanupProcesses(installer::kChromeExe, 0, | 182 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), |
183 content::RESULT_CODE_HUNG, NULL); | 183 content::RESULT_CODE_HUNG, NULL); |
184 FilePath install_path; | 184 FilePath install_path; |
185 if (!GetChromeInstallDirectory( | 185 if (!GetChromeInstallDirectory( |
186 system_level, &install_path)) { | 186 system_level, &install_path)) { |
187 LOG(ERROR) << "Could not find Chrome install directory"; | 187 LOG(ERROR) << "Could not find Chrome install directory"; |
188 return false; | 188 return false; |
189 } | 189 } |
190 install_path = install_path.Append(installer::kChromeExe); | 190 install_path = install_path.Append(installer::kChromeExe); |
191 CommandLine browser(install_path); | 191 CommandLine browser(install_path); |
192 | 192 |
(...skipping 18 matching lines...) Expand all Loading... |
211 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); | 211 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); |
212 browser_path = browser_path.Append(mini_installer_constants::kIELocation); | 212 browser_path = browser_path.Append(mini_installer_constants::kIELocation); |
213 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); | 213 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); |
214 | 214 |
215 CommandLine cmd_line(browser_path); | 215 CommandLine cmd_line(browser_path); |
216 cmd_line.AppendArg(url); | 216 cmd_line.AppendArg(url); |
217 return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); | 217 return base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); |
218 } | 218 } |
219 | 219 |
220 bool UninstallAll() { | 220 bool UninstallAll() { |
221 base::CleanupProcesses(installer::kChromeExe, 0, | 221 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), |
222 content::RESULT_CODE_HUNG, NULL); | 222 content::RESULT_CODE_HUNG, NULL); |
223 base::CleanupProcesses(installer::kChromeFrameHelperExe, 0, | 223 base::CleanupProcesses(installer::kChromeFrameHelperExe, base::TimeDelta(), |
224 content::RESULT_CODE_HUNG, NULL); | 224 content::RESULT_CODE_HUNG, NULL); |
225 std::vector<installer_test::InstalledProduct> installed; | 225 std::vector<installer_test::InstalledProduct> installed; |
226 if (!GetInstalledProducts(&installed)) { | 226 if (!GetInstalledProducts(&installed)) { |
227 LOG(WARNING) << "No installed products to uninstall."; | 227 LOG(WARNING) << "No installed products to uninstall."; |
228 return false; | 228 return false; |
229 } | 229 } |
230 bool ret_val = false; | 230 bool ret_val = false; |
231 for (size_t i = 0; i < installed.size(); ++i) { | 231 for (size_t i = 0; i < installed.size(); ++i) { |
232 if (!Uninstall(installed[i].system, installed[i].type)) | 232 if (!Uninstall(installed[i].system, installed[i].type)) |
233 ret_val = false; | 233 ret_val = false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); | 266 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); |
267 uninstall_cmd.AppendSwitchNative( | 267 uninstall_cmd.AppendSwitchNative( |
268 installer::switches::kInstallArchive, archive); | 268 installer::switches::kInstallArchive, archive); |
269 if (system_level) | 269 if (system_level) |
270 uninstall_cmd.AppendSwitch(installer::switches::kSystemLevel); | 270 uninstall_cmd.AppendSwitch(installer::switches::kSystemLevel); |
271 if ((product & kMultiMask) !=0) | 271 if ((product & kMultiMask) !=0) |
272 uninstall_cmd.AppendSwitch(installer::switches::kMultiInstall); | 272 uninstall_cmd.AppendSwitch(installer::switches::kMultiInstall); |
273 LOG(INFO) << "Uninstall command: " << uninstall_cmd.GetCommandLineString(); | 273 LOG(INFO) << "Uninstall command: " << uninstall_cmd.GetCommandLineString(); |
274 bool ret_val = RunAndWaitForCommandToFinish(uninstall_cmd); | 274 bool ret_val = RunAndWaitForCommandToFinish(uninstall_cmd); |
275 // Close IE notification when uninstalling Chrome Frame. | 275 // Close IE notification when uninstalling Chrome Frame. |
276 base::CleanupProcesses(mini_installer_constants::kIEProcessName, 0, | 276 base::CleanupProcesses(mini_installer_constants::kIEProcessName, |
| 277 base::TimeDelta(), |
277 content::RESULT_CODE_HUNG, NULL); | 278 content::RESULT_CODE_HUNG, NULL); |
278 return ret_val; | 279 return ret_val; |
279 } | 280 } |
280 | 281 |
281 | 282 |
282 bool RunAndWaitForCommandToFinish(CommandLine command) { | 283 bool RunAndWaitForCommandToFinish(CommandLine command) { |
283 if (!file_util::PathExists(command.GetProgram())) { | 284 if (!file_util::PathExists(command.GetProgram())) { |
284 LOG(ERROR) << "Command executable does not exist: " | 285 LOG(ERROR) << "Command executable does not exist: " |
285 << command.GetProgram().MaybeAsASCII(); | 286 << command.GetProgram().MaybeAsASCII(); |
286 return false; | 287 return false; |
287 } | 288 } |
288 base::ProcessHandle process; | 289 base::ProcessHandle process; |
289 if (!base::LaunchProcess(command, base::LaunchOptions(), &process)) { | 290 if (!base::LaunchProcess(command, base::LaunchOptions(), &process)) { |
290 LOG(ERROR) << "Failed to launch command: " | 291 LOG(ERROR) << "Failed to launch command: " |
291 << command.GetCommandLineString(); | 292 << command.GetCommandLineString(); |
292 return false; | 293 return false; |
293 } | 294 } |
294 if (!base::WaitForSingleProcess(process, base::TimeDelta::FromMinutes(1))) { | 295 if (!base::WaitForSingleProcess(process, base::TimeDelta::FromMinutes(1))) { |
295 LOG(ERROR) << "Launched process did not complete."; | 296 LOG(ERROR) << "Launched process did not complete."; |
296 return false; | 297 return false; |
297 } | 298 } |
298 return true; | 299 return true; |
299 } | 300 } |
300 | 301 |
301 } // namespace | 302 } // namespace |
OLD | NEW |