| 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 // Serialization warnings are only recorded in debug build. | 5 // Serialization warnings are only recorded in debug build. |
| 6 #ifndef NDEBUG | 6 #ifndef NDEBUG |
| 7 | 7 |
| 8 #include "mojo/public/cpp/bindings/array.h" | 8 #include "mojo/public/cpp/bindings/array.h" |
| 9 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 9 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
| 10 #include "mojo/public/cpp/bindings/lib/array_serialization.h" | 10 #include "mojo/public/cpp/bindings/lib/array_serialization.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/validation_errors.h" | 12 #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| 13 #include "mojo/public/cpp/bindings/string.h" | 13 #include "mojo/public/cpp/bindings/string.h" |
| 14 #include "mojo/public/cpp/environment/environment.h" | |
| 15 #include "mojo/public/cpp/system/message_pipe.h" | 14 #include "mojo/public/cpp/system/message_pipe.h" |
| 16 #include "mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom
.h" | 15 #include "mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom
.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 17 |
| 19 namespace mojo { | 18 namespace mojo { |
| 20 namespace test { | 19 namespace test { |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 using mojo::internal::ArrayValidateParams; | 22 using mojo::internal::ArrayValidateParams; |
| 24 | 23 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 63 |
| 65 template <typename T> | 64 template <typename T> |
| 66 void TestArrayWarning(T obj, | 65 void TestArrayWarning(T obj, |
| 67 mojo::internal::ValidationError expected_warning, | 66 mojo::internal::ValidationError expected_warning, |
| 68 const ArrayValidateParams* validate_params) { | 67 const ArrayValidateParams* validate_params) { |
| 69 mojo::internal::FixedBufferForTesting buf(GetSerializedSize_(obj)); | 68 mojo::internal::FixedBufferForTesting buf(GetSerializedSize_(obj)); |
| 70 typename T::Data_* data; | 69 typename T::Data_* data; |
| 71 EXPECT_EQ(expected_warning, | 70 EXPECT_EQ(expected_warning, |
| 72 SerializeArray_(&obj, &buf, &data, validate_params)); | 71 SerializeArray_(&obj, &buf, &data, validate_params)); |
| 73 } | 72 } |
| 74 | |
| 75 Environment env_; | |
| 76 }; | 73 }; |
| 77 | 74 |
| 78 TEST_F(SerializationWarningTest, HandleInStruct) { | 75 TEST_F(SerializationWarningTest, HandleInStruct) { |
| 79 Struct2Ptr test_struct(Struct2::New()); | 76 Struct2Ptr test_struct(Struct2::New()); |
| 80 EXPECT_FALSE(test_struct->hdl.is_valid()); | 77 EXPECT_FALSE(test_struct->hdl.is_valid()); |
| 81 | 78 |
| 82 TestWarning(test_struct.Pass(), | 79 TestWarning(test_struct.Pass(), |
| 83 mojo::internal::ValidationError::UNEXPECTED_INVALID_HANDLE); | 80 mojo::internal::ValidationError::UNEXPECTED_INVALID_HANDLE); |
| 84 | 81 |
| 85 test_struct = Struct2::New(); | 82 test_struct = Struct2::New(); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 TestArrayWarning(test_array.Pass(), | 209 TestArrayWarning(test_array.Pass(), |
| 213 mojo::internal::ValidationError::UNEXPECTED_ARRAY_HEADER, | 210 mojo::internal::ValidationError::UNEXPECTED_ARRAY_HEADER, |
| 214 &validate_params_2); | 211 &validate_params_2); |
| 215 } | 212 } |
| 216 | 213 |
| 217 } // namespace | 214 } // namespace |
| 218 } // namespace test | 215 } // namespace test |
| 219 } // namespace mojo | 216 } // namespace mojo |
| 220 | 217 |
| 221 #endif | 218 #endif |
| OLD | NEW |