| 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/webdriver_session.h" | 5 #include "chrome/test/webdriver/webdriver_session.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 const std::string& script, ListValue* args) { | 1130 const std::string& script, ListValue* args) { |
| 1131 class SwitchFrameValueParser : public ValueParser { | 1131 class SwitchFrameValueParser : public ValueParser { |
| 1132 public: | 1132 public: |
| 1133 SwitchFrameValueParser( | 1133 SwitchFrameValueParser( |
| 1134 bool* found_frame, ElementId* frame, std::string* xpath) | 1134 bool* found_frame, ElementId* frame, std::string* xpath) |
| 1135 : found_frame_(found_frame), frame_(frame), xpath_(xpath) { } | 1135 : found_frame_(found_frame), frame_(frame), xpath_(xpath) { } |
| 1136 | 1136 |
| 1137 virtual ~SwitchFrameValueParser() { } | 1137 virtual ~SwitchFrameValueParser() { } |
| 1138 | 1138 |
| 1139 virtual bool Parse(base::Value* value) const OVERRIDE { | 1139 virtual bool Parse(base::Value* value) const OVERRIDE { |
| 1140 if (value->IsType(Value::TYPE_NULL)) { | 1140 if (value->IsNull()) { |
| 1141 *found_frame_ = false; | 1141 *found_frame_ = false; |
| 1142 return true; | 1142 return true; |
| 1143 } | 1143 } |
| 1144 ListValue* list; | 1144 ListValue* list; |
| 1145 if (!value->GetAsList(&list)) | 1145 if (!value->GetAsList(&list)) |
| 1146 return false; | 1146 return false; |
| 1147 *found_frame_ = true; | 1147 *found_frame_ = true; |
| 1148 return SetFromListValue(list, frame_, xpath_); | 1148 return SetFromListValue(list, frame_, xpath_); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 CHECK(root_element.is_valid()); | 1211 CHECK(root_element.is_valid()); |
| 1212 | 1212 |
| 1213 class FindElementsParser : public ValueParser { | 1213 class FindElementsParser : public ValueParser { |
| 1214 public: | 1214 public: |
| 1215 explicit FindElementsParser(std::vector<ElementId>* elements) | 1215 explicit FindElementsParser(std::vector<ElementId>* elements) |
| 1216 : elements_(elements) { } | 1216 : elements_(elements) { } |
| 1217 | 1217 |
| 1218 virtual ~FindElementsParser() { } | 1218 virtual ~FindElementsParser() { } |
| 1219 | 1219 |
| 1220 virtual bool Parse(base::Value* value) const OVERRIDE { | 1220 virtual bool Parse(base::Value* value) const OVERRIDE { |
| 1221 if (!value->IsType(Value::TYPE_LIST)) | 1221 if (!value->IsList()) |
| 1222 return false; | 1222 return false; |
| 1223 ListValue* list = static_cast<ListValue*>(value); | 1223 ListValue* list = static_cast<ListValue*>(value); |
| 1224 for (size_t i = 0; i < list->GetSize(); ++i) { | 1224 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 1225 ElementId element; | 1225 ElementId element; |
| 1226 Value* element_value = NULL; | 1226 Value* element_value = NULL; |
| 1227 if (!list->Get(i, &element_value)) | 1227 if (!list->Get(i, &element_value)) |
| 1228 return false; | 1228 return false; |
| 1229 if (!SetFromValue(element_value, &element)) | 1229 if (!SetFromValue(element_value, &element)) |
| 1230 return false; | 1230 return false; |
| 1231 elements_->push_back(element); | 1231 elements_->push_back(element); |
| 1232 } | 1232 } |
| 1233 return true; | 1233 return true; |
| 1234 } | 1234 } |
| 1235 private: | 1235 private: |
| 1236 std::vector<ElementId>* elements_; | 1236 std::vector<ElementId>* elements_; |
| 1237 }; | 1237 }; |
| 1238 | 1238 |
| 1239 class FindElementParser : public ValueParser { | 1239 class FindElementParser : public ValueParser { |
| 1240 public: | 1240 public: |
| 1241 explicit FindElementParser(std::vector<ElementId>* elements) | 1241 explicit FindElementParser(std::vector<ElementId>* elements) |
| 1242 : elements_(elements) { } | 1242 : elements_(elements) { } |
| 1243 | 1243 |
| 1244 virtual ~FindElementParser() { } | 1244 virtual ~FindElementParser() { } |
| 1245 | 1245 |
| 1246 virtual bool Parse(base::Value* value) const OVERRIDE { | 1246 virtual bool Parse(base::Value* value) const OVERRIDE { |
| 1247 if (value->IsType(Value::TYPE_NULL)) | 1247 if (value->IsNull()) |
| 1248 return true; | 1248 return true; |
| 1249 ElementId element; | 1249 ElementId element; |
| 1250 bool set = SetFromValue(value, &element); | 1250 bool set = SetFromValue(value, &element); |
| 1251 if (set) | 1251 if (set) |
| 1252 elements_->push_back(element); | 1252 elements_->push_back(element); |
| 1253 return set; | 1253 return set; |
| 1254 } | 1254 } |
| 1255 private: | 1255 private: |
| 1256 std::vector<ElementId>* elements_; | 1256 std::vector<ElementId>* elements_; |
| 1257 }; | 1257 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1285 const ElementId& element, | 1285 const ElementId& element, |
| 1286 const Point& location) { | 1286 const Point& location) { |
| 1287 class IsElementClickableParser : public ValueParser { | 1287 class IsElementClickableParser : public ValueParser { |
| 1288 public: | 1288 public: |
| 1289 IsElementClickableParser(bool* clickable, std::string* message) | 1289 IsElementClickableParser(bool* clickable, std::string* message) |
| 1290 : clickable_(clickable), message_(message) { } | 1290 : clickable_(clickable), message_(message) { } |
| 1291 | 1291 |
| 1292 virtual ~IsElementClickableParser() { } | 1292 virtual ~IsElementClickableParser() { } |
| 1293 | 1293 |
| 1294 virtual bool Parse(base::Value* value) const OVERRIDE { | 1294 virtual bool Parse(base::Value* value) const OVERRIDE { |
| 1295 if (!value->IsType(Value::TYPE_DICTIONARY)) | 1295 if (!value->IsDictionary()) |
| 1296 return false; | 1296 return false; |
| 1297 DictionaryValue* dict = static_cast<DictionaryValue*>(value); | 1297 DictionaryValue* dict = static_cast<DictionaryValue*>(value); |
| 1298 dict->GetString("message", message_); | 1298 dict->GetString("message", message_); |
| 1299 return dict->GetBoolean("clickable", clickable_); | 1299 return dict->GetBoolean("clickable", clickable_); |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 private: | 1302 private: |
| 1303 bool* clickable_; | 1303 bool* clickable_; |
| 1304 std::string* message_; | 1304 std::string* message_; |
| 1305 }; | 1305 }; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 Error* Session::GetAppCacheStatus(int* status) { | 1386 Error* Session::GetAppCacheStatus(int* status) { |
| 1387 return ExecuteScriptAndParse( | 1387 return ExecuteScriptAndParse( |
| 1388 current_target_, | 1388 current_target_, |
| 1389 atoms::GET_APPCACHE_STATUS, | 1389 atoms::GET_APPCACHE_STATUS, |
| 1390 "getAppcacheStatus", | 1390 "getAppcacheStatus", |
| 1391 new ListValue(), | 1391 new ListValue(), |
| 1392 CreateDirectValueParser(status)); | 1392 CreateDirectValueParser(status)); |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 } // namespace webdriver | 1395 } // namespace webdriver |
| OLD | NEW |