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

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

Issue 9288051: Implement the webdriver window sizing commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 years, 11 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/webdriver_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/webdriver_util.cc
diff --git a/chrome/test/webdriver/webdriver_util.cc b/chrome/test/webdriver/webdriver_util.cc
index 1347284e0a6fcae56c1d99b775e2a9643477394c..d4b27d2fa90b8db96810e9073a18af6fec1eeba9 100644
--- a/chrome/test/webdriver/webdriver_util.cc
+++ b/chrome/test/webdriver/webdriver_util.cc
@@ -12,6 +12,7 @@
#include "base/rand_util.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
+#include "base/string_split.h"
#include "base/third_party/icu/icu_utf.h"
#include "chrome/common/automation_id.h"
#include "chrome/test/automation/automation_json_requests.h"
@@ -121,31 +122,37 @@ const char* GetJsonTypeName(Value::Type type) {
return "unknown";
}
+std::string AutomationIdToString(const AutomationId& id) {
+ return base::StringPrintf("%d-%s", id.type(), id.id().c_str());
+}
+
bool StringToAutomationId(const std::string& string_id, AutomationId* id) {
- scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
- std::string error_msg;
- return value.get() && AutomationId::FromValue(value.get(), id, &error_msg);
+ std::vector<std::string> split_id;
+ base::SplitString(string_id, '-', &split_id);
+ if (split_id.size() != 2)
+ return false;
+ int type;
+ if (!base::StringToInt(split_id[0], &type))
+ return false;
+ *id = AutomationId(static_cast<AutomationId::Type>(type), split_id[1]);
+ return true;
}
std::string WebViewIdToString(const WebViewId& view_id) {
- DictionaryValue* dict = view_id.GetId().ToValue();
- if (view_id.old_style())
- dict->SetBoolean("old_style", true);
- return JsonStringify(dict);
+ return base::StringPrintf(
+ "%s%s",
+ view_id.old_style() ? "t" : "f",
+ AutomationIdToString(view_id.GetId()).c_str());
}
bool StringToWebViewId(const std::string& string_id, WebViewId* view_id) {
- scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
+ if (string_id.empty() || (string_id[0] != 'f' && string_id[0] != 't'))
+ return false;
+ bool old_style = string_id[0] == 't';
AutomationId id;
- std::string error_msg;
- DictionaryValue* dict;
- if (!value.get() || !AutomationId::FromValue(value.get(), &id, &error_msg) ||
- !value->GetAsDictionary(&dict))
+ if (!StringToAutomationId(string_id.substr(1), &id))
return false;
- bool old_style = false;
- dict->GetBoolean("old_style", &old_style);
-
if (old_style) {
int tab_id;
if (!base::StringToInt(id.id(), &tab_id))
« no previous file with comments | « chrome/test/webdriver/webdriver_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698