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_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_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/values.h" | 12 |
| 13 using base::Value; |
13 | 14 |
14 namespace webdriver { | 15 namespace webdriver { |
15 | 16 |
16 SkipParsing* kSkipParsing = NULL; | 17 SkipParsing* kSkipParsing = NULL; |
17 | 18 |
18 std::string GenerateRandomID() { | 19 std::string GenerateRandomID() { |
19 uint64 msb = base::RandUint64(); | 20 uint64 msb = base::RandUint64(); |
20 uint64 lsb = base::RandUint64(); | 21 uint64 lsb = base::RandUint64(); |
21 return base::StringPrintf("%016" PRIx64 "%016" PRIx64, msb, lsb); | 22 return base::StringPrintf("%016" PRIx64 "%016" PRIx64, msb, lsb); |
22 } | 23 } |
23 | 24 |
24 std::string JsonStringify(const Value* value) { | 25 std::string JsonStringify(const Value* value) { |
25 std::string json; | 26 std::string json; |
26 base::JSONWriter::Write(value, false, &json); | 27 base::JSONWriter::Write(value, false, &json); |
27 return json; | 28 return json; |
28 } | 29 } |
29 | 30 |
| 31 const char* GetJsonTypeName(Value::Type type) { |
| 32 switch (type) { |
| 33 case Value::TYPE_NULL: |
| 34 return "null"; |
| 35 case Value::TYPE_BOOLEAN: |
| 36 return "boolean"; |
| 37 case Value::TYPE_INTEGER: |
| 38 return "integer"; |
| 39 case Value::TYPE_DOUBLE: |
| 40 return "double"; |
| 41 case Value::TYPE_STRING: |
| 42 return "string"; |
| 43 case Value::TYPE_BINARY: |
| 44 return "binary"; |
| 45 case Value::TYPE_DICTIONARY: |
| 46 return "dictionary"; |
| 47 case Value::TYPE_LIST: |
| 48 return "list"; |
| 49 } |
| 50 return "unknown"; |
| 51 } |
| 52 |
30 ValueParser::ValueParser() { } | 53 ValueParser::ValueParser() { } |
31 | 54 |
32 ValueParser::~ValueParser() { } | 55 ValueParser::~ValueParser() { } |
33 | 56 |
34 } // namespace webdriver | 57 } // namespace webdriver |
35 | 58 |
36 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( | 59 bool ValueConversionTraits<webdriver::SkipParsing>::SetFromValue( |
37 const base::Value* value, const webdriver::SkipParsing* t) { | 60 const base::Value* value, const webdriver::SkipParsing* t) { |
38 return true; | 61 return true; |
39 } | 62 } |
40 | 63 |
41 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( | 64 bool ValueConversionTraits<webdriver::SkipParsing>::CanConvert( |
42 const base::Value* value) { | 65 const base::Value* value) { |
43 return true; | 66 return true; |
44 } | 67 } |
OLD | NEW |