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

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

Issue 8806030: Add commands to Chrome WebDriver for installing and manipulating extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years 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 5440d5ac0fa5862ef4c3befc468f8d779a61d65f..af4589b98c6567131322638b42b7b4b7f2779f54 100644
--- a/chrome/test/webdriver/webdriver_util.cc
+++ b/chrome/test/webdriver/webdriver_util.cc
@@ -6,10 +6,14 @@
#include "base/basictypes.h"
#include "base/format_macros.h"
+#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
#include "base/rand_util.h"
#include "base/stringprintf.h"
+#include "base/string_number_conversions.h"
+#include "chrome/common/automation_id.h"
+#include "chrome/test/automation/automation_json_requests.h"
using base::DictionaryValue;
using base::ListValue;
@@ -116,6 +120,42 @@ const char* GetJsonTypeName(Value::Type type) {
return "unknown";
}
+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::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);
+}
+
+bool StringToWebViewId(const std::string& string_id, WebViewId* view_id) {
+ scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
+ AutomationId id;
+ std::string error_msg;
+ DictionaryValue* dict;
+ if (!value.get() || !AutomationId::FromValue(value.get(), &id, &error_msg) ||
+ !value->GetAsDictionary(&dict))
+ 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))
+ return false;
+ *view_id = WebViewId::ForOldStyleTab(tab_id);
+ } else {
+ *view_id = WebViewId::ForView(id);
+ }
+ return true;
+}
+
ValueParser::ValueParser() { }
ValueParser::~ValueParser() { }
« 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