Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/environment.h" | 13 #include "base/environment.h" |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "base/scoped_temp_dir.h" | |
|
kkania
2011/03/16 18:19:10
i don't think you need this here anymore
Joe
2011/03/17 00:15:25
Done.
| |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "chrome/common/automation_constants.h" | 22 #include "chrome/common/automation_constants.h" |
| 22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 25 #include "chrome/test/automation/automation_json_requests.h" | 26 #include "chrome/test/automation/automation_json_requests.h" |
| 26 #include "chrome/test/automation/automation_proxy.h" | 27 #include "chrome/test/automation/automation_proxy.h" |
| 27 #include "chrome/test/automation/proxy_launcher.h" | 28 #include "chrome/test/automation/proxy_launcher.h" |
| 28 #include "chrome/test/webdriver/frame_path.h" | 29 #include "chrome/test/webdriver/frame_path.h" |
| 29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 int windex = 0, tab_index = 0; | 226 int windex = 0, tab_index = 0; |
| 226 if (!GetIndicesForTab(tab_id, &windex, &tab_index)) { | 227 if (!GetIndicesForTab(tab_id, &windex, &tab_index)) { |
| 227 *success = false; | 228 *success = false; |
| 228 return; | 229 return; |
| 229 } | 230 } |
| 230 | 231 |
| 231 *success = SendWebKeyEventJSONRequest( | 232 *success = SendWebKeyEventJSONRequest( |
| 232 automation(), windex, tab_index, key_event); | 233 automation(), windex, tab_index, key_event); |
| 233 } | 234 } |
| 234 | 235 |
| 236 void Automation::GetScreenShot(int tab_id, | |
| 237 const FilePath& path, | |
| 238 bool* success) { | |
| 239 int windex = 0, tab_index = 0; | |
| 240 | |
| 241 if (!GetIndicesForTab(tab_id, &windex, &tab_index)) { | |
| 242 *success = false; | |
| 243 return; | |
| 244 } | |
| 245 | |
| 246 *success = SendGetScreenShotJSONRequest( | |
| 247 automation(), windex, tab_index, path); | |
| 248 } | |
| 249 | |
| 235 void Automation::NavigateToURL(int tab_id, | 250 void Automation::NavigateToURL(int tab_id, |
| 236 const std::string& url, | 251 const std::string& url, |
| 237 bool* success) { | 252 bool* success) { |
| 238 int browser_index = 0, tab_index = 0; | 253 int browser_index = 0, tab_index = 0; |
| 239 if (!GetIndicesForTab(tab_id, &browser_index, &tab_index)) { | 254 if (!GetIndicesForTab(tab_id, &browser_index, &tab_index)) { |
| 240 *success = false; | 255 *success = false; |
| 241 return; | 256 return; |
| 242 } | 257 } |
| 243 | 258 |
| 244 AutomationMsg_NavigationResponseValues navigate_response; | 259 AutomationMsg_NavigationResponseValues navigate_response; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 int tab_id, int* browser_index, int* tab_index) { | 412 int tab_id, int* browser_index, int* tab_index) { |
| 398 if (!SendGetIndicesFromTabIdJSONRequest(automation(), tab_id, | 413 if (!SendGetIndicesFromTabIdJSONRequest(automation(), tab_id, |
| 399 browser_index, tab_index)) { | 414 browser_index, tab_index)) { |
| 400 LOG(ERROR) << "Could not get browser and tab indices for WebDriver tab id"; | 415 LOG(ERROR) << "Could not get browser and tab indices for WebDriver tab id"; |
| 401 return false; | 416 return false; |
| 402 } | 417 } |
| 403 return true; | 418 return true; |
| 404 } | 419 } |
| 405 | 420 |
| 406 } // namespace webdriver | 421 } // namespace webdriver |
| OLD | NEW |