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