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

Side by Side Diff: chrome/common/common_param_traits_unittest.cc

Issue 7647026: base: Add three helper functions to Values API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a typo Ceate -> Create 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 #include <string.h> 5 #include <string.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/common/common_param_traits.h" 10 #include "content/common/common_param_traits.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Make sure we don't read out the bitmap! 112 // Make sure we don't read out the bitmap!
113 SkBitmap bad_output; 113 SkBitmap bad_output;
114 iter = NULL; 114 iter = NULL;
115 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); 115 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output));
116 } 116 }
117 117
118 TEST(IPCMessageTest, ListValue) { 118 TEST(IPCMessageTest, ListValue) {
119 ListValue input; 119 ListValue input;
120 input.Set(0, Value::CreateDoubleValue(42.42)); 120 input.Set(0, Value::CreateDoubleValue(42.42));
121 input.Set(1, Value::CreateStringValue("forty")); 121 input.Set(1, Value::CreateStringValue("forty"));
122 input.Set(2, Value::CreateNullValue()); 122 input.Set(2, base::NullValue());
123 123
124 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 124 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
125 IPC::WriteParam(&msg, input); 125 IPC::WriteParam(&msg, input);
126 126
127 ListValue output; 127 ListValue output;
128 void* iter = NULL; 128 void* iter = NULL;
129 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 129 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
130 130
131 EXPECT_TRUE(input.Equals(&output)); 131 EXPECT_TRUE(input.Equals(&output));
132 132
133 // Also test the corrupt case. 133 // Also test the corrupt case.
134 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); 134 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
135 bad_msg.WriteInt(99); 135 bad_msg.WriteInt(99);
136 iter = NULL; 136 iter = NULL;
137 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); 137 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
138 } 138 }
139 139
140 TEST(IPCMessageTest, DictionaryValue) { 140 TEST(IPCMessageTest, DictionaryValue) {
141 DictionaryValue input; 141 DictionaryValue input;
142 input.Set("null", Value::CreateNullValue()); 142 input.Set("null", base::NullValue());
143 input.Set("bool", Value::CreateBooleanValue(true)); 143 input.Set("bool", base::TrueValue());
144 input.Set("int", Value::CreateIntegerValue(42)); 144 input.Set("int", Value::CreateIntegerValue(42));
145 145
146 scoped_ptr<DictionaryValue> subdict(new DictionaryValue()); 146 scoped_ptr<DictionaryValue> subdict(new DictionaryValue());
147 subdict->Set("str", Value::CreateStringValue("forty two")); 147 subdict->Set("str", Value::CreateStringValue("forty two"));
148 subdict->Set("bool", Value::CreateBooleanValue(false)); 148 subdict->Set("bool", base::FalseValue());
149 149
150 scoped_ptr<ListValue> sublist(new ListValue()); 150 scoped_ptr<ListValue> sublist(new ListValue());
151 sublist->Set(0, Value::CreateDoubleValue(42.42)); 151 sublist->Set(0, Value::CreateDoubleValue(42.42));
152 sublist->Set(1, Value::CreateStringValue("forty")); 152 sublist->Set(1, Value::CreateStringValue("forty"));
153 sublist->Set(2, Value::CreateStringValue("two")); 153 sublist->Set(2, Value::CreateStringValue("two"));
154 subdict->Set("list", sublist.release()); 154 subdict->Set("list", sublist.release());
155 155
156 input.Set("dict", subdict.release()); 156 input.Set("dict", subdict.release());
157 157
158 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 158 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
(...skipping 18 matching lines...) Expand all
177 177
178 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 178 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
179 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); 179 IPC::ParamTraits<net::HostPortPair>::Write(&msg, input);
180 180
181 net::HostPortPair output; 181 net::HostPortPair output;
182 void* iter = NULL; 182 void* iter = NULL;
183 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); 183 EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output));
184 EXPECT_EQ(input.host(), output.host()); 184 EXPECT_EQ(input.host(), output.host());
185 EXPECT_EQ(input.port(), output.port()); 185 EXPECT_EQ(input.port(), output.port());
186 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_ui_unittest.cc ('k') | chrome/common/json_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698