| OLD | NEW |
| 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 <vector> | 5 #include <vector> |
| 6 #include "mojo/public/cpp/bindings/array.h" | 6 #include "mojo/public/cpp/bindings/array.h" |
| 7 #include "mojo/public/cpp/bindings/binding.h" | 7 #include "mojo/public/cpp/bindings/binding.h" |
| 8 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 8 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| 9 #include "mojo/public/cpp/bindings/lib/array_serialization.h" | 9 #include "mojo/public/cpp/bindings/lib/array_serialization.h" |
| 10 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" | 10 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" |
| 11 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" | 11 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" |
| 12 #include "mojo/public/cpp/bindings/lib/map_serialization.h" |
| 12 #include "mojo/public/cpp/bindings/string.h" | 13 #include "mojo/public/cpp/bindings/string.h" |
| 13 #include "mojo/public/cpp/environment/environment.h" | 14 #include "mojo/public/cpp/environment/environment.h" |
| 14 #include "mojo/public/cpp/test_support/test_utils.h" | 15 #include "mojo/public/cpp/test_support/test_utils.h" |
| 15 #include "mojo/public/cpp/utility/run_loop.h" | 16 #include "mojo/public/cpp/utility/run_loop.h" |
| 16 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | 17 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" |
| 17 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom.h" | 18 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace mojo { | 21 namespace mojo { |
| 21 namespace test { | 22 namespace test { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 116 |
| 116 TEST(UnionTest, PodSerialization) { | 117 TEST(UnionTest, PodSerialization) { |
| 117 PodUnionPtr pod1(PodUnion::New()); | 118 PodUnionPtr pod1(PodUnion::New()); |
| 118 pod1->set_f_int8(10); | 119 pod1->set_f_int8(10); |
| 119 | 120 |
| 120 size_t size = GetSerializedSize_(pod1, false); | 121 size_t size = GetSerializedSize_(pod1, false); |
| 121 EXPECT_EQ(16U, size); | 122 EXPECT_EQ(16U, size); |
| 122 | 123 |
| 123 mojo::internal::FixedBufferForTesting buf(size); | 124 mojo::internal::FixedBufferForTesting buf(size); |
| 124 internal::PodUnion_Data* data = nullptr; | 125 internal::PodUnion_Data* data = nullptr; |
| 125 SerializeUnion_(pod1.Pass(), &buf, &data, false); | 126 SerializeUnion_(pod1.get(), &buf, &data, false); |
| 126 | 127 |
| 127 PodUnionPtr pod2; | 128 PodUnionPtr pod2(PodUnion::New()); |
| 128 Deserialize_(data, &pod2); | 129 Deserialize_(data, pod2.get()); |
| 129 | 130 |
| 130 EXPECT_EQ(10, pod2->get_f_int8()); | 131 EXPECT_EQ(10, pod2->get_f_int8()); |
| 131 EXPECT_TRUE(pod2->is_f_int8()); | 132 EXPECT_TRUE(pod2->is_f_int8()); |
| 132 EXPECT_EQ(pod2->which(), PodUnion::Tag::F_INT8); | 133 EXPECT_EQ(pod2->which(), PodUnion::Tag::F_INT8); |
| 133 } | 134 } |
| 134 | 135 |
| 135 TEST(UnionTest, EnumSerialization) { | 136 TEST(UnionTest, EnumSerialization) { |
| 136 PodUnionPtr pod1(PodUnion::New()); | 137 PodUnionPtr pod1(PodUnion::New()); |
| 137 pod1->set_f_enum(AN_ENUM_SECOND); | 138 pod1->set_f_enum(AN_ENUM_SECOND); |
| 138 | 139 |
| 139 size_t size = GetSerializedSize_(pod1, false); | 140 size_t size = GetSerializedSize_(pod1, false); |
| 140 EXPECT_EQ(16U, size); | 141 EXPECT_EQ(16U, size); |
| 141 | 142 |
| 142 mojo::internal::FixedBufferForTesting buf(size); | 143 mojo::internal::FixedBufferForTesting buf(size); |
| 143 internal::PodUnion_Data* data = nullptr; | 144 internal::PodUnion_Data* data = nullptr; |
| 144 SerializeUnion_(pod1.Pass(), &buf, &data, false); | 145 SerializeUnion_(pod1.get(), &buf, &data, false); |
| 145 | 146 |
| 146 PodUnionPtr pod2; | 147 PodUnionPtr pod2 = PodUnion::New(); |
| 147 Deserialize_(data, &pod2); | 148 Deserialize_(data, pod2.get()); |
| 148 | 149 |
| 149 EXPECT_EQ(AN_ENUM_SECOND, pod2->get_f_enum()); | 150 EXPECT_EQ(AN_ENUM_SECOND, pod2->get_f_enum()); |
| 150 EXPECT_TRUE(pod2->is_f_enum()); | 151 EXPECT_TRUE(pod2->is_f_enum()); |
| 151 EXPECT_EQ(pod2->which(), PodUnion::Tag::F_ENUM); | 152 EXPECT_EQ(pod2->which(), PodUnion::Tag::F_ENUM); |
| 152 } | 153 } |
| 153 | 154 |
| 154 TEST(UnionTest, PodValidation) { | 155 TEST(UnionTest, PodValidation) { |
| 155 PodUnionPtr pod(PodUnion::New()); | 156 PodUnionPtr pod(PodUnion::New()); |
| 156 pod->set_f_int8(10); | 157 pod->set_f_int8(10); |
| 157 | 158 |
| 158 size_t size = GetSerializedSize_(pod, false); | 159 size_t size = GetSerializedSize_(pod, false); |
| 159 EXPECT_EQ(16U, size); | 160 EXPECT_EQ(16U, size); |
| 160 | 161 |
| 161 mojo::internal::FixedBufferForTesting buf(size); | 162 mojo::internal::FixedBufferForTesting buf(size); |
| 162 internal::PodUnion_Data* data = nullptr; | 163 internal::PodUnion_Data* data = nullptr; |
| 163 SerializeUnion_(pod.Pass(), &buf, &data, false); | 164 SerializeUnion_(pod.get(), &buf, &data, false); |
| 164 void* raw_buf = buf.Leak(); | 165 void* raw_buf = buf.Leak(); |
| 165 mojo::internal::BoundsChecker bounds_checker(data, | 166 mojo::internal::BoundsChecker bounds_checker(data, |
| 166 static_cast<uint32_t>(size), 0); | 167 static_cast<uint32_t>(size), 0); |
| 167 EXPECT_TRUE( | 168 EXPECT_TRUE( |
| 168 internal::PodUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 169 internal::PodUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 169 free(raw_buf); | 170 free(raw_buf); |
| 170 } | 171 } |
| 171 | 172 |
| 172 TEST(UnionTest, SerializeNotNull) { | 173 TEST(UnionTest, SerializeNotNull) { |
| 173 PodUnionPtr pod(PodUnion::New()); | 174 PodUnionPtr pod(PodUnion::New()); |
| 174 pod->set_f_int8(0); | 175 pod->set_f_int8(0); |
| 175 size_t size = GetSerializedSize_(pod, false); | 176 size_t size = GetSerializedSize_(pod, false); |
| 176 mojo::internal::FixedBufferForTesting buf(size); | 177 mojo::internal::FixedBufferForTesting buf(size); |
| 177 internal::PodUnion_Data* data = nullptr; | 178 internal::PodUnion_Data* data = nullptr; |
| 178 SerializeUnion_(pod.Pass(), &buf, &data, false); | 179 SerializeUnion_(pod.get(), &buf, &data, false); |
| 179 EXPECT_FALSE(data->is_null()); | 180 EXPECT_FALSE(data->is_null()); |
| 180 } | 181 } |
| 181 | 182 |
| 182 TEST(UnionTest, SerializeIsNullInlined) { | 183 TEST(UnionTest, SerializeIsNullInlined) { |
| 183 PodUnionPtr pod; | 184 PodUnionPtr pod; |
| 184 size_t size = GetSerializedSize_(pod, false); | 185 size_t size = GetSerializedSize_(pod, false); |
| 185 EXPECT_EQ(16U, size); | 186 EXPECT_EQ(16U, size); |
| 186 mojo::internal::FixedBufferForTesting buf(size); | 187 mojo::internal::FixedBufferForTesting buf(size); |
| 187 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); | 188 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); |
| 188 | 189 |
| 189 // Check that dirty output buffers are handled correctly by serialization. | 190 // Check that dirty output buffers are handled correctly by serialization. |
| 190 data->size = 16U; | 191 data->size = 16U; |
| 191 data->tag = PodUnion::Tag::F_UINT16; | 192 data->tag = PodUnion::Tag::F_UINT16; |
| 192 data->data.f_f_int16 = 20; | 193 data->data.f_f_int16 = 20; |
| 193 | 194 |
| 194 SerializeUnion_(pod.Pass(), &buf, &data, true); | 195 SerializeUnion_(pod.get(), &buf, &data, true); |
| 195 EXPECT_TRUE(data->is_null()); | 196 EXPECT_TRUE(data->is_null()); |
| 196 | 197 |
| 197 PodUnionPtr pod2; | 198 PodUnionPtr pod2 = PodUnion::New(); |
| 198 Deserialize_(data, &pod2); | 199 Deserialize_(data, pod2.get()); |
| 199 EXPECT_TRUE(pod2.is_null()); | 200 EXPECT_EQ(pod2->which(), PodUnion::Tag::__UNKNOWN__); |
| 200 } | 201 } |
| 201 | 202 |
| 202 TEST(UnionTest, SerializeIsNullNotInlined) { | 203 TEST(UnionTest, SerializeIsNullNotInlined) { |
| 203 PodUnionPtr pod; | 204 PodUnionPtr pod; |
| 204 size_t size = GetSerializedSize_(pod, false); | 205 size_t size = GetSerializedSize_(pod, false); |
| 205 EXPECT_EQ(16U, size); | 206 EXPECT_EQ(16U, size); |
| 206 mojo::internal::FixedBufferForTesting buf(size); | 207 mojo::internal::FixedBufferForTesting buf(size); |
| 207 internal::PodUnion_Data* data = nullptr; | 208 internal::PodUnion_Data* data = nullptr; |
| 208 SerializeUnion_(pod.Pass(), &buf, &data, false); | 209 SerializeUnion_(pod.get(), &buf, &data, false); |
| 209 EXPECT_EQ(nullptr, data); | 210 EXPECT_EQ(nullptr, data); |
| 210 } | 211 } |
| 211 | 212 |
| 212 TEST(UnionTest, NullValidation) { | 213 TEST(UnionTest, NullValidation) { |
| 213 void* buf = nullptr; | 214 void* buf = nullptr; |
| 214 mojo::internal::BoundsChecker bounds_checker(buf, 0, 0); | 215 mojo::internal::BoundsChecker bounds_checker(buf, 0, 0); |
| 215 EXPECT_TRUE(internal::PodUnion_Data::Validate(buf, &bounds_checker, false)); | 216 EXPECT_TRUE(internal::PodUnion_Data::Validate(buf, &bounds_checker, false)); |
| 216 } | 217 } |
| 217 | 218 |
| 218 TEST(UnionTest, OutOfAlignmentValidation) { | 219 TEST(UnionTest, OutOfAlignmentValidation) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 245 } | 246 } |
| 246 | 247 |
| 247 TEST(UnionTest, UnknownTagDeserialization) { | 248 TEST(UnionTest, UnknownTagDeserialization) { |
| 248 Environment environment; | 249 Environment environment; |
| 249 size_t size = sizeof(internal::PodUnion_Data); | 250 size_t size = sizeof(internal::PodUnion_Data); |
| 250 mojo::internal::FixedBufferForTesting buf(size); | 251 mojo::internal::FixedBufferForTesting buf(size); |
| 251 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); | 252 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); |
| 252 data->size = size; | 253 data->size = size; |
| 253 data->tag = static_cast<internal::PodUnion_Data::PodUnion_Tag>(100); | 254 data->tag = static_cast<internal::PodUnion_Data::PodUnion_Tag>(100); |
| 254 | 255 |
| 255 PodUnionPtr pod2; | 256 PodUnionPtr pod2 = PodUnion::New(); |
| 256 Deserialize_(data, &pod2); | 257 Deserialize_(data, pod2.get()); |
| 257 | 258 |
| 258 EXPECT_TRUE(pod2->has_unknown_tag()); | 259 EXPECT_TRUE(pod2->has_unknown_tag()); |
| 259 } | 260 } |
| 260 | 261 |
| 261 TEST(UnionTest, UnknownTagValidation) { | 262 TEST(UnionTest, UnknownTagValidation) { |
| 262 Environment environment; | 263 Environment environment; |
| 263 size_t size = sizeof(internal::PodUnion_Data); | 264 size_t size = sizeof(internal::PodUnion_Data); |
| 264 mojo::internal::FixedBufferForTesting buf(size); | 265 mojo::internal::FixedBufferForTesting buf(size); |
| 265 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); | 266 internal::PodUnion_Data* data = internal::PodUnion_Data::New(&buf); |
| 266 data->size = size; | 267 data->size = size; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 309 |
| 309 TEST(UnionTest, StringSerialization) { | 310 TEST(UnionTest, StringSerialization) { |
| 310 ObjectUnionPtr pod1(ObjectUnion::New()); | 311 ObjectUnionPtr pod1(ObjectUnion::New()); |
| 311 | 312 |
| 312 String hello("hello world"); | 313 String hello("hello world"); |
| 313 pod1->set_f_string(hello); | 314 pod1->set_f_string(hello); |
| 314 | 315 |
| 315 size_t size = GetSerializedSize_(pod1, false); | 316 size_t size = GetSerializedSize_(pod1, false); |
| 316 mojo::internal::FixedBufferForTesting buf(size); | 317 mojo::internal::FixedBufferForTesting buf(size); |
| 317 internal::ObjectUnion_Data* data = nullptr; | 318 internal::ObjectUnion_Data* data = nullptr; |
| 318 SerializeUnion_(pod1.Pass(), &buf, &data, false); | 319 SerializeUnion_(pod1.get(), &buf, &data, false); |
| 319 | 320 |
| 320 std::vector<Handle> handles; | 321 std::vector<Handle> handles; |
| 321 data->EncodePointersAndHandles(&handles); | 322 data->EncodePointersAndHandles(&handles); |
| 322 data->DecodePointersAndHandles(&handles); | 323 data->DecodePointersAndHandles(&handles); |
| 323 | 324 |
| 324 ObjectUnionPtr pod2; | 325 ObjectUnionPtr pod2 = ObjectUnion::New(); |
| 325 Deserialize_(data, &pod2); | 326 Deserialize_(data, pod2.get()); |
| 326 EXPECT_EQ(hello, pod2->get_f_string()); | 327 EXPECT_EQ(hello, pod2->get_f_string()); |
| 327 EXPECT_TRUE(pod2->is_f_string()); | 328 EXPECT_TRUE(pod2->is_f_string()); |
| 328 EXPECT_EQ(pod2->which(), ObjectUnion::Tag::F_STRING); | 329 EXPECT_EQ(pod2->which(), ObjectUnion::Tag::F_STRING); |
| 329 } | 330 } |
| 330 | 331 |
| 331 TEST(UnionTest, NullStringValidation) { | 332 TEST(UnionTest, NullStringValidation) { |
| 332 Environment environment; | 333 Environment environment; |
| 333 size_t size = sizeof(internal::ObjectUnion_Data); | 334 size_t size = sizeof(internal::ObjectUnion_Data); |
| 334 mojo::internal::FixedBufferForTesting buf(size); | 335 mojo::internal::FixedBufferForTesting buf(size); |
| 335 internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf); | 336 internal::ObjectUnion_Data* data = internal::ObjectUnion_Data::New(&buf); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 array[0]->set_f_int8(10); | 403 array[0]->set_f_int8(10); |
| 403 array[1]->set_f_int16(12); | 404 array[1]->set_f_int16(12); |
| 404 EXPECT_EQ(2U, array.size()); | 405 EXPECT_EQ(2U, array.size()); |
| 405 | 406 |
| 406 size_t size = GetSerializedSize_(array); | 407 size_t size = GetSerializedSize_(array); |
| 407 EXPECT_EQ(40U, size); | 408 EXPECT_EQ(40U, size); |
| 408 | 409 |
| 409 mojo::internal::FixedBufferForTesting buf(size); | 410 mojo::internal::FixedBufferForTesting buf(size); |
| 410 mojo::internal::Array_Data<internal::PodUnion_Data>* data; | 411 mojo::internal::Array_Data<internal::PodUnion_Data>* data; |
| 411 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); | 412 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); |
| 412 SerializeArray_(array.Pass(), &buf, &data, &validate_params); | 413 SerializeArray_(&array, &buf, &data, &validate_params); |
| 413 | 414 |
| 414 Array<PodUnionPtr> array2; | 415 Array<PodUnionPtr> array2; |
| 415 Deserialize_(data, &array2); | 416 Deserialize_(data, &array2); |
| 416 | 417 |
| 417 EXPECT_EQ(2U, array2.size()); | 418 EXPECT_EQ(2U, array2.size()); |
| 418 | 419 |
| 419 EXPECT_EQ(10, array2[0]->get_f_int8()); | 420 EXPECT_EQ(10, array2[0]->get_f_int8()); |
| 420 EXPECT_EQ(12, array2[1]->get_f_int16()); | 421 EXPECT_EQ(12, array2[1]->get_f_int16()); |
| 421 } | 422 } |
| 422 | 423 |
| 423 TEST(UnionTest, PodUnionInArrayValidation) { | 424 TEST(UnionTest, PodUnionInArrayValidation) { |
| 424 Environment environment; | 425 Environment environment; |
| 425 Array<PodUnionPtr> array(2); | 426 Array<PodUnionPtr> array(2); |
| 426 array[0] = PodUnion::New(); | 427 array[0] = PodUnion::New(); |
| 427 array[1] = PodUnion::New(); | 428 array[1] = PodUnion::New(); |
| 428 | 429 |
| 429 array[0]->set_f_int8(10); | 430 array[0]->set_f_int8(10); |
| 430 array[1]->set_f_int16(12); | 431 array[1]->set_f_int16(12); |
| 431 | 432 |
| 432 size_t size = GetSerializedSize_(array); | 433 size_t size = GetSerializedSize_(array); |
| 433 | 434 |
| 434 mojo::internal::FixedBufferForTesting buf(size); | 435 mojo::internal::FixedBufferForTesting buf(size); |
| 435 mojo::internal::Array_Data<internal::PodUnion_Data>* data; | 436 mojo::internal::Array_Data<internal::PodUnion_Data>* data; |
| 436 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); | 437 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); |
| 437 SerializeArray_(array.Pass(), &buf, &data, &validate_params); | 438 SerializeArray_(&array, &buf, &data, &validate_params); |
| 438 | 439 |
| 439 void* raw_buf = buf.Leak(); | 440 void* raw_buf = buf.Leak(); |
| 440 mojo::internal::BoundsChecker bounds_checker(data, | 441 mojo::internal::BoundsChecker bounds_checker(data, |
| 441 static_cast<uint32_t>(size), 1); | 442 static_cast<uint32_t>(size), 1); |
| 442 | 443 |
| 443 EXPECT_TRUE(Array<PodUnionPtr>::Data_::Validate(raw_buf, &bounds_checker, | 444 EXPECT_TRUE(Array<PodUnionPtr>::Data_::Validate(raw_buf, &bounds_checker, |
| 444 &validate_params)); | 445 &validate_params)); |
| 445 free(raw_buf); | 446 free(raw_buf); |
| 446 } | 447 } |
| 447 TEST(UnionTest, PodUnionInArraySerializationWithNull) { | 448 TEST(UnionTest, PodUnionInArraySerializationWithNull) { |
| 448 Environment environment; | 449 Environment environment; |
| 449 Array<PodUnionPtr> array(2); | 450 Array<PodUnionPtr> array(2); |
| 450 array[0] = PodUnion::New(); | 451 array[0] = PodUnion::New(); |
| 451 | 452 |
| 452 array[0]->set_f_int8(10); | 453 array[0]->set_f_int8(10); |
| 453 EXPECT_EQ(2U, array.size()); | 454 EXPECT_EQ(2U, array.size()); |
| 454 | 455 |
| 455 size_t size = GetSerializedSize_(array); | 456 size_t size = GetSerializedSize_(array); |
| 456 EXPECT_EQ(40U, size); | 457 EXPECT_EQ(40U, size); |
| 457 | 458 |
| 458 mojo::internal::FixedBufferForTesting buf(size); | 459 mojo::internal::FixedBufferForTesting buf(size); |
| 459 mojo::internal::Array_Data<internal::PodUnion_Data>* data; | 460 mojo::internal::Array_Data<internal::PodUnion_Data>* data; |
| 460 mojo::internal::ArrayValidateParams validate_params(0, true, nullptr); | 461 mojo::internal::ArrayValidateParams validate_params(0, true, nullptr); |
| 461 SerializeArray_(array.Pass(), &buf, &data, &validate_params); | 462 SerializeArray_(&array, &buf, &data, &validate_params); |
| 462 | 463 |
| 463 Array<PodUnionPtr> array2; | 464 Array<PodUnionPtr> array2; |
| 464 Deserialize_(data, &array2); | 465 Deserialize_(data, &array2); |
| 465 | 466 |
| 466 EXPECT_EQ(2U, array2.size()); | 467 EXPECT_EQ(2U, array2.size()); |
| 467 | 468 |
| 468 EXPECT_EQ(10, array2[0]->get_f_int8()); | 469 EXPECT_EQ(10, array2[0]->get_f_int8()); |
| 469 EXPECT_TRUE(array2[1].is_null()); | 470 EXPECT_TRUE(array2[1].is_null()); |
| 470 } | 471 } |
| 471 | 472 |
| 472 // TODO(azani): Move back in struct_unittest.cc when possible. | 473 // TODO(azani): Move back in struct_unittest.cc when possible. |
| 473 // Struct tests | 474 // Struct tests |
| 474 TEST(UnionTest, Clone_Union) { | 475 TEST(UnionTest, Clone_Union) { |
| 475 Environment environment; | 476 Environment environment; |
| 476 SmallStructPtr small_struct(SmallStruct::New()); | 477 SmallStructPtr small_struct(SmallStruct::New()); |
| 477 small_struct->pod_union = PodUnion::New(); | 478 small_struct->pod_union = PodUnion::New(); |
| 478 small_struct->pod_union->set_f_int8(10); | 479 small_struct->pod_union->set_f_int8(10); |
| 479 | 480 |
| 480 SmallStructPtr clone = small_struct.Clone(); | 481 SmallStructPtr clone = small_struct.Clone(); |
| 481 EXPECT_EQ(10, clone->pod_union->get_f_int8()); | 482 EXPECT_EQ(10, clone->pod_union->get_f_int8()); |
| 482 } | 483 } |
| 483 | 484 |
| 484 // Serialization test of a struct with a union of plain old data. | 485 // Serialization test of a struct with a union of plain old data. |
| 485 TEST(UnionTest, Serialization_UnionOfPods) { | 486 TEST(UnionTest, Serialization_UnionOfPods) { |
| 486 Environment environment; | 487 Environment environment; |
| 487 SmallStructPtr small_struct(SmallStruct::New()); | 488 SmallStructPtr small_struct(SmallStruct::New()); |
| 488 small_struct->pod_union = PodUnion::New(); | 489 small_struct->pod_union = PodUnion::New(); |
| 489 small_struct->pod_union->set_f_int32(10); | 490 small_struct->pod_union->set_f_int32(10); |
| 490 | 491 |
| 491 size_t size = GetSerializedSize_(small_struct); | 492 size_t size = GetSerializedSize_(*small_struct.get()); |
| 492 | 493 |
| 493 mojo::internal::FixedBufferForTesting buf(size); | 494 mojo::internal::FixedBufferForTesting buf(size); |
| 494 internal::SmallStruct_Data* data = nullptr; | 495 internal::SmallStruct_Data* data = nullptr; |
| 495 Serialize_(small_struct.Pass(), &buf, &data); | 496 Serialize_(small_struct.get(), &buf, &data); |
| 496 | 497 |
| 497 SmallStructPtr deserialized; | 498 SmallStructPtr deserialized(SmallStruct::New()); |
| 498 Deserialize_(data, &deserialized); | 499 Deserialize_(data, deserialized.get()); |
| 499 | 500 |
| 500 EXPECT_EQ(10, deserialized->pod_union->get_f_int32()); | 501 EXPECT_EQ(10, deserialized->pod_union->get_f_int32()); |
| 501 } | 502 } |
| 502 | 503 |
| 503 // Serialization test of a struct with a union of structs. | 504 // Serialization test of a struct with a union of structs. |
| 504 TEST(UnionTest, Serialization_UnionOfObjects) { | 505 TEST(UnionTest, Serialization_UnionOfObjects) { |
| 505 Environment environment; | 506 Environment environment; |
| 506 SmallObjStructPtr obj_struct(SmallObjStruct::New()); | 507 SmallObjStructPtr obj_struct(SmallObjStruct::New()); |
| 507 obj_struct->obj_union = ObjectUnion::New(); | 508 obj_struct->obj_union = ObjectUnion::New(); |
| 508 String hello("hello world"); | 509 String hello("hello world"); |
| 509 obj_struct->obj_union->set_f_string(hello); | 510 obj_struct->obj_union->set_f_string(hello); |
| 510 | 511 |
| 511 size_t size = GetSerializedSize_(obj_struct); | 512 size_t size = GetSerializedSize_(*obj_struct.get()); |
| 512 | 513 |
| 513 mojo::internal::FixedBufferForTesting buf(size); | 514 mojo::internal::FixedBufferForTesting buf(size); |
| 514 internal::SmallObjStruct_Data* data = nullptr; | 515 internal::SmallObjStruct_Data* data = nullptr; |
| 515 Serialize_(obj_struct.Pass(), &buf, &data); | 516 Serialize_(obj_struct.get(), &buf, &data); |
| 516 | 517 |
| 517 std::vector<Handle> handles; | 518 std::vector<Handle> handles; |
| 518 data->EncodePointersAndHandles(&handles); | 519 data->EncodePointersAndHandles(&handles); |
| 519 data->DecodePointersAndHandles(&handles); | 520 data->DecodePointersAndHandles(&handles); |
| 520 | 521 |
| 521 SmallObjStructPtr deserialized; | 522 SmallObjStructPtr deserialized(SmallObjStruct::New()); |
| 522 Deserialize_(data, &deserialized); | 523 Deserialize_(data, deserialized.get()); |
| 523 | 524 |
| 524 EXPECT_EQ(hello, deserialized->obj_union->get_f_string()); | 525 EXPECT_EQ(hello, deserialized->obj_union->get_f_string()); |
| 525 } | 526 } |
| 526 | 527 |
| 527 // Validation test of a struct with a union. | 528 // Validation test of a struct with a union. |
| 528 TEST(UnionTest, Validation_UnionsInStruct) { | 529 TEST(UnionTest, Validation_UnionsInStruct) { |
| 529 Environment environment; | 530 Environment environment; |
| 530 SmallStructPtr small_struct(SmallStruct::New()); | 531 SmallStructPtr small_struct(SmallStruct::New()); |
| 531 small_struct->pod_union = PodUnion::New(); | 532 small_struct->pod_union = PodUnion::New(); |
| 532 small_struct->pod_union->set_f_int32(10); | 533 small_struct->pod_union->set_f_int32(10); |
| 533 | 534 |
| 534 size_t size = GetSerializedSize_(small_struct); | 535 size_t size = GetSerializedSize_(*small_struct.get()); |
| 535 | 536 |
| 536 mojo::internal::FixedBufferForTesting buf(size); | 537 mojo::internal::FixedBufferForTesting buf(size); |
| 537 internal::SmallStruct_Data* data = nullptr; | 538 internal::SmallStruct_Data* data = nullptr; |
| 538 Serialize_(small_struct.Pass(), &buf, &data); | 539 Serialize_(small_struct.get(), &buf, &data); |
| 539 | 540 |
| 540 void* raw_buf = buf.Leak(); | 541 void* raw_buf = buf.Leak(); |
| 541 mojo::internal::BoundsChecker bounds_checker(data, | 542 mojo::internal::BoundsChecker bounds_checker(data, |
| 542 static_cast<uint32_t>(size), 0); | 543 static_cast<uint32_t>(size), 0); |
| 543 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); | 544 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); |
| 544 free(raw_buf); | 545 free(raw_buf); |
| 545 } | 546 } |
| 546 | 547 |
| 547 // Validation test of a struct union fails due to unknown union tag. | 548 // Validation test of a struct union fails due to unknown union tag. |
| 548 TEST(UnionTest, Validation_PodUnionInStruct_Failure) { | 549 TEST(UnionTest, Validation_PodUnionInStruct_Failure) { |
| 549 Environment environment; | 550 Environment environment; |
| 550 SmallStructPtr small_struct(SmallStruct::New()); | 551 SmallStructPtr small_struct(SmallStruct::New()); |
| 551 small_struct->pod_union = PodUnion::New(); | 552 small_struct->pod_union = PodUnion::New(); |
| 552 small_struct->pod_union->set_f_int32(10); | 553 small_struct->pod_union->set_f_int32(10); |
| 553 | 554 |
| 554 size_t size = GetSerializedSize_(small_struct); | 555 size_t size = GetSerializedSize_(*small_struct.get()); |
| 555 | 556 |
| 556 mojo::internal::FixedBufferForTesting buf(size); | 557 mojo::internal::FixedBufferForTesting buf(size); |
| 557 internal::SmallStruct_Data* data = nullptr; | 558 internal::SmallStruct_Data* data = nullptr; |
| 558 Serialize_(small_struct.Pass(), &buf, &data); | 559 Serialize_(small_struct.get(), &buf, &data); |
| 559 data->pod_union.tag = static_cast<internal::PodUnion_Data::PodUnion_Tag>(100); | 560 data->pod_union.tag = static_cast<internal::PodUnion_Data::PodUnion_Tag>(100); |
| 560 | 561 |
| 561 void* raw_buf = buf.Leak(); | 562 void* raw_buf = buf.Leak(); |
| 562 mojo::internal::BoundsChecker bounds_checker(data, | 563 mojo::internal::BoundsChecker bounds_checker(data, |
| 563 static_cast<uint32_t>(size), 0); | 564 static_cast<uint32_t>(size), 0); |
| 564 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); | 565 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); |
| 565 free(raw_buf); | 566 free(raw_buf); |
| 566 } | 567 } |
| 567 | 568 |
| 568 // Validation fails due to non-nullable null union in struct. | 569 // Validation fails due to non-nullable null union in struct. |
| 569 TEST(UnionTest, Validation_NullUnion_Failure) { | 570 TEST(UnionTest, Validation_NullUnion_Failure) { |
| 570 Environment environment; | 571 Environment environment; |
| 571 SmallStructNonNullableUnionPtr small_struct( | 572 SmallStructNonNullableUnionPtr small_struct( |
| 572 SmallStructNonNullableUnion::New()); | 573 SmallStructNonNullableUnion::New()); |
| 573 | 574 |
| 574 size_t size = GetSerializedSize_(small_struct); | 575 size_t size = GetSerializedSize_(*small_struct.get()); |
| 575 | 576 |
| 576 mojo::internal::FixedBufferForTesting buf(size); | 577 mojo::internal::FixedBufferForTesting buf(size); |
| 577 internal::SmallStructNonNullableUnion_Data* data = | 578 internal::SmallStructNonNullableUnion_Data* data = |
| 578 internal::SmallStructNonNullableUnion_Data::New(&buf); | 579 internal::SmallStructNonNullableUnion_Data::New(&buf); |
| 579 | 580 |
| 580 void* raw_buf = buf.Leak(); | 581 void* raw_buf = buf.Leak(); |
| 581 mojo::internal::BoundsChecker bounds_checker(data, | 582 mojo::internal::BoundsChecker bounds_checker(data, |
| 582 static_cast<uint32_t>(size), 0); | 583 static_cast<uint32_t>(size), 0); |
| 583 EXPECT_FALSE(internal::SmallStructNonNullableUnion_Data::Validate( | 584 EXPECT_FALSE(internal::SmallStructNonNullableUnion_Data::Validate( |
| 584 raw_buf, &bounds_checker)); | 585 raw_buf, &bounds_checker)); |
| 585 free(raw_buf); | 586 free(raw_buf); |
| 586 } | 587 } |
| 587 | 588 |
| 588 // Validation passes with nullable null union. | 589 // Validation passes with nullable null union. |
| 589 TEST(UnionTest, Validation_NullableUnion) { | 590 TEST(UnionTest, Validation_NullableUnion) { |
| 590 Environment environment; | 591 Environment environment; |
| 591 SmallStructPtr small_struct(SmallStruct::New()); | 592 SmallStructPtr small_struct(SmallStruct::New()); |
| 592 | 593 |
| 593 size_t size = GetSerializedSize_(small_struct); | 594 size_t size = GetSerializedSize_(*small_struct.get()); |
| 594 | 595 |
| 595 mojo::internal::FixedBufferForTesting buf(size); | 596 mojo::internal::FixedBufferForTesting buf(size); |
| 596 internal::SmallStruct_Data* data = nullptr; | 597 internal::SmallStruct_Data* data = nullptr; |
| 597 Serialize_(small_struct.Pass(), &buf, &data); | 598 Serialize_(small_struct.get(), &buf, &data); |
| 598 | 599 |
| 599 void* raw_buf = buf.Leak(); | 600 void* raw_buf = buf.Leak(); |
| 600 mojo::internal::BoundsChecker bounds_checker(data, | 601 mojo::internal::BoundsChecker bounds_checker(data, |
| 601 static_cast<uint32_t>(size), 0); | 602 static_cast<uint32_t>(size), 0); |
| 602 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); | 603 EXPECT_TRUE(internal::SmallStruct_Data::Validate(raw_buf, &bounds_checker)); |
| 603 free(raw_buf); | 604 free(raw_buf); |
| 604 } | 605 } |
| 605 | 606 |
| 606 // TODO(azani): Move back in map_unittest.cc when possible. | 607 // TODO(azani): Move back in map_unittest.cc when possible. |
| 607 // Map Tests | 608 // Map Tests |
| (...skipping 19 matching lines...) Expand all Loading... |
| 627 map["one"]->set_f_int8(8); | 628 map["one"]->set_f_int8(8); |
| 628 map["two"]->set_f_int16(16); | 629 map["two"]->set_f_int16(16); |
| 629 | 630 |
| 630 size_t size = GetSerializedSize_(map); | 631 size_t size = GetSerializedSize_(map); |
| 631 EXPECT_EQ(120U, size); | 632 EXPECT_EQ(120U, size); |
| 632 | 633 |
| 633 mojo::internal::FixedBufferForTesting buf(size); | 634 mojo::internal::FixedBufferForTesting buf(size); |
| 634 mojo::internal::Map_Data<mojo::internal::String_Data*, | 635 mojo::internal::Map_Data<mojo::internal::String_Data*, |
| 635 internal::PodUnion_Data>* data; | 636 internal::PodUnion_Data>* data; |
| 636 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); | 637 mojo::internal::ArrayValidateParams validate_params(0, false, nullptr); |
| 637 SerializeMap_(map.Pass(), &buf, &data, &validate_params); | 638 SerializeMap_(&map, &buf, &data, &validate_params); |
| 638 | 639 |
| 639 Map<String, PodUnionPtr> map2; | 640 Map<String, PodUnionPtr> map2; |
| 640 Deserialize_(data, &map2); | 641 Deserialize_(data, &map2); |
| 641 | 642 |
| 642 EXPECT_EQ(8, map2["one"]->get_f_int8()); | 643 EXPECT_EQ(8, map2["one"]->get_f_int8()); |
| 643 EXPECT_EQ(16, map2["two"]->get_f_int16()); | 644 EXPECT_EQ(16, map2["two"]->get_f_int16()); |
| 644 } | 645 } |
| 645 | 646 |
| 646 TEST(UnionTest, PodUnionInMapSerializationWithNull) { | 647 TEST(UnionTest, PodUnionInMapSerializationWithNull) { |
| 647 Environment environment; | 648 Environment environment; |
| 648 Map<String, PodUnionPtr> map; | 649 Map<String, PodUnionPtr> map; |
| 649 map.insert("one", PodUnion::New()); | 650 map.insert("one", PodUnion::New()); |
| 650 map.insert("two", nullptr); | 651 map.insert("two", nullptr); |
| 651 | 652 |
| 652 map["one"]->set_f_int8(8); | 653 map["one"]->set_f_int8(8); |
| 653 | 654 |
| 654 size_t size = GetSerializedSize_(map); | 655 size_t size = GetSerializedSize_(map); |
| 655 EXPECT_EQ(120U, size); | 656 EXPECT_EQ(120U, size); |
| 656 | 657 |
| 657 mojo::internal::FixedBufferForTesting buf(size); | 658 mojo::internal::FixedBufferForTesting buf(size); |
| 658 mojo::internal::Map_Data<mojo::internal::String_Data*, | 659 mojo::internal::Map_Data<mojo::internal::String_Data*, |
| 659 internal::PodUnion_Data>* data; | 660 internal::PodUnion_Data>* data; |
| 660 mojo::internal::ArrayValidateParams validate_params(0, true, nullptr); | 661 mojo::internal::ArrayValidateParams validate_params(0, true, nullptr); |
| 661 SerializeMap_(map.Pass(), &buf, &data, &validate_params); | 662 SerializeMap_(&map, &buf, &data, &validate_params); |
| 662 | 663 |
| 663 Map<String, PodUnionPtr> map2; | 664 Map<String, PodUnionPtr> map2; |
| 664 Deserialize_(data, &map2); | 665 Deserialize_(data, &map2); |
| 665 | 666 |
| 666 EXPECT_EQ(8, map2["one"]->get_f_int8()); | 667 EXPECT_EQ(8, map2["one"]->get_f_int8()); |
| 667 EXPECT_TRUE(map2["two"].is_null()); | 668 EXPECT_TRUE(map2["two"].is_null()); |
| 668 } | 669 } |
| 669 | 670 |
| 670 TEST(UnionTest, StructInUnionGetterSetterPasser) { | 671 TEST(UnionTest, StructInUnionGetterSetterPasser) { |
| 671 DummyStructPtr dummy(DummyStruct::New()); | 672 DummyStructPtr dummy(DummyStruct::New()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 683 dummy->f_int8 = 8; | 684 dummy->f_int8 = 8; |
| 684 | 685 |
| 685 ObjectUnionPtr obj(ObjectUnion::New()); | 686 ObjectUnionPtr obj(ObjectUnion::New()); |
| 686 obj->set_f_dummy(dummy.Pass()); | 687 obj->set_f_dummy(dummy.Pass()); |
| 687 | 688 |
| 688 size_t size = GetSerializedSize_(obj, false); | 689 size_t size = GetSerializedSize_(obj, false); |
| 689 EXPECT_EQ(32U, size); | 690 EXPECT_EQ(32U, size); |
| 690 | 691 |
| 691 mojo::internal::FixedBufferForTesting buf(size); | 692 mojo::internal::FixedBufferForTesting buf(size); |
| 692 internal::ObjectUnion_Data* data = nullptr; | 693 internal::ObjectUnion_Data* data = nullptr; |
| 693 SerializeUnion_(obj.Pass(), &buf, &data, false); | 694 SerializeUnion_(obj.get(), &buf, &data, false); |
| 694 | 695 |
| 695 std::vector<Handle> handles; | 696 std::vector<Handle> handles; |
| 696 data->EncodePointersAndHandles(&handles); | 697 data->EncodePointersAndHandles(&handles); |
| 697 data->DecodePointersAndHandles(&handles); | 698 data->DecodePointersAndHandles(&handles); |
| 698 | 699 |
| 699 ObjectUnionPtr obj2; | 700 ObjectUnionPtr obj2 = ObjectUnion::New(); |
| 700 Deserialize_(data, &obj2); | 701 Deserialize_(data, obj2.get()); |
| 701 EXPECT_EQ(8, obj2->get_f_dummy()->f_int8); | 702 EXPECT_EQ(8, obj2->get_f_dummy()->f_int8); |
| 702 } | 703 } |
| 703 | 704 |
| 704 TEST(UnionTest, StructInUnionValidation) { | 705 TEST(UnionTest, StructInUnionValidation) { |
| 705 Environment environment; | 706 Environment environment; |
| 706 DummyStructPtr dummy(DummyStruct::New()); | 707 DummyStructPtr dummy(DummyStruct::New()); |
| 707 dummy->f_int8 = 8; | 708 dummy->f_int8 = 8; |
| 708 | 709 |
| 709 ObjectUnionPtr obj(ObjectUnion::New()); | 710 ObjectUnionPtr obj(ObjectUnion::New()); |
| 710 obj->set_f_dummy(dummy.Pass()); | 711 obj->set_f_dummy(dummy.Pass()); |
| 711 | 712 |
| 712 size_t size = GetSerializedSize_(obj, false); | 713 size_t size = GetSerializedSize_(obj, false); |
| 713 | 714 |
| 714 mojo::internal::FixedBufferForTesting buf(size); | 715 mojo::internal::FixedBufferForTesting buf(size); |
| 715 internal::ObjectUnion_Data* data = nullptr; | 716 internal::ObjectUnion_Data* data = nullptr; |
| 716 SerializeUnion_(obj.Pass(), &buf, &data, false); | 717 SerializeUnion_(obj.get(), &buf, &data, false); |
| 717 | 718 |
| 718 void* raw_buf = buf.Leak(); | 719 void* raw_buf = buf.Leak(); |
| 719 mojo::internal::BoundsChecker bounds_checker(data, | 720 mojo::internal::BoundsChecker bounds_checker(data, |
| 720 static_cast<uint32_t>(size), 0); | 721 static_cast<uint32_t>(size), 0); |
| 721 EXPECT_TRUE( | 722 EXPECT_TRUE( |
| 722 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 723 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 723 free(raw_buf); | 724 free(raw_buf); |
| 724 } | 725 } |
| 725 | 726 |
| 726 TEST(UnionTest, StructInUnionValidationNonNullable) { | 727 TEST(UnionTest, StructInUnionValidationNonNullable) { |
| 727 Environment environment; | 728 Environment environment; |
| 728 DummyStructPtr dummy(nullptr); | 729 DummyStructPtr dummy(nullptr); |
| 729 | 730 |
| 730 ObjectUnionPtr obj(ObjectUnion::New()); | 731 ObjectUnionPtr obj(ObjectUnion::New()); |
| 731 obj->set_f_dummy(dummy.Pass()); | 732 obj->set_f_dummy(dummy.Pass()); |
| 732 | 733 |
| 733 size_t size = GetSerializedSize_(obj, false); | 734 size_t size = GetSerializedSize_(obj, false); |
| 734 | 735 |
| 735 mojo::internal::FixedBufferForTesting buf(size); | 736 mojo::internal::FixedBufferForTesting buf(size); |
| 736 internal::ObjectUnion_Data* data = nullptr; | 737 internal::ObjectUnion_Data* data = nullptr; |
| 737 SerializeUnion_(obj.Pass(), &buf, &data, false); | 738 SerializeUnion_(obj.get(), &buf, &data, false); |
| 738 | 739 |
| 739 void* raw_buf = buf.Leak(); | 740 void* raw_buf = buf.Leak(); |
| 740 mojo::internal::BoundsChecker bounds_checker(data, | 741 mojo::internal::BoundsChecker bounds_checker(data, |
| 741 static_cast<uint32_t>(size), 0); | 742 static_cast<uint32_t>(size), 0); |
| 742 EXPECT_FALSE( | 743 EXPECT_FALSE( |
| 743 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 744 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 744 free(raw_buf); | 745 free(raw_buf); |
| 745 } | 746 } |
| 746 | 747 |
| 747 TEST(UnionTest, StructInUnionValidationNullable) { | 748 TEST(UnionTest, StructInUnionValidationNullable) { |
| 748 Environment environment; | 749 Environment environment; |
| 749 DummyStructPtr dummy(nullptr); | 750 DummyStructPtr dummy(nullptr); |
| 750 | 751 |
| 751 ObjectUnionPtr obj(ObjectUnion::New()); | 752 ObjectUnionPtr obj(ObjectUnion::New()); |
| 752 obj->set_f_nullable(dummy.Pass()); | 753 obj->set_f_nullable(dummy.Pass()); |
| 753 | 754 |
| 754 size_t size = GetSerializedSize_(obj, false); | 755 size_t size = GetSerializedSize_(obj, false); |
| 755 | 756 |
| 756 mojo::internal::FixedBufferForTesting buf(size); | 757 mojo::internal::FixedBufferForTesting buf(size); |
| 757 internal::ObjectUnion_Data* data = nullptr; | 758 internal::ObjectUnion_Data* data = nullptr; |
| 758 SerializeUnion_(obj.Pass(), &buf, &data, false); | 759 SerializeUnion_(obj.get(), &buf, &data, false); |
| 759 | 760 |
| 760 void* raw_buf = buf.Leak(); | 761 void* raw_buf = buf.Leak(); |
| 761 mojo::internal::BoundsChecker bounds_checker(data, | 762 mojo::internal::BoundsChecker bounds_checker(data, |
| 762 static_cast<uint32_t>(size), 0); | 763 static_cast<uint32_t>(size), 0); |
| 763 EXPECT_TRUE( | 764 EXPECT_TRUE( |
| 764 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 765 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 765 free(raw_buf); | 766 free(raw_buf); |
| 766 } | 767 } |
| 767 | 768 |
| 768 TEST(UnionTest, ArrayInUnionGetterSetter) { | 769 TEST(UnionTest, ArrayInUnionGetterSetter) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 787 array[1] = 9; | 788 array[1] = 9; |
| 788 | 789 |
| 789 ObjectUnionPtr obj(ObjectUnion::New()); | 790 ObjectUnionPtr obj(ObjectUnion::New()); |
| 790 obj->set_f_array_int8(array.Pass()); | 791 obj->set_f_array_int8(array.Pass()); |
| 791 | 792 |
| 792 size_t size = GetSerializedSize_(obj, false); | 793 size_t size = GetSerializedSize_(obj, false); |
| 793 EXPECT_EQ(32U, size); | 794 EXPECT_EQ(32U, size); |
| 794 | 795 |
| 795 mojo::internal::FixedBufferForTesting buf(size); | 796 mojo::internal::FixedBufferForTesting buf(size); |
| 796 internal::ObjectUnion_Data* data = nullptr; | 797 internal::ObjectUnion_Data* data = nullptr; |
| 797 SerializeUnion_(obj.Pass(), &buf, &data, false); | 798 SerializeUnion_(obj.get(), &buf, &data, false); |
| 798 | 799 |
| 799 std::vector<Handle> handles; | 800 std::vector<Handle> handles; |
| 800 data->EncodePointersAndHandles(&handles); | 801 data->EncodePointersAndHandles(&handles); |
| 801 data->DecodePointersAndHandles(&handles); | 802 data->DecodePointersAndHandles(&handles); |
| 802 | 803 |
| 803 ObjectUnionPtr obj2; | 804 ObjectUnionPtr obj2 = ObjectUnion::New(); |
| 804 Deserialize_(data, &obj2); | 805 Deserialize_(data, obj2.get()); |
| 805 | 806 |
| 806 EXPECT_EQ(8, obj2->get_f_array_int8()[0]); | 807 EXPECT_EQ(8, obj2->get_f_array_int8()[0]); |
| 807 EXPECT_EQ(9, obj2->get_f_array_int8()[1]); | 808 EXPECT_EQ(9, obj2->get_f_array_int8()[1]); |
| 808 } | 809 } |
| 809 | 810 |
| 810 TEST(UnionTest, ArrayInUnionValidation) { | 811 TEST(UnionTest, ArrayInUnionValidation) { |
| 811 Environment environment; | 812 Environment environment; |
| 812 | 813 |
| 813 Array<int8_t> array(2); | 814 Array<int8_t> array(2); |
| 814 array[0] = 8; | 815 array[0] = 8; |
| 815 array[1] = 9; | 816 array[1] = 9; |
| 816 | 817 |
| 817 ObjectUnionPtr obj(ObjectUnion::New()); | 818 ObjectUnionPtr obj(ObjectUnion::New()); |
| 818 obj->set_f_array_int8(array.Pass()); | 819 obj->set_f_array_int8(array.Pass()); |
| 819 | 820 |
| 820 size_t size = GetSerializedSize_(obj, false); | 821 size_t size = GetSerializedSize_(obj, false); |
| 821 mojo::internal::FixedBufferForTesting buf(size); | 822 mojo::internal::FixedBufferForTesting buf(size); |
| 822 internal::ObjectUnion_Data* data = nullptr; | 823 internal::ObjectUnion_Data* data = nullptr; |
| 823 SerializeUnion_(obj.Pass(), &buf, &data, false); | 824 SerializeUnion_(obj.get(), &buf, &data, false); |
| 824 | 825 |
| 825 std::vector<Handle> handles; | 826 std::vector<Handle> handles; |
| 826 data->EncodePointersAndHandles(&handles); | 827 data->EncodePointersAndHandles(&handles); |
| 827 | 828 |
| 828 void* raw_buf = buf.Leak(); | 829 void* raw_buf = buf.Leak(); |
| 829 mojo::internal::BoundsChecker bounds_checker(data, | 830 mojo::internal::BoundsChecker bounds_checker(data, |
| 830 static_cast<uint32_t>(size), 0); | 831 static_cast<uint32_t>(size), 0); |
| 831 | 832 |
| 832 EXPECT_TRUE( | 833 EXPECT_TRUE( |
| 833 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 834 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 854 map.insert("two", 2); | 855 map.insert("two", 2); |
| 855 | 856 |
| 856 ObjectUnionPtr obj(ObjectUnion::New()); | 857 ObjectUnionPtr obj(ObjectUnion::New()); |
| 857 obj->set_f_map_int8(map.Pass()); | 858 obj->set_f_map_int8(map.Pass()); |
| 858 | 859 |
| 859 size_t size = GetSerializedSize_(obj, false); | 860 size_t size = GetSerializedSize_(obj, false); |
| 860 EXPECT_EQ(112U, size); | 861 EXPECT_EQ(112U, size); |
| 861 | 862 |
| 862 mojo::internal::FixedBufferForTesting buf(size); | 863 mojo::internal::FixedBufferForTesting buf(size); |
| 863 internal::ObjectUnion_Data* data = nullptr; | 864 internal::ObjectUnion_Data* data = nullptr; |
| 864 SerializeUnion_(obj.Pass(), &buf, &data, false); | 865 SerializeUnion_(obj.get(), &buf, &data, false); |
| 865 | 866 |
| 866 std::vector<Handle> handles; | 867 std::vector<Handle> handles; |
| 867 data->EncodePointersAndHandles(&handles); | 868 data->EncodePointersAndHandles(&handles); |
| 868 data->DecodePointersAndHandles(&handles); | 869 data->DecodePointersAndHandles(&handles); |
| 869 | 870 |
| 870 ObjectUnionPtr obj2; | 871 ObjectUnionPtr obj2 = ObjectUnion::New(); |
| 871 Deserialize_(data, &obj2); | 872 Deserialize_(data, obj2.get()); |
| 872 | 873 |
| 873 EXPECT_EQ(1, obj2->get_f_map_int8()["one"]); | 874 EXPECT_EQ(1, obj2->get_f_map_int8()["one"]); |
| 874 EXPECT_EQ(2, obj2->get_f_map_int8()["two"]); | 875 EXPECT_EQ(2, obj2->get_f_map_int8()["two"]); |
| 875 } | 876 } |
| 876 | 877 |
| 877 TEST(UnionTest, MapInUnionValidation) { | 878 TEST(UnionTest, MapInUnionValidation) { |
| 878 Environment environment; | 879 Environment environment; |
| 879 Map<String, int8_t> map; | 880 Map<String, int8_t> map; |
| 880 map.insert("one", 1); | 881 map.insert("one", 1); |
| 881 map.insert("two", 2); | 882 map.insert("two", 2); |
| 882 | 883 |
| 883 ObjectUnionPtr obj(ObjectUnion::New()); | 884 ObjectUnionPtr obj(ObjectUnion::New()); |
| 884 obj->set_f_map_int8(map.Pass()); | 885 obj->set_f_map_int8(map.Pass()); |
| 885 | 886 |
| 886 size_t size = GetSerializedSize_(obj, false); | 887 size_t size = GetSerializedSize_(obj, false); |
| 887 EXPECT_EQ(112U, size); | 888 EXPECT_EQ(112U, size); |
| 888 | 889 |
| 889 mojo::internal::FixedBufferForTesting buf(size); | 890 mojo::internal::FixedBufferForTesting buf(size); |
| 890 internal::ObjectUnion_Data* data = nullptr; | 891 internal::ObjectUnion_Data* data = nullptr; |
| 891 SerializeUnion_(obj.Pass(), &buf, &data, false); | 892 SerializeUnion_(obj.get(), &buf, &data, false); |
| 892 | 893 |
| 893 std::vector<Handle> handles; | 894 std::vector<Handle> handles; |
| 894 data->EncodePointersAndHandles(&handles); | 895 data->EncodePointersAndHandles(&handles); |
| 895 | 896 |
| 896 void* raw_buf = buf.Leak(); | 897 void* raw_buf = buf.Leak(); |
| 897 mojo::internal::BoundsChecker bounds_checker(data, | 898 mojo::internal::BoundsChecker bounds_checker(data, |
| 898 static_cast<uint32_t>(size), 0); | 899 static_cast<uint32_t>(size), 0); |
| 899 | 900 |
| 900 EXPECT_TRUE( | 901 EXPECT_TRUE( |
| 901 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 902 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 918 pod->set_f_int8(10); | 919 pod->set_f_int8(10); |
| 919 | 920 |
| 920 ObjectUnionPtr obj(ObjectUnion::New()); | 921 ObjectUnionPtr obj(ObjectUnion::New()); |
| 921 obj->set_f_pod_union(pod.Pass()); | 922 obj->set_f_pod_union(pod.Pass()); |
| 922 | 923 |
| 923 size_t size = GetSerializedSize_(obj, false); | 924 size_t size = GetSerializedSize_(obj, false); |
| 924 EXPECT_EQ(32U, size); | 925 EXPECT_EQ(32U, size); |
| 925 | 926 |
| 926 mojo::internal::FixedBufferForTesting buf(size); | 927 mojo::internal::FixedBufferForTesting buf(size); |
| 927 internal::ObjectUnion_Data* data = nullptr; | 928 internal::ObjectUnion_Data* data = nullptr; |
| 928 SerializeUnion_(obj.Pass(), &buf, &data, false); | 929 SerializeUnion_(obj.get(), &buf, &data, false); |
| 929 | 930 |
| 930 std::vector<Handle> handles; | 931 std::vector<Handle> handles; |
| 931 data->EncodePointersAndHandles(&handles); | 932 data->EncodePointersAndHandles(&handles); |
| 932 data->DecodePointersAndHandles(&handles); | 933 data->DecodePointersAndHandles(&handles); |
| 933 | 934 |
| 934 ObjectUnionPtr obj2; | 935 ObjectUnionPtr obj2 = ObjectUnion::New(); |
| 935 Deserialize_(data, &obj2); | 936 Deserialize_(data, obj2.get()); |
| 936 EXPECT_EQ(10, obj2->get_f_pod_union()->get_f_int8()); | 937 EXPECT_EQ(10, obj2->get_f_pod_union()->get_f_int8()); |
| 937 } | 938 } |
| 938 | 939 |
| 939 TEST(UnionTest, UnionInUnionValidation) { | 940 TEST(UnionTest, UnionInUnionValidation) { |
| 940 Environment environment; | 941 Environment environment; |
| 941 PodUnionPtr pod(PodUnion::New()); | 942 PodUnionPtr pod(PodUnion::New()); |
| 942 pod->set_f_int8(10); | 943 pod->set_f_int8(10); |
| 943 | 944 |
| 944 ObjectUnionPtr obj(ObjectUnion::New()); | 945 ObjectUnionPtr obj(ObjectUnion::New()); |
| 945 obj->set_f_pod_union(pod.Pass()); | 946 obj->set_f_pod_union(pod.Pass()); |
| 946 | 947 |
| 947 size_t size = GetSerializedSize_(obj, false); | 948 size_t size = GetSerializedSize_(obj, false); |
| 948 EXPECT_EQ(32U, size); | 949 EXPECT_EQ(32U, size); |
| 949 | 950 |
| 950 mojo::internal::FixedBufferForTesting buf(size); | 951 mojo::internal::FixedBufferForTesting buf(size); |
| 951 internal::ObjectUnion_Data* data = nullptr; | 952 internal::ObjectUnion_Data* data = nullptr; |
| 952 SerializeUnion_(obj.Pass(), &buf, &data, false); | 953 SerializeUnion_(obj.get(), &buf, &data, false); |
| 953 | 954 |
| 954 std::vector<Handle> handles; | 955 std::vector<Handle> handles; |
| 955 data->EncodePointersAndHandles(&handles); | 956 data->EncodePointersAndHandles(&handles); |
| 956 | 957 |
| 957 void* raw_buf = buf.Leak(); | 958 void* raw_buf = buf.Leak(); |
| 958 mojo::internal::BoundsChecker bounds_checker(data, | 959 mojo::internal::BoundsChecker bounds_checker(data, |
| 959 static_cast<uint32_t>(size), 0); | 960 static_cast<uint32_t>(size), 0); |
| 960 EXPECT_TRUE( | 961 EXPECT_TRUE( |
| 961 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 962 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 962 free(raw_buf); | 963 free(raw_buf); |
| 963 } | 964 } |
| 964 | 965 |
| 965 TEST(UnionTest, UnionInUnionValidationNonNullable) { | 966 TEST(UnionTest, UnionInUnionValidationNonNullable) { |
| 966 Environment environment; | 967 Environment environment; |
| 967 PodUnionPtr pod(nullptr); | 968 PodUnionPtr pod(nullptr); |
| 968 | 969 |
| 969 ObjectUnionPtr obj(ObjectUnion::New()); | 970 ObjectUnionPtr obj(ObjectUnion::New()); |
| 970 obj->set_f_pod_union(pod.Pass()); | 971 obj->set_f_pod_union(pod.Pass()); |
| 971 | 972 |
| 972 size_t size = GetSerializedSize_(obj, false); | 973 size_t size = GetSerializedSize_(obj, false); |
| 973 | 974 |
| 974 mojo::internal::FixedBufferForTesting buf(size); | 975 mojo::internal::FixedBufferForTesting buf(size); |
| 975 internal::ObjectUnion_Data* data = nullptr; | 976 internal::ObjectUnion_Data* data = nullptr; |
| 976 SerializeUnion_(obj.Pass(), &buf, &data, false); | 977 SerializeUnion_(obj.get(), &buf, &data, false); |
| 977 std::vector<Handle> handles; | 978 std::vector<Handle> handles; |
| 978 data->EncodePointersAndHandles(&handles); | 979 data->EncodePointersAndHandles(&handles); |
| 979 | 980 |
| 980 void* raw_buf = buf.Leak(); | 981 void* raw_buf = buf.Leak(); |
| 981 mojo::internal::BoundsChecker bounds_checker(data, | 982 mojo::internal::BoundsChecker bounds_checker(data, |
| 982 static_cast<uint32_t>(size), 0); | 983 static_cast<uint32_t>(size), 0); |
| 983 EXPECT_FALSE( | 984 EXPECT_FALSE( |
| 984 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 985 internal::ObjectUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 985 free(raw_buf); | 986 free(raw_buf); |
| 986 } | 987 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1010 CreateMessagePipe(nullptr, &pipe0, &pipe1); | 1011 CreateMessagePipe(nullptr, &pipe0, &pipe1); |
| 1011 | 1012 |
| 1012 HandleUnionPtr handle(HandleUnion::New()); | 1013 HandleUnionPtr handle(HandleUnion::New()); |
| 1013 handle->set_f_message_pipe(pipe1.Pass()); | 1014 handle->set_f_message_pipe(pipe1.Pass()); |
| 1014 | 1015 |
| 1015 size_t size = GetSerializedSize_(handle, false); | 1016 size_t size = GetSerializedSize_(handle, false); |
| 1016 EXPECT_EQ(16U, size); | 1017 EXPECT_EQ(16U, size); |
| 1017 | 1018 |
| 1018 mojo::internal::FixedBufferForTesting buf(size); | 1019 mojo::internal::FixedBufferForTesting buf(size); |
| 1019 internal::HandleUnion_Data* data = nullptr; | 1020 internal::HandleUnion_Data* data = nullptr; |
| 1020 SerializeUnion_(handle.Pass(), &buf, &data, false); | 1021 SerializeUnion_(handle.get(), &buf, &data, false); |
| 1021 | 1022 |
| 1022 std::vector<Handle> handles; | 1023 std::vector<Handle> handles; |
| 1023 data->EncodePointersAndHandles(&handles); | 1024 data->EncodePointersAndHandles(&handles); |
| 1024 EXPECT_EQ(1U, handles.size()); | 1025 EXPECT_EQ(1U, handles.size()); |
| 1025 data->DecodePointersAndHandles(&handles); | 1026 data->DecodePointersAndHandles(&handles); |
| 1026 | 1027 |
| 1027 HandleUnionPtr handle2(HandleUnion::New()); | 1028 HandleUnionPtr handle2(HandleUnion::New()); |
| 1028 Deserialize_(data, &handle2); | 1029 Deserialize_(data, handle2.get()); |
| 1029 | 1030 |
| 1030 std::string golden("hello world"); | 1031 std::string golden("hello world"); |
| 1031 WriteTextMessage(pipe0.get(), golden); | 1032 WriteTextMessage(pipe0.get(), golden); |
| 1032 | 1033 |
| 1033 std::string actual; | 1034 std::string actual; |
| 1034 ReadTextMessage(handle2->get_f_message_pipe().get(), &actual); | 1035 ReadTextMessage(handle2->get_f_message_pipe().get(), &actual); |
| 1035 | 1036 |
| 1036 EXPECT_EQ(golden, actual); | 1037 EXPECT_EQ(golden, actual); |
| 1037 } | 1038 } |
| 1038 | 1039 |
| 1039 TEST(UnionTest, HandleInUnionValidation) { | 1040 TEST(UnionTest, HandleInUnionValidation) { |
| 1040 Environment environment; | 1041 Environment environment; |
| 1041 ScopedMessagePipeHandle pipe0; | 1042 ScopedMessagePipeHandle pipe0; |
| 1042 ScopedMessagePipeHandle pipe1; | 1043 ScopedMessagePipeHandle pipe1; |
| 1043 | 1044 |
| 1044 CreateMessagePipe(nullptr, &pipe0, &pipe1); | 1045 CreateMessagePipe(nullptr, &pipe0, &pipe1); |
| 1045 | 1046 |
| 1046 HandleUnionPtr handle(HandleUnion::New()); | 1047 HandleUnionPtr handle(HandleUnion::New()); |
| 1047 handle->set_f_message_pipe(pipe1.Pass()); | 1048 handle->set_f_message_pipe(pipe1.Pass()); |
| 1048 | 1049 |
| 1049 size_t size = GetSerializedSize_(handle, false); | 1050 size_t size = GetSerializedSize_(handle, false); |
| 1050 EXPECT_EQ(16U, size); | 1051 EXPECT_EQ(16U, size); |
| 1051 | 1052 |
| 1052 mojo::internal::FixedBufferForTesting buf(size); | 1053 mojo::internal::FixedBufferForTesting buf(size); |
| 1053 internal::HandleUnion_Data* data = nullptr; | 1054 internal::HandleUnion_Data* data = nullptr; |
| 1054 SerializeUnion_(handle.Pass(), &buf, &data, false); | 1055 SerializeUnion_(handle.get(), &buf, &data, false); |
| 1055 | 1056 |
| 1056 std::vector<Handle> handles; | 1057 std::vector<Handle> handles; |
| 1057 data->EncodePointersAndHandles(&handles); | 1058 data->EncodePointersAndHandles(&handles); |
| 1058 | 1059 |
| 1059 void* raw_buf = buf.Leak(); | 1060 void* raw_buf = buf.Leak(); |
| 1060 mojo::internal::BoundsChecker bounds_checker(data, | 1061 mojo::internal::BoundsChecker bounds_checker(data, |
| 1061 static_cast<uint32_t>(size), 1); | 1062 static_cast<uint32_t>(size), 1); |
| 1062 EXPECT_TRUE( | 1063 EXPECT_TRUE( |
| 1063 internal::HandleUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 1064 internal::HandleUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 1064 free(raw_buf); | 1065 free(raw_buf); |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 TEST(UnionTest, HandleInUnionValidationNull) { | 1068 TEST(UnionTest, HandleInUnionValidationNull) { |
| 1068 Environment environment; | 1069 Environment environment; |
| 1069 ScopedMessagePipeHandle pipe; | 1070 ScopedMessagePipeHandle pipe; |
| 1070 HandleUnionPtr handle(HandleUnion::New()); | 1071 HandleUnionPtr handle(HandleUnion::New()); |
| 1071 handle->set_f_message_pipe(pipe.Pass()); | 1072 handle->set_f_message_pipe(pipe.Pass()); |
| 1072 | 1073 |
| 1073 size_t size = GetSerializedSize_(handle, false); | 1074 size_t size = GetSerializedSize_(handle, false); |
| 1074 EXPECT_EQ(16U, size); | 1075 EXPECT_EQ(16U, size); |
| 1075 | 1076 |
| 1076 mojo::internal::FixedBufferForTesting buf(size); | 1077 mojo::internal::FixedBufferForTesting buf(size); |
| 1077 internal::HandleUnion_Data* data = nullptr; | 1078 internal::HandleUnion_Data* data = nullptr; |
| 1078 SerializeUnion_(handle.Pass(), &buf, &data, false); | 1079 SerializeUnion_(handle.get(), &buf, &data, false); |
| 1079 | 1080 |
| 1080 std::vector<Handle> handles; | 1081 std::vector<Handle> handles; |
| 1081 data->EncodePointersAndHandles(&handles); | 1082 data->EncodePointersAndHandles(&handles); |
| 1082 | 1083 |
| 1083 void* raw_buf = buf.Leak(); | 1084 void* raw_buf = buf.Leak(); |
| 1084 mojo::internal::BoundsChecker bounds_checker(data, | 1085 mojo::internal::BoundsChecker bounds_checker(data, |
| 1085 static_cast<uint32_t>(size), 1); | 1086 static_cast<uint32_t>(size), 1); |
| 1086 EXPECT_FALSE( | 1087 EXPECT_FALSE( |
| 1087 internal::HandleUnion_Data::Validate(raw_buf, &bounds_checker, false)); | 1088 internal::HandleUnion_Data::Validate(raw_buf, &bounds_checker, false)); |
| 1088 free(raw_buf); | 1089 free(raw_buf); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 SmallCachePtr ptr; | 1126 SmallCachePtr ptr; |
| 1126 Binding<SmallCache> bindings(&impl, GetProxy(&ptr)); | 1127 Binding<SmallCache> bindings(&impl, GetProxy(&ptr)); |
| 1127 | 1128 |
| 1128 HandleUnionPtr handle(HandleUnion::New()); | 1129 HandleUnionPtr handle(HandleUnion::New()); |
| 1129 handle->set_f_small_cache(ptr.Pass()); | 1130 handle->set_f_small_cache(ptr.Pass()); |
| 1130 size_t size = GetSerializedSize_(handle, false); | 1131 size_t size = GetSerializedSize_(handle, false); |
| 1131 EXPECT_EQ(16U, size); | 1132 EXPECT_EQ(16U, size); |
| 1132 | 1133 |
| 1133 mojo::internal::FixedBufferForTesting buf(size); | 1134 mojo::internal::FixedBufferForTesting buf(size); |
| 1134 internal::HandleUnion_Data* data = nullptr; | 1135 internal::HandleUnion_Data* data = nullptr; |
| 1135 SerializeUnion_(handle.Pass(), &buf, &data, false); | 1136 SerializeUnion_(handle.get(), &buf, &data, false); |
| 1136 | 1137 |
| 1137 std::vector<Handle> handles; | 1138 std::vector<Handle> handles; |
| 1138 data->EncodePointersAndHandles(&handles); | 1139 data->EncodePointersAndHandles(&handles); |
| 1139 EXPECT_EQ(1U, handles.size()); | 1140 EXPECT_EQ(1U, handles.size()); |
| 1140 data->DecodePointersAndHandles(&handles); | 1141 data->DecodePointersAndHandles(&handles); |
| 1141 | 1142 |
| 1142 HandleUnionPtr handle2(HandleUnion::New()); | 1143 HandleUnionPtr handle2(HandleUnion::New()); |
| 1143 Deserialize_(data, &handle2); | 1144 Deserialize_(data, handle2.get()); |
| 1144 | 1145 |
| 1145 handle2->get_f_small_cache()->SetIntValue(10); | 1146 handle2->get_f_small_cache()->SetIntValue(10); |
| 1146 run_loop.RunUntilIdle(); | 1147 run_loop.RunUntilIdle(); |
| 1147 EXPECT_EQ(10, impl.int_value()); | 1148 EXPECT_EQ(10, impl.int_value()); |
| 1148 } | 1149 } |
| 1149 | 1150 |
| 1150 class UnionInterfaceImpl : public UnionInterface { | 1151 class UnionInterfaceImpl : public UnionInterface { |
| 1151 public: | 1152 public: |
| 1152 UnionInterfaceImpl() {} | 1153 UnionInterfaceImpl() {} |
| 1153 ~UnionInterfaceImpl() override {} | 1154 ~UnionInterfaceImpl() override {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1168 PodUnionPtr pod(PodUnion::New()); | 1169 PodUnionPtr pod(PodUnion::New()); |
| 1169 pod->set_f_int16(16); | 1170 pod->set_f_int16(16); |
| 1170 | 1171 |
| 1171 ptr->Echo(pod.Pass(), | 1172 ptr->Echo(pod.Pass(), |
| 1172 [](PodUnionPtr out) { EXPECT_EQ(16, out->get_f_int16()); }); | 1173 [](PodUnionPtr out) { EXPECT_EQ(16, out->get_f_int16()); }); |
| 1173 run_loop.RunUntilIdle(); | 1174 run_loop.RunUntilIdle(); |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 } // namespace test | 1177 } // namespace test |
| 1177 } // namespace mojo | 1178 } // namespace mojo |
| OLD | NEW |