OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/common_param_traits.h" | 10 #include "chrome/common/common_param_traits.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 memset(bogus_pixels.get(), 'B', bogus_pixels_size); | 111 memset(bogus_pixels.get(), 'B', bogus_pixels_size); |
112 bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); | 112 bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); |
113 // Make sure we don't read out the bitmap! | 113 // Make sure we don't read out the bitmap! |
114 SkBitmap bad_output; | 114 SkBitmap bad_output; |
115 iter = NULL; | 115 iter = NULL; |
116 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); | 116 EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); |
117 } | 117 } |
118 | 118 |
119 TEST(IPCMessageTest, ListValue) { | 119 TEST(IPCMessageTest, ListValue) { |
120 ListValue input; | 120 ListValue input; |
121 input.Set(0, Value::CreateRealValue(42.42)); | 121 input.Set(0, Value::CreateDoubleValue(42.42)); |
122 input.Set(1, Value::CreateStringValue("forty")); | 122 input.Set(1, Value::CreateStringValue("forty")); |
123 input.Set(2, Value::CreateNullValue()); | 123 input.Set(2, Value::CreateNullValue()); |
124 | 124 |
125 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 125 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
126 IPC::WriteParam(&msg, input); | 126 IPC::WriteParam(&msg, input); |
127 | 127 |
128 ListValue output; | 128 ListValue output; |
129 void* iter = NULL; | 129 void* iter = NULL; |
130 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); | 130 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); |
131 | 131 |
(...skipping 10 matching lines...) Expand all Loading... |
142 DictionaryValue input; | 142 DictionaryValue input; |
143 input.Set("null", Value::CreateNullValue()); | 143 input.Set("null", Value::CreateNullValue()); |
144 input.Set("bool", Value::CreateBooleanValue(true)); | 144 input.Set("bool", Value::CreateBooleanValue(true)); |
145 input.Set("int", Value::CreateIntegerValue(42)); | 145 input.Set("int", Value::CreateIntegerValue(42)); |
146 | 146 |
147 scoped_ptr<DictionaryValue> subdict(new DictionaryValue()); | 147 scoped_ptr<DictionaryValue> subdict(new DictionaryValue()); |
148 subdict->Set("str", Value::CreateStringValue("forty two")); | 148 subdict->Set("str", Value::CreateStringValue("forty two")); |
149 subdict->Set("bool", Value::CreateBooleanValue(false)); | 149 subdict->Set("bool", Value::CreateBooleanValue(false)); |
150 | 150 |
151 scoped_ptr<ListValue> sublist(new ListValue()); | 151 scoped_ptr<ListValue> sublist(new ListValue()); |
152 sublist->Set(0, Value::CreateRealValue(42.42)); | 152 sublist->Set(0, Value::CreateDoubleValue(42.42)); |
153 sublist->Set(1, Value::CreateStringValue("forty")); | 153 sublist->Set(1, Value::CreateStringValue("forty")); |
154 sublist->Set(2, Value::CreateStringValue("two")); | 154 sublist->Set(2, Value::CreateStringValue("two")); |
155 subdict->Set("list", sublist.release()); | 155 subdict->Set("list", sublist.release()); |
156 | 156 |
157 input.Set("dict", subdict.release()); | 157 input.Set("dict", subdict.release()); |
158 | 158 |
159 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); | 159 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
160 IPC::WriteParam(&msg, input); | 160 IPC::WriteParam(&msg, input); |
161 | 161 |
162 DictionaryValue output; | 162 DictionaryValue output; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 printing::PrinterCapsAndDefaults output; | 279 printing::PrinterCapsAndDefaults output; |
280 void* iter = NULL; | 280 void* iter = NULL; |
281 EXPECT_TRUE(IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Read( | 281 EXPECT_TRUE(IPC::ParamTraits<printing::PrinterCapsAndDefaults>::Read( |
282 &msg, &iter, &output)); | 282 &msg, &iter, &output)); |
283 EXPECT_TRUE(input.printer_capabilities == output.printer_capabilities); | 283 EXPECT_TRUE(input.printer_capabilities == output.printer_capabilities); |
284 EXPECT_TRUE(input.caps_mime_type == output.caps_mime_type); | 284 EXPECT_TRUE(input.caps_mime_type == output.caps_mime_type); |
285 EXPECT_TRUE(input.printer_defaults == output.printer_defaults); | 285 EXPECT_TRUE(input.printer_defaults == output.printer_defaults); |
286 EXPECT_TRUE(input.defaults_mime_type == output.defaults_mime_type); | 286 EXPECT_TRUE(input.defaults_mime_type == output.defaults_mime_type); |
287 } | 287 } |
288 | 288 |
OLD | NEW |