Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1257)

Side by Side Diff: chrome/test/mini_installer_test/installer_test_util.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 bool DeleteInstallDirectory(bool system_level, 53 bool DeleteInstallDirectory(bool system_level,
54 InstallationValidator::InstallationType type) { 54 InstallationValidator::InstallationType type) {
55 std::string version = GetVersion(type); 55 std::string version = GetVersion(type);
56 if (version.empty()) 56 if (version.empty())
57 return false; 57 return false;
58 base::FilePath path; 58 base::FilePath path;
59 bool has_install_dir = GetInstallDirectory(system_level, 59 bool has_install_dir = GetInstallDirectory(system_level,
60 ToBrowserDistributionType(type), 60 ToBrowserDistributionType(type),
61 &path); 61 &path);
62 if (!has_install_dir || !file_util::PathExists(path)) 62 if (!has_install_dir || !base::PathExists(path))
63 return false; 63 return false;
64 path = path.AppendASCII(version); 64 path = path.AppendASCII(version);
65 return base::Delete(path, true); 65 return base::Delete(path, true);
66 } 66 }
67 67
68 bool DeleteRegistryKey(bool system_level, 68 bool DeleteRegistryKey(bool system_level,
69 InstallationValidator::InstallationType type) { 69 InstallationValidator::InstallationType type) {
70 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( 70 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
71 ToBrowserDistributionType(type)); 71 ToBrowserDistributionType(type));
72 base::FilePath::StringType key(google_update::kRegPathClients); 72 base::FilePath::StringType key(google_update::kRegPathClients);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 for (size_t i = 0; i < installed.size(); ++i) { 147 for (size_t i = 0; i < installed.size(); ++i) {
148 if ((installed[i].type & product) != 0) { 148 if ((installed[i].type & product) != 0) {
149 return installed[i].version; 149 return installed[i].version;
150 } 150 }
151 } 151 }
152 } 152 }
153 return ""; 153 return "";
154 } 154 }
155 155
156 bool Install(const base::FilePath& installer) { 156 bool Install(const base::FilePath& installer) {
157 if (!file_util::PathExists(installer)) { 157 if (!base::PathExists(installer)) {
158 LOG(ERROR) << "Installer does not exist: " << installer.MaybeAsASCII(); 158 LOG(ERROR) << "Installer does not exist: " << installer.MaybeAsASCII();
159 return false; 159 return false;
160 } 160 }
161 CommandLine command(installer); 161 CommandLine command(installer);
162 LOG(INFO) << "Running installer command: " 162 LOG(INFO) << "Running installer command: "
163 << command.GetCommandLineString(); 163 << command.GetCommandLineString();
164 return installer_test::RunAndWaitForCommandToFinish(command); 164 return installer_test::RunAndWaitForCommandToFinish(command);
165 } 165 }
166 166
167 bool Install(const base::FilePath& installer, const SwitchBuilder& switches) { 167 bool Install(const base::FilePath& installer, const SwitchBuilder& switches) {
168 if (!file_util::PathExists(installer)) { 168 if (!base::PathExists(installer)) {
169 LOG(ERROR) << "Installer does not exist: " << installer.MaybeAsASCII(); 169 LOG(ERROR) << "Installer does not exist: " << installer.MaybeAsASCII();
170 return false; 170 return false;
171 } 171 }
172 CommandLine command(installer); 172 CommandLine command(installer);
173 command.AppendArguments(switches.GetSwitches(), false); 173 command.AppendArguments(switches.GetSwitches(), false);
174 LOG(INFO) << "Running installer command: " 174 LOG(INFO) << "Running installer command: "
175 << command.GetCommandLineString(); 175 << command.GetCommandLineString();
176 return installer_test::RunAndWaitForCommandToFinish(command); 176 return installer_test::RunAndWaitForCommandToFinish(command);
177 } 177 }
178 178
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 bool ret_val = RunAndWaitForCommandToFinish(uninstall_cmd); 272 bool ret_val = RunAndWaitForCommandToFinish(uninstall_cmd);
273 // Close IE notification when uninstalling Chrome Frame. 273 // Close IE notification when uninstalling Chrome Frame.
274 base::CleanupProcesses(mini_installer_constants::kIEProcessName, 274 base::CleanupProcesses(mini_installer_constants::kIEProcessName,
275 base::TimeDelta(), 275 base::TimeDelta(),
276 content::RESULT_CODE_HUNG, NULL); 276 content::RESULT_CODE_HUNG, NULL);
277 return ret_val; 277 return ret_val;
278 } 278 }
279 279
280 280
281 bool RunAndWaitForCommandToFinish(CommandLine command) { 281 bool RunAndWaitForCommandToFinish(CommandLine command) {
282 if (!file_util::PathExists(command.GetProgram())) { 282 if (!base::PathExists(command.GetProgram())) {
283 LOG(ERROR) << "Command executable does not exist: " 283 LOG(ERROR) << "Command executable does not exist: "
284 << command.GetProgram().MaybeAsASCII(); 284 << command.GetProgram().MaybeAsASCII();
285 return false; 285 return false;
286 } 286 }
287 base::ProcessHandle process; 287 base::ProcessHandle process;
288 if (!base::LaunchProcess(command, base::LaunchOptions(), &process)) { 288 if (!base::LaunchProcess(command, base::LaunchOptions(), &process)) {
289 LOG(ERROR) << "Failed to launch command: " 289 LOG(ERROR) << "Failed to launch command: "
290 << command.GetCommandLineString(); 290 << command.GetCommandLineString();
291 return false; 291 return false;
292 } 292 }
293 if (!base::WaitForSingleProcess(process, base::TimeDelta::FromMinutes(1))) { 293 if (!base::WaitForSingleProcess(process, base::TimeDelta::FromMinutes(1))) {
294 LOG(ERROR) << "Launched process did not complete."; 294 LOG(ERROR) << "Launched process did not complete.";
295 return false; 295 return false;
296 } 296 }
297 return true; 297 return true;
298 } 298 }
299 299
300 } // namespace 300 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/mini_installer_test/installer_path_provider.cc ('k') | chrome/test/mini_installer_test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698