| 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 <utility> | 5 #include <utility> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/array.h" | 8 #include "mojo/public/cpp/bindings/array.h" |
| 9 #include "mojo/public/cpp/bindings/binding.h" | 9 #include "mojo/public/cpp/bindings/binding.h" |
| 10 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 10 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 656 |
| 657 // Serialize a null union and deserialize it back to check that we have a null | 657 // Serialize a null union and deserialize it back to check that we have a null |
| 658 // union. | 658 // union. |
| 659 TEST(UnionTest, Deserialize_NullableUnion) { | 659 TEST(UnionTest, Deserialize_NullableUnion) { |
| 660 char buf[1024]; | 660 char buf[1024]; |
| 661 SmallStructPtr small_struct = SmallStruct::New(); | 661 SmallStructPtr small_struct = SmallStruct::New(); |
| 662 small_struct->Serialize(buf, sizeof(buf)); | 662 small_struct->Serialize(buf, sizeof(buf)); |
| 663 EXPECT_TRUE(small_struct->pod_union.is_null()); | 663 EXPECT_TRUE(small_struct->pod_union.is_null()); |
| 664 | 664 |
| 665 SmallStructPtr deserialized_struct = SmallStruct::New(); | 665 SmallStructPtr deserialized_struct = SmallStruct::New(); |
| 666 deserialized_struct->Deserialize(buf); | 666 EXPECT_TRUE(deserialized_struct->Deserialize(buf, sizeof(buf))); |
| 667 | |
| 668 EXPECT_TRUE(deserialized_struct->pod_union.is_null()); | 667 EXPECT_TRUE(deserialized_struct->pod_union.is_null()); |
| 669 } | 668 } |
| 670 | 669 |
| 671 // Validation passes with nullable null union containing non-nullable objects. | 670 // Validation passes with nullable null union containing non-nullable objects. |
| 672 TEST(UnionTest, Validation_NullableObjectUnion) { | 671 TEST(UnionTest, Validation_NullableObjectUnion) { |
| 673 Environment environment; | 672 Environment environment; |
| 674 StructNullObjectUnionPtr small_struct(StructNullObjectUnion::New()); | 673 StructNullObjectUnionPtr small_struct(StructNullObjectUnion::New()); |
| 675 | 674 |
| 676 size_t size = GetSerializedSize_(*small_struct); | 675 size_t size = GetSerializedSize_(*small_struct); |
| 677 | 676 |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 PodUnionPtr pod(PodUnion::New()); | 1286 PodUnionPtr pod(PodUnion::New()); |
| 1288 pod->set_f_int16(16); | 1287 pod->set_f_int16(16); |
| 1289 | 1288 |
| 1290 ptr->Echo(pod.Pass(), | 1289 ptr->Echo(pod.Pass(), |
| 1291 [](PodUnionPtr out) { EXPECT_EQ(16, out->get_f_int16()); }); | 1290 [](PodUnionPtr out) { EXPECT_EQ(16, out->get_f_int16()); }); |
| 1292 run_loop.RunUntilIdle(); | 1291 run_loop.RunUntilIdle(); |
| 1293 } | 1292 } |
| 1294 | 1293 |
| 1295 } // namespace test | 1294 } // namespace test |
| 1296 } // namespace mojo | 1295 } // namespace mojo |
| OLD | NEW |