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

Side by Side Diff: chrome/test/webdriver/webdriver_element_id.cc

Issue 23526047: Delete old chromedriver code, and remove mongoose webserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/webdriver_element_id.h ('k') | chrome/test/webdriver/webdriver_error.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/webdriver/webdriver_element_id.h"
6
7 #include "base/values.h"
8 #include "base/logging.h"
9
10 namespace {
11
12 // Special dictionary key to identify an element ID to WebDriver atoms and
13 // remote clients.
14 const char kWebElementKey[] = "ELEMENT";
15
16 } // namespace
17
18 namespace webdriver {
19
20 const char LocatorType::kClassName[] = "className";
21 const char LocatorType::kCss[] = "css";
22 const char LocatorType::kId[] = "id";
23 const char LocatorType::kLinkText[] = "linkText";
24 const char LocatorType::kName[] = "name";
25 const char LocatorType::kPartialLinkText[] = "partialLinkText";
26 const char LocatorType::kTagName[] = "tagName";
27 const char LocatorType::kXpath[] = "xpath";
28
29 ElementId::ElementId() : is_valid_(false) {}
30
31 ElementId::ElementId(const std::string& id) : id_(id), is_valid_(true) {}
32
33 ElementId::ElementId(const base::Value* value) {
34 is_valid_ = false;
35 if (value->IsType(base::Value::TYPE_DICTIONARY)) {
36 is_valid_ = static_cast<const base::DictionaryValue*>(value)->
37 GetString(kWebElementKey, &id_);
38 }
39 }
40
41 ElementId::~ElementId() {}
42
43 base::Value* ElementId::ToValue() const {
44 CHECK(is_valid_);
45 if (id_.empty())
46 return base::Value::CreateNullValue();
47 base::DictionaryValue* element = new base::DictionaryValue();
48 element->SetString(kWebElementKey, id_);
49 return element;
50 }
51
52 bool ElementId::is_valid() const {
53 return is_valid_;
54 }
55
56 } // namespace webdriver
57
58 base::Value* ValueConversionTraits<webdriver::ElementId>::CreateValueFrom(
59 const webdriver::ElementId& t) {
60 return t.ToValue();
61 }
62
63 bool ValueConversionTraits<webdriver::ElementId>::SetFromValue(
64 const base::Value* value, webdriver::ElementId* t) {
65 webdriver::ElementId id(value);
66 if (id.is_valid())
67 *t = id;
68 return id.is_valid();
69 }
70
71 bool ValueConversionTraits<webdriver::ElementId>::CanConvert(
72 const base::Value* value) {
73 webdriver::ElementId t;
74 return SetFromValue(value, &t);
75 }
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_element_id.h ('k') | chrome/test/webdriver/webdriver_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698