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

Side by Side Diff: chrome/test/webdriver/webdriver_automation.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/webdriver/webdriver_automation.h" 5 #include "chrome/test/webdriver/webdriver_automation.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 namespace { 47 namespace {
48 48
49 // Iterates through each browser executable path, and checks if the path exists 49 // Iterates through each browser executable path, and checks if the path exists
50 // in any of the given locations. If found, returns true and sets |browser_exe|. 50 // in any of the given locations. If found, returns true and sets |browser_exe|.
51 bool CheckForChromeExe(const std::vector<base::FilePath>& browser_exes, 51 bool CheckForChromeExe(const std::vector<base::FilePath>& browser_exes,
52 const std::vector<base::FilePath>& locations, 52 const std::vector<base::FilePath>& locations,
53 base::FilePath* browser_exe) { 53 base::FilePath* browser_exe) {
54 for (size_t i = 0; i < browser_exes.size(); ++i) { 54 for (size_t i = 0; i < browser_exes.size(); ++i) {
55 for (size_t j = 0; j < locations.size(); ++j) { 55 for (size_t j = 0; j < locations.size(); ++j) {
56 base::FilePath path = locations[j].Append(browser_exes[i]); 56 base::FilePath path = locations[j].Append(browser_exes[i]);
57 if (file_util::PathExists(path)) { 57 if (base::PathExists(path)) {
58 *browser_exe = path; 58 *browser_exe = path;
59 return true; 59 return true;
60 } 60 }
61 } 61 }
62 } 62 }
63 return false; 63 return false;
64 } 64 }
65 65
66 // Gets the path to the default Chrome executable. Returns true on success. 66 // Gets the path to the default Chrome executable. Returns true on success.
67 bool GetDefaultChromeExe(base::FilePath* browser_exe) { 67 bool GetDefaultChromeExe(base::FilePath* browser_exe) {
(...skipping 22 matching lines...) Expand all
90 #endif 90 #endif
91 std::vector<base::FilePath> browser_exes( 91 std::vector<base::FilePath> browser_exes(
92 browser_exes_array, browser_exes_array + arraysize(browser_exes_array)); 92 browser_exes_array, browser_exes_array + arraysize(browser_exes_array));
93 93
94 // Step 1: Check the directory this module resides in. This is done 94 // Step 1: Check the directory this module resides in. This is done
95 // before all else so that the tests will pickup the built chrome. 95 // before all else so that the tests will pickup the built chrome.
96 base::FilePath module_dir; 96 base::FilePath module_dir;
97 if (PathService::Get(base::DIR_MODULE, &module_dir)) { 97 if (PathService::Get(base::DIR_MODULE, &module_dir)) {
98 for (size_t j = 0; j < browser_exes.size(); ++j) { 98 for (size_t j = 0; j < browser_exes.size(); ++j) {
99 base::FilePath path = module_dir.Append(browser_exes[j]); 99 base::FilePath path = module_dir.Append(browser_exes[j]);
100 if (file_util::PathExists(path)) { 100 if (base::PathExists(path)) {
101 *browser_exe = path; 101 *browser_exe = path;
102 return true; 102 return true;
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107 // Step 2: Add all possible install locations, in order they should be 107 // Step 2: Add all possible install locations, in order they should be
108 // searched. If a location can only hold a chromium install, add it to 108 // searched. If a location can only hold a chromium install, add it to
109 // |chromium_locations|. Since on some platforms we cannot tell by the binary 109 // |chromium_locations|. Since on some platforms we cannot tell by the binary
110 // name whether it is chrome or chromium, we search these locations last. 110 // name whether it is chrome or chromium, we search these locations last.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 404
405 // Find the Chrome binary. 405 // Find the Chrome binary.
406 if (command.GetProgram().empty()) { 406 if (command.GetProgram().empty()) {
407 base::FilePath browser_exe; 407 base::FilePath browser_exe;
408 if (!GetDefaultChromeExe(&browser_exe)) { 408 if (!GetDefaultChromeExe(&browser_exe)) {
409 *error = new Error(kUnknownError, "Could not find default Chrome binary"); 409 *error = new Error(kUnknownError, "Could not find default Chrome binary");
410 return; 410 return;
411 } 411 }
412 command.SetProgram(browser_exe); 412 command.SetProgram(browser_exe);
413 } 413 }
414 if (!file_util::PathExists(command.GetProgram())) { 414 if (!base::PathExists(command.GetProgram())) {
415 std::string message = base::StringPrintf( 415 std::string message = base::StringPrintf(
416 "Could not find Chrome binary at: %" PRFilePath, 416 "Could not find Chrome binary at: %" PRFilePath,
417 command.GetProgram().value().c_str()); 417 command.GetProgram().value().c_str());
418 *error = new Error(kUnknownError, message); 418 *error = new Error(kUnknownError, message);
419 return; 419 return;
420 } 420 }
421 std::string chrome_details = base::StringPrintf( 421 std::string chrome_details = base::StringPrintf(
422 "Using Chrome binary at: %" PRFilePath, 422 "Using Chrome binary at: %" PRFilePath,
423 command.GetProgram().value().c_str()); 423 command.GetProgram().value().c_str());
424 424
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 } 1207 }
1208 1208
1209 Error* Automation::CheckMaximizeSupported() { 1209 Error* Automation::CheckMaximizeSupported() {
1210 const char* message = 1210 const char* message =
1211 "Maximize automation interface is not supported for this version of " 1211 "Maximize automation interface is not supported for this version of "
1212 "Chrome."; 1212 "Chrome.";
1213 return CheckVersion(1160, message); 1213 return CheckVersion(1160, message);
1214 } 1214 }
1215 1215
1216 } // namespace webdriver 1216 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/webelement_commands.cc ('k') | chrome/tools/crash_service/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698