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

Unified Diff: chrome/test/webdriver/session.cc

Issue 6614023: Convert ChromeDriver to use only the JSON automation interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Pawel's additional comments Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/webdriver_key_converter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/session.cc
diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc
index 400c7eb42915ce74bb5d74ceabe435380e71bfb0..4402797319de3e498934feafdef24b3b7c285e1b 100644
--- a/chrome/test/webdriver/session.cc
+++ b/chrome/test/webdriver/session.cc
@@ -30,6 +30,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/test/automation/automation_json_requests.h"
#include "chrome/test/test_launcher_utils.h"
#include "chrome/test/webdriver/session_manager.h"
#include "chrome/test/webdriver/utility_functions.h"
@@ -259,14 +260,15 @@ bool Session::GetTabTitle(std::string* tab_title) {
return success;
}
-void Session::MouseClick(const gfx::Point& click, int flags) {
+void Session::MouseClick(const gfx::Point& click,
+ automation::MouseButton button) {
bool success = false;
RunSessionTask(NewRunnableMethod(
automation_.get(),
&Automation::MouseClick,
current_window_id_,
click,
- flags,
+ button,
&success));
}
@@ -309,16 +311,20 @@ bool Session::GetCookies(const GURL& url, std::string* cookies) {
bool Session::GetCookieByName(const GURL& url,
const std::string& cookie_name,
std::string* cookie) {
- bool success = false;
- RunSessionTask(NewRunnableMethod(
- automation_.get(),
- &Automation::GetCookieByName,
- current_window_id_,
- url,
- cookie_name,
- cookie,
- &success));
- return success;
+ std::string cookies;
+ if (!GetCookies(url, &cookies))
+ return false;
+
+ std::string namestr = cookie_name + "=";
+ std::string::size_type idx = cookies.find(namestr);
+ if (idx != std::string::npos) {
+ cookies.erase(0, idx + namestr.length());
+ *cookie = cookies.substr(0, cookies.find(";"));
+ } else {
+ cookie->clear();
+ }
+
+ return true;
}
bool Session::DeleteCookie(const GURL& url, const std::string& cookie_name) {
@@ -359,12 +365,18 @@ ErrorCode Session::SwitchToWindow(const std::string& name) {
int switch_to_id = 0;
int name_no = 0;
if (base::StringToInt(name, &name_no)) {
+ bool success = false;
bool does_exist = false;
RunSessionTask(NewRunnableMethod(
automation_.get(),
&Automation::DoesTabExist,
name_no,
- &does_exist));
+ &does_exist,
+ &success));
+ if (!success) {
+ LOG(ERROR) << "Unable to determine if window exists";
+ return kUnknownError;
+ }
if (does_exist)
switch_to_id = name_no;
}
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/webdriver_key_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698