OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/validation_errors.h" | 7 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
8 #include "mojo/public/cpp/system/message_pipe.h" | 8 #include "mojo/public/cpp/system/message_pipe.h" |
9 #include "mojo/public/interfaces/bindings/tests/rect.mojom.h" | 9 #include "mojo/public/interfaces/bindings/tests/rect.mojom.h" |
10 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" | 10 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 EXPECT_EQ(expected_validation_error, actual_validation_error); | 40 EXPECT_EQ(expected_validation_error, actual_validation_error); |
41 | 41 |
42 Type out_val; | 42 Type out_val; |
43 bool deserialize_ret = out_val.Deserialize(bytes.data(), bytes.size()); | 43 bool deserialize_ret = out_val.Deserialize(bytes.data(), bytes.size()); |
44 if (actual_validation_error == mojo::internal::ValidationError::NONE) { | 44 if (actual_validation_error == mojo::internal::ValidationError::NONE) { |
45 EXPECT_TRUE(val->Equals(out_val)); | 45 EXPECT_TRUE(val->Equals(out_val)); |
46 } | 46 } |
47 EXPECT_EQ(actual_validation_error == mojo::internal::ValidationError::NONE, | 47 EXPECT_EQ(actual_validation_error == mojo::internal::ValidationError::NONE, |
48 deserialize_ret); | 48 deserialize_ret); |
49 } | 49 } |
50 | |
51 private: | |
52 Environment env_; | |
53 }; | 50 }; |
54 | 51 |
55 TEST_F(StructSerializationAPITest, GetSerializedSize) { | 52 TEST_F(StructSerializationAPITest, GetSerializedSize) { |
56 Rect rect; | 53 Rect rect; |
57 // 8 byte struct header | 54 // 8 byte struct header |
58 // + 16 bytes worth of fields | 55 // + 16 bytes worth of fields |
59 EXPECT_EQ(24u, rect.GetSerializedSize()); | 56 EXPECT_EQ(24u, rect.GetSerializedSize()); |
60 | 57 |
61 HandleStruct handle_struct; | 58 HandleStruct handle_struct; |
62 // 8 byte struct header | 59 // 8 byte struct header |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // don't Validate. | 196 // don't Validate. |
200 co_data->header_.num_bytes = 0u; | 197 co_data->header_.num_bytes = 0u; |
201 co.DeserializeWithoutValidation(buf); | 198 co.DeserializeWithoutValidation(buf); |
202 EXPECT_EQ(kMagic, co_data->other); | 199 EXPECT_EQ(kMagic, co_data->other); |
203 EXPECT_EQ(0u, co_data->header_.num_bytes); | 200 EXPECT_EQ(0u, co_data->header_.num_bytes); |
204 } | 201 } |
205 | 202 |
206 } // namespace | 203 } // namespace |
207 } // namespace test | 204 } // namespace test |
208 } // namespace mojo | 205 } // namespace mojo |
OLD | NEW |