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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/webdriver_util.h ('k') | no next file » | 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/webdriver_util.h" 5 #include "chrome/test/webdriver/webdriver_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/rand_util.h" 12 #include "base/rand_util.h"
12 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/string_number_conversions.h"
15 #include "chrome/common/automation_id.h"
16 #include "chrome/test/automation/automation_json_requests.h"
13 17
14 using base::DictionaryValue; 18 using base::DictionaryValue;
15 using base::ListValue; 19 using base::ListValue;
16 using base::Value; 20 using base::Value;
17 21
18 namespace webdriver { 22 namespace webdriver {
19 23
20 SkipParsing* kSkipParsing = NULL; 24 SkipParsing* kSkipParsing = NULL;
21 25
22 std::string GenerateRandomID() { 26 std::string GenerateRandomID() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 case Value::TYPE_BINARY: 113 case Value::TYPE_BINARY:
110 return "binary"; 114 return "binary";
111 case Value::TYPE_DICTIONARY: 115 case Value::TYPE_DICTIONARY:
112 return "dictionary"; 116 return "dictionary";
113 case Value::TYPE_LIST: 117 case Value::TYPE_LIST:
114 return "list"; 118 return "list";
115 } 119 }
116 return "unknown"; 120 return "unknown";
117 } 121 }
118 122
123 bool StringToAutomationId(const std::string& string_id, AutomationId* id) {
124 scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
125 std::string error_msg;
126 return value.get() && AutomationId::FromValue(value.get(), id, &error_msg);
127 }
128
129 std::string WebViewIdToString(const WebViewId& view_id) {
130 DictionaryValue* dict = view_id.GetId().ToValue();
131 if (view_id.old_style())
132 dict->SetBoolean("old_style", true);
133 return JsonStringify(dict);
134 }
135
136 bool StringToWebViewId(const std::string& string_id, WebViewId* view_id) {
137 scoped_ptr<Value> value(base::JSONReader::Read(string_id, false));
138 AutomationId id;
139 std::string error_msg;
140 DictionaryValue* dict;
141 if (!value.get() || !AutomationId::FromValue(value.get(), &id, &error_msg) ||
142 !value->GetAsDictionary(&dict))
143 return false;
144
145 bool old_style = false;
146 dict->GetBoolean("old_style", &old_style);
147
148 if (old_style) {
149 int tab_id;
150 if (!base::StringToInt(id.id(), &tab_id))
151 return false;
152 *view_id = WebViewId::ForOldStyleTab(tab_id);
153 } else {
154 *view_id = WebViewId::ForView(id);
155 }
156 return true;
157 }
158
119 ValueParser::ValueParser() { } 159 ValueParser::ValueParser() { }
120 160
121 ValueParser::~ValueParser() { } 161 ValueParser::~ValueParser() { }
122 162
123 } // namespace webdriver 163 } // namespace webdriver
124 164
125 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( 165 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue(
126 const Value* value, const webdriver::SkipParsing* t) { 166 const Value* value, const webdriver::SkipParsing* t) {
127 return true; 167 return true;
128 } 168 }
129 169
130 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( 170 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert(
131 const Value* value) { 171 const Value* value) {
132 return true; 172 return true;
133 } 173 }
OLDNEW
« 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