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

Side by Side Diff: chrome/test/automation/javascript_message_utils.h

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 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
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 #ifndef CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_ 5 #ifndef CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
6 #define CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_ 6 #define CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/test/automation/dom_element_proxy.h" 16 #include "chrome/test/automation/dom_element_proxy.h"
17 17
18 // ValueConversionTraits contains functions for creating a value from a 18 // ValueConversionTraits contains functions for creating a value from a
19 // type, and setting a type from a value. This is general-purpose and can 19 // type, and setting a type from a value. This is general-purpose and can
20 // be moved to a common location if needed. 20 // be moved to a common location if needed.
21 template <class T> 21 template <class T>
22 struct ValueConversionTraits { 22 struct ValueConversionTraits {
23 }; 23 };
24 24
25 template <> 25 template <>
26 struct ValueConversionTraits<int> { 26 struct ValueConversionTraits<int> {
27 static Value* CreateValue(int t) { 27 static Value* CreateValue(int t) {
28 return Value::CreateIntegerValue(t); 28 return base::NumberValue::New(t);
29 } 29 }
30 static bool SetFromValue(Value* value, int* t) { 30 static bool SetFromValue(Value* value, int* t) {
31 return value->GetAsInteger(t); 31 return value->GetAsInteger(t);
32 } 32 }
33 }; 33 };
34 34
35 template <> 35 template <>
36 struct ValueConversionTraits<bool> { 36 struct ValueConversionTraits<bool> {
37 static Value* CreateValue(bool t) { 37 static Value* CreateValue(bool t) {
38 return Value::CreateBooleanValue(t); 38 return base::BooleanValue::New(t);
39 } 39 }
40 static bool SetFromValue(Value* value, bool* t) { 40 static bool SetFromValue(Value* value, bool* t) {
41 return value->GetAsBoolean(t); 41 return value->GetAsBoolean(t);
42 } 42 }
43 }; 43 };
44 44
45 template <> 45 template <>
46 struct ValueConversionTraits<std::string> { 46 struct ValueConversionTraits<std::string> {
47 static Value* CreateValue(const std::string& t) { 47 static Value* CreateValue(const std::string& t) {
48 return Value::CreateStringValue(t); 48 return base::StringValue::New(t);
49 } 49 }
50 static bool SetFromValue(Value* value, std::string* t) { 50 static bool SetFromValue(Value* value, std::string* t) {
51 return value->GetAsString(t); 51 return value->GetAsString(t);
52 } 52 }
53 }; 53 };
54 54
55 template <> 55 template <>
56 struct ValueConversionTraits<DOMElementProxy::By> { 56 struct ValueConversionTraits<DOMElementProxy::By> {
57 typedef DOMElementProxy::By type; 57 typedef DOMElementProxy::By type;
58 static Value* CreateValue(const type& t) { 58 static Value* CreateValue(const type& t) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const T2& arg2, const T3& arg3) { 135 const T2& arg2, const T3& arg3) {
136 return base::StringPrintf(format.c_str(), 136 return base::StringPrintf(format.c_str(),
137 JSONStringify(arg1).c_str(), 137 JSONStringify(arg1).c_str(),
138 JSONStringify(arg2).c_str(), 138 JSONStringify(arg2).c_str(),
139 JSONStringify(arg3).c_str()); 139 JSONStringify(arg3).c_str());
140 } 140 }
141 141
142 } // namespace javascript_utils 142 } // namespace javascript_utils
143 143
144 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_ 144 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy_uitest.cc ('k') | chrome/test/live_sync/multiple_client_preferences_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698