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

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

Issue 7640017: 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 : cmdline(CommandLine::NO_PROGRAM) {} 187 : command(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 CommandLine cmdline = options.cmdline; 196 // Prepare Chrome's command line.
197 if (cmdline.GetProgram().empty()) { 197 CommandLine command(CommandLine::NO_PROGRAM);
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()) {
198 FilePath browser_exe; 211 FilePath browser_exe;
199 if (!GetDefaultChromeExe(&browser_exe)) { 212 if (!GetDefaultChromeExe(&browser_exe)) {
200 *error = new Error(kUnknownError, "Could not find default Chrome binary"); 213 *error = new Error(kUnknownError, "Could not find default Chrome binary");
201 return; 214 return;
202 } 215 }
203 cmdline.SetProgram(browser_exe); 216 command.SetProgram(browser_exe);
204 } 217 }
205 if (!file_util::PathExists(cmdline.GetProgram())) { 218 if (!file_util::PathExists(command.GetProgram())) {
206 std::string message = base::StringPrintf( 219 std::string message = base::StringPrintf(
207 "Could not find Chrome binary at: %" PRFilePath, 220 "Could not find Chrome binary at: %" PRFilePath,
208 cmdline.GetProgram().value().c_str()); 221 command.GetProgram().value().c_str());
209 *error = new Error(kUnknownError, message); 222 *error = new Error(kUnknownError, message);
210 return; 223 return;
211 } 224 }
212 std::string chrome_details = base::StringPrintf( 225 std::string chrome_details = base::StringPrintf(
213 "Using Chrome binary at: %" PRFilePath, 226 "Using Chrome binary at: %" PRFilePath,
214 cmdline.GetProgram().value().c_str()); 227 command.GetProgram().value().c_str());
215 LOG(INFO) << chrome_details; 228 LOG(INFO) << chrome_details;
216 229
217 cmdline.AppendSwitch(switches::kDisableHangMonitor); 230 // Create the ProxyLauncher and launch Chrome.
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
227 if (options.channel_id.empty()) { 231 if (options.channel_id.empty()) {
228 launcher_.reset(new AnonymousProxyLauncher(false)); 232 launcher_.reset(new AnonymousProxyLauncher(false));
229 } else { 233 } else {
230 launcher_.reset(new NamedProxyLauncher(options.channel_id, false, false)); 234 launcher_.reset(new NamedProxyLauncher(options.channel_id, false, false));
231 } 235 }
232
233 ProxyLauncher::LaunchState launch_props = { 236 ProxyLauncher::LaunchState launch_props = {
234 false, // clear_profile 237 false, // clear_profile
235 options.user_data_dir, // template_user_data 238 options.user_data_dir, // template_user_data
236 base::Closure(), 239 base::Closure(),
237 cmdline, 240 command,
238 true, // include_testing_id 241 true, // include_testing_id
239 true // show_window 242 true // show_window
240 }; 243 };
241 if (!launcher_->InitializeConnection(launch_props, true)) { 244 if (!launcher_->InitializeConnection(launch_props, true)) {
242 LOG(ERROR) << "Failed to initialize connection"; 245 LOG(ERROR) << "Failed to initialize connection";
243 *error = new Error( 246 *error = new Error(
244 kUnknownError, 247 kUnknownError,
245 "Unable to either launch or connect to Chrome. Please check that " 248 "Unable to either launch or connect to Chrome. Please check that "
246 "ChromeDriver is up-to-date. " + chrome_details); 249 "ChromeDriver is up-to-date. " + chrome_details);
247 return; 250 return;
248 } 251 }
249 252
250 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout); 253 launcher_->automation()->set_action_timeout_ms(base::kNoTimeout);
251 LOG(INFO) << "Chrome launched successfully. Version: " 254 LOG(INFO) << "Chrome launched successfully. Version: "
252 << automation()->server_version(); 255 << automation()->server_version();
253 256
257 // Check the version of Chrome is compatible with this ChromeDriver.
254 chrome_details += ", version (" + automation()->server_version() + ")"; 258 chrome_details += ", version (" + automation()->server_version() + ")";
255 int version = 0; 259 int version = 0;
256 std::string error_msg; 260 std::string error_msg;
257 if (!SendGetChromeDriverAutomationVersion( 261 if (!SendGetChromeDriverAutomationVersion(
258 automation(), &version, &error_msg)) { 262 automation(), &version, &error_msg)) {
259 *error = new Error(kUnknownError, error_msg + " " + chrome_details); 263 *error = new Error(kUnknownError, error_msg + " " + chrome_details);
260 return; 264 return;
261 } 265 }
262 if (version > automation::kChromeDriverAutomationVersion) { 266 if (version > automation::kChromeDriverAutomationVersion) {
263 *error = new Error( 267 *error = new Error(
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 768, 0, "Alerts are not supported for this version of Chrome"); 715 768, 0, "Alerts are not supported for this version of Chrome");
712 } 716 }
713 717
714 Error* Automation::CheckAdvancedInteractionsSupported() { 718 Error* Automation::CheckAdvancedInteractionsSupported() {
715 const char* message = 719 const char* message =
716 "Advanced user interactions are not supported for this version of Chrome"; 720 "Advanced user interactions are not supported for this version of Chrome";
717 return CheckVersion(750, 0, message); 721 return CheckVersion(750, 0, message);
718 } 722 }
719 723
720 } // namespace webdriver 724 } // 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