| 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_element_id.h" | 5 #include "chrome/test/webdriver/webdriver_element_id.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/test/automation/javascript_message_utils.h" | 9 #include "chrome/test/automation/javascript_message_utils.h" |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const char LocatorType::kPartialLinkText[] = "partialLinkText"; | 26 const char LocatorType::kPartialLinkText[] = "partialLinkText"; |
| 27 const char LocatorType::kTagName[] = "tagName"; | 27 const char LocatorType::kTagName[] = "tagName"; |
| 28 const char LocatorType::kXpath[] = "xpath"; | 28 const char LocatorType::kXpath[] = "xpath"; |
| 29 | 29 |
| 30 ElementId::ElementId() : is_valid_(false) {} | 30 ElementId::ElementId() : is_valid_(false) {} |
| 31 | 31 |
| 32 ElementId::ElementId(const std::string& id) : id_(id), is_valid_(true) {} | 32 ElementId::ElementId(const std::string& id) : id_(id), is_valid_(true) {} |
| 33 | 33 |
| 34 ElementId::ElementId(const Value* value) { | 34 ElementId::ElementId(const Value* value) { |
| 35 is_valid_ = false; | 35 is_valid_ = false; |
| 36 if (value->IsType(Value::TYPE_DICTIONARY)) { | 36 if (value->IsDictionary()) { |
| 37 is_valid_ = static_cast<const DictionaryValue*>(value)-> | 37 is_valid_ = static_cast<const DictionaryValue*>(value)-> |
| 38 GetString(kWebElementKey, &id_); | 38 GetString(kWebElementKey, &id_); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 ElementId::~ElementId() {} | 42 ElementId::~ElementId() {} |
| 43 | 43 |
| 44 Value* ElementId::ToValue() const { | 44 Value* ElementId::ToValue() const { |
| 45 CHECK(is_valid_); | 45 CHECK(is_valid_); |
| 46 if (id_.empty()) | 46 if (id_.empty()) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 if (id.is_valid()) | 67 if (id.is_valid()) |
| 68 *t = id; | 68 *t = id; |
| 69 return id.is_valid(); | 69 return id.is_valid(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool ValueConversionTraits<webdriver::ElementId>::CanConvert( | 72 bool ValueConversionTraits<webdriver::ElementId>::CanConvert( |
| 73 const base::Value* value) { | 73 const base::Value* value) { |
| 74 webdriver::ElementId t; | 74 webdriver::ElementId t; |
| 75 return SetFromValue(value, &t); | 75 return SetFromValue(value, &t); |
| 76 } | 76 } |
| OLD | NEW |