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

Side by Side Diff: chrome/test/webdriver/automation.cc

Issue 7637017: Revert 96562 - Disable pyauto tests on mac that requires py2.6. Fix 2 failing chromedriver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « chrome/test/webdriver/automation.h ('k') | chrome/test/webdriver/commands/create_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/webdriver/automation.h" 5 #include "chrome/test/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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // browser is installed there. Check the chromium locations lastly. 177 // browser is installed there. Check the chromium locations lastly.
178 return CheckForChromeExe(browser_exes, locations, browser_exe) || 178 return CheckForChromeExe(browser_exes, locations, browser_exe) ||
179 CheckForChromeExe(browser_exes, chromium_locations, browser_exe); 179 CheckForChromeExe(browser_exes, chromium_locations, browser_exe);
180 } 180 }
181 181
182 } // namespace 182 } // namespace
183 183
184 namespace webdriver { 184 namespace webdriver {
185 185
186 Automation::BrowserOptions::BrowserOptions() 186 Automation::BrowserOptions::BrowserOptions()
187 : command(CommandLine::NO_PROGRAM) {} 187 : cmdline(CommandLine::NO_PROGRAM) {}
188 188
189 Automation::BrowserOptions::~BrowserOptions() {} 189 Automation::BrowserOptions::~BrowserOptions() {}
190 190
191 Automation::Automation() {} 191 Automation::Automation() {}
192 192
193 Automation::~Automation() {} 193 Automation::~Automation() {}
194 194
195 void Automation::Init(const BrowserOptions& options, Error** error) { 195 void Automation::Init(const BrowserOptions& options, Error** error) {
196 // Prepare Chrome's command line. 196 CommandLine cmdline = options.cmdline;
197 CommandLine command(CommandLine::NO_PROGRAM); 197 if (cmdline.GetProgram().empty()) {
198 command.AppendSwitch(switches::kDisableHangMonitor);
199 command.AppendSwitch(switches::kDisablePromptOnRepost);
200 command.AppendSwitch(switches::kDomAutomationController);
201 command.AppendSwitch(switches::kFullMemoryCrashReport);
202 command.AppendSwitch(switches::kNoDefaultBrowserCheck);
203 command.AppendSwitch(switches::kNoFirstRun);
204 if (options.user_data_dir.empty())
205 command.AppendSwitchASCII(switches::kHomePage, chrome::kAboutBlankURL);
206
207 command.AppendArguments(options.command, true /* include_program */);
208
209 // Find the Chrome binary.
210 if (command.GetProgram().empty()) {
211 FilePath browser_exe; 198 FilePath browser_exe;
212 if (!GetDefaultChromeExe(&browser_exe)) { 199 if (!GetDefaultChromeExe(&browser_exe)) {
213 *error = new Error(kUnknownError, "Could not find default Chrome binary"); 200 *error = new Error(kUnknownError, "Could not find default Chrome binary");
214 return; 201 return;
215 } 202 }
216 command.SetProgram(browser_exe); 203 cmdline.SetProgram(browser_exe);
217 } 204 }
218 if (!file_util::PathExists(command.GetProgram())) { 205 if (!file_util::PathExists(cmdline.GetProgram())) {
219 std::string message = base::StringPrintf( 206 std::string message = base::StringPrintf(
220 "Could not find Chrome binary at: %" PRFilePath, 207 "Could not find Chrome binary at: %" PRFilePath,
221 command.GetProgram().value().c_str()); 208 cmdline.GetProgram().value().c_str());
222 *error = new Error(kUnknownError, message); 209 *error = new Error(kUnknownError, message);
223 return; 210 return;
224 } 211 }
225 std::string chrome_details = base::StringPrintf( 212 std::string chrome_details = base::StringPrintf(
226 "Using Chrome binary at: %" PRFilePath, 213 "Using Chrome binary at: %" PRFilePath,
227 command.GetProgram().value().c_str()); 214 cmdline.GetProgram().value().c_str());
228 LOG(INFO) << chrome_details; 215 LOG(INFO) << chrome_details;
229 216
230 // Create the ProxyLauncher and launch Chrome. 217 cmdline.AppendSwitch(switches::kDisableHangMonitor);
218 cmdline.AppendSwitch(switches::kDisablePromptOnRepost);
219 cmdline.AppendSwitch(switches::kDomAutomationController);
220 cmdline.AppendSwitch(switches::kFullMemoryCrashReport);
221 cmdline.AppendSwitch(switches::kNoDefaultBrowserCheck);
222 cmdline.AppendSwitch(switches::kNoFirstRun);
223
224 if (options.user_data_dir.empty())
225 cmdline.AppendSwitchASCII(switches::kHomePage, chrome::kAboutBlankURL);
226
231 if (options.channel_id.empty()) { 227 if (options.channel_id.empty()) {
232 launcher_.reset(new AnonymousProxyLauncher(false)); 228 launcher_.reset(new AnonymousProxyLauncher(false));
233 } else { 229 } else {
234 launcher_.reset(new NamedProxyLauncher(options.channel_id, false, false)); 230 launcher_.reset(new NamedProxyLauncher(options.channel_id, false, false));
235 } 231 }
232
236 ProxyLauncher::LaunchState launch_props = { 233 ProxyLauncher::LaunchState launch_props = {
237 false, // clear_profile 234 false, // clear_profile
238 options.user_data_dir, // template_user_data 235 options.user_data_dir, // template_user_data
239 base::Closure(), 236 base::Closure(),
240 command, 237 cmdline,
241 true, // include_testing_id 238 true, // include_testing_id
242 true // show_window 239 true // show_window
243 }; 240 };
244 if (!launcher_->InitializeConnection(launch_props, true)) { 241 if (!launcher_->InitializeConnection(launch_props, true)) {
245 LOG(ERROR) << "Failed to initialize connection"; 242 LOG(ERROR) << "Failed to initialize connection";
246 *error = new Error( 243 *error = new Error(
247 kUnknownError, 244 kUnknownError,
248 "Unable to either launch or connect to Chrome. Please check that " 245 "Unable to either launch or connect to Chrome. Please check that "
249 "ChromeDriver is up-to-date. " + chrome_details); 246 "ChromeDriver is up-to-date. " + chrome_details);
250 return; 247 return;
251 } 248 }
252 249
253 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout); 250 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout);
254 LOG(INFO) << "Chrome launched successfully. Version: " 251 LOG(INFO) << "Chrome launched successfully. Version: "
255 << automation()->server_version(); 252 << automation()->server_version();
256 253
257 // Check the version of Chrome is compatible with this ChromeDriver.
258 chrome_details += ", version (" + automation()->server_version() + ")"; 254 chrome_details += ", version (" + automation()->server_version() + ")";
259 int version = 0; 255 int version = 0;
260 std::string error_msg; 256 std::string error_msg;
261 if (!SendGetChromeDriverAutomationVersion( 257 if (!SendGetChromeDriverAutomationVersion(
262 automation(), &version, &error_msg)) { 258 automation(), &version, &error_msg)) {
263 *error = new Error(kUnknownError, error_msg + " " + chrome_details); 259 *error = new Error(kUnknownError, error_msg + " " + chrome_details);
264 return; 260 return;
265 } 261 }
266 if (version > automation::kChromeDriverAutomationVersion) { 262 if (version > automation::kChromeDriverAutomationVersion) {
267 *error = new Error( 263 *error = new Error(
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 768, 0, "Alerts are not supported for this version of Chrome"); 711 768, 0, "Alerts are not supported for this version of Chrome");
716 } 712 }
717 713
718 Error* Automation::CheckAdvancedInteractionsSupported() { 714 Error* Automation::CheckAdvancedInteractionsSupported() {
719 const char* message = 715 const char* message =
720 "Advanced user interactions are not supported for this version of Chrome"; 716 "Advanced user interactions are not supported for this version of Chrome";
721 return CheckVersion(750, 0, message); 717 return CheckVersion(750, 0, message);
722 } 718 }
723 719
724 } // namespace webdriver 720 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/automation.h ('k') | chrome/test/webdriver/commands/create_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698