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

Side by Side Diff: mojo/public/cpp/bindings/tests/map_unittest.cc

Issue 1475813002: Mojo C++ bindings: support passing associated interface pointers/requests in method parameter lists… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@25_use_multiplex_router
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/public/cpp/bindings/array.h" 5 #include "mojo/public/cpp/bindings/array.h"
6 #include "mojo/public/cpp/bindings/lib/array_serialization.h" 6 #include "mojo/public/cpp/bindings/lib/array_serialization.h"
7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 7 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
8 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" 8 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
9 #include "mojo/public/cpp/bindings/lib/validate_params.h" 9 #include "mojo/public/cpp/bindings/lib/validate_params.h"
10 #include "mojo/public/cpp/bindings/map.h" 10 #include "mojo/public/cpp/bindings/map.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 array[0].insert(1, 42); 272 array[0].insert(1, 42);
273 273
274 size_t size = GetSerializedSize_(array); 274 size_t size = GetSerializedSize_(array);
275 FixedBufferForTesting buf(size); 275 FixedBufferForTesting buf(size);
276 Array_Data<Map_Data<int32_t, int8_t>*>* data; 276 Array_Data<Map_Data<int32_t, int8_t>*>* data;
277 ArrayValidateParams validate_params( 277 ArrayValidateParams validate_params(
278 0, false, new ArrayValidateParams(0, false, nullptr)); 278 0, false, new ArrayValidateParams(0, false, nullptr));
279 SerializeArray_(array.Pass(), &buf, &data, &validate_params); 279 SerializeArray_(array.Pass(), &buf, &data, &validate_params);
280 280
281 Array<Map<int32_t, int8_t>> deserialized_array; 281 Array<Map<int32_t, int8_t>> deserialized_array;
282 Deserialize_(data, &deserialized_array); 282 Deserialize_(data, &deserialized_array, nullptr);
283 283
284 ASSERT_EQ(1u, deserialized_array.size()); 284 ASSERT_EQ(1u, deserialized_array.size());
285 ASSERT_EQ(1u, deserialized_array[0].size()); 285 ASSERT_EQ(1u, deserialized_array[0].size());
286 ASSERT_EQ(42, deserialized_array[0].at(1)); 286 ASSERT_EQ(42, deserialized_array[0].at(1));
287 } 287 }
288 288
289 { 289 {
290 Array<Map<String, Array<bool>>> array(1); 290 Array<Map<String, Array<bool>>> array(1);
291 Array<bool> map_value(2); 291 Array<bool> map_value(2);
292 map_value[0] = false; 292 map_value[0] = false;
293 map_value[1] = true; 293 map_value[1] = true;
294 array[0].insert("hello world", map_value.Pass()); 294 array[0].insert("hello world", map_value.Pass());
295 295
296 size_t size = GetSerializedSize_(array); 296 size_t size = GetSerializedSize_(array);
297 FixedBufferForTesting buf(size); 297 FixedBufferForTesting buf(size);
298 Array_Data<Map_Data<String_Data*, Array_Data<bool>*>*>* data; 298 Array_Data<Map_Data<String_Data*, Array_Data<bool>*>*>* data;
299 ArrayValidateParams validate_params( 299 ArrayValidateParams validate_params(
300 0, false, new ArrayValidateParams( 300 0, false, new ArrayValidateParams(
301 0, false, new ArrayValidateParams(0, false, nullptr))); 301 0, false, new ArrayValidateParams(0, false, nullptr)));
302 SerializeArray_(array.Pass(), &buf, &data, &validate_params); 302 SerializeArray_(array.Pass(), &buf, &data, &validate_params);
303 303
304 Array<Map<String, Array<bool>>> deserialized_array; 304 Array<Map<String, Array<bool>>> deserialized_array;
305 Deserialize_(data, &deserialized_array); 305 Deserialize_(data, &deserialized_array, nullptr);
306 306
307 ASSERT_EQ(1u, deserialized_array.size()); 307 ASSERT_EQ(1u, deserialized_array.size());
308 ASSERT_EQ(1u, deserialized_array[0].size()); 308 ASSERT_EQ(1u, deserialized_array[0].size());
309 ASSERT_FALSE(deserialized_array[0].at("hello world")[0]); 309 ASSERT_FALSE(deserialized_array[0].at("hello world")[0]);
310 ASSERT_TRUE(deserialized_array[0].at("hello world")[1]); 310 ASSERT_TRUE(deserialized_array[0].at("hello world")[1]);
311 } 311 }
312 } 312 }
313 313
314 } // namespace 314 } // namespace
315 } // namespace test 315 } // namespace test
316 } // namespace mojo 316 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/associated_interface_unittest.cc ('k') | mojo/public/cpp/bindings/tests/struct_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698