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 when DLOG is enabled. | 5 // Serialization warnings are only recorded when DLOG is enabled. |
6 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 6 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | 112 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); |
113 | 113 |
114 test_struct = Struct3::New(); | 114 test_struct = Struct3::New(); |
115 test_struct->struct_1 = Struct1::New(); | 115 test_struct->struct_1 = Struct1::New(); |
116 | 116 |
117 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); | 117 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); |
118 } | 118 } |
119 | 119 |
120 TEST_F(SerializationWarningTest, ArrayOfStructsInStruct) { | 120 TEST_F(SerializationWarningTest, ArrayOfStructsInStruct) { |
121 Struct4Ptr test_struct(Struct4::New()); | 121 Struct4Ptr test_struct(Struct4::New()); |
122 EXPECT_TRUE(!test_struct->data); | |
123 | |
124 TestWarning(std::move(test_struct), | |
125 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | |
126 | |
127 test_struct = Struct4::New(); | |
128 test_struct->data.resize(1); | 122 test_struct->data.resize(1); |
129 | 123 |
130 TestWarning(std::move(test_struct), | 124 TestWarning(std::move(test_struct), |
131 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | 125 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); |
132 | 126 |
133 test_struct = Struct4::New(); | 127 test_struct = Struct4::New(); |
134 test_struct->data.resize(0); | 128 test_struct->data.resize(0); |
135 | 129 |
136 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); | 130 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); |
137 | 131 |
138 test_struct = Struct4::New(); | 132 test_struct = Struct4::New(); |
139 test_struct->data.resize(1); | 133 test_struct->data.resize(1); |
140 test_struct->data[0] = Struct1::New(); | 134 test_struct->data[0] = Struct1::New(); |
141 | 135 |
142 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); | 136 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); |
143 } | 137 } |
144 | 138 |
145 TEST_F(SerializationWarningTest, FixedArrayOfStructsInStruct) { | 139 TEST_F(SerializationWarningTest, FixedArrayOfStructsInStruct) { |
146 Struct5Ptr test_struct(Struct5::New()); | 140 Struct5Ptr test_struct(Struct5::New()); |
147 EXPECT_TRUE(!test_struct->pair); | |
148 | |
149 TestWarning(std::move(test_struct), | |
150 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | |
151 | |
152 test_struct = Struct5::New(); | |
153 test_struct->pair.resize(1); | 141 test_struct->pair.resize(1); |
154 test_struct->pair[0] = Struct1::New(); | 142 test_struct->pair[0] = Struct1::New(); |
155 | 143 |
156 TestWarning(std::move(test_struct), | 144 TestWarning(std::move(test_struct), |
157 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER); | 145 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER); |
158 | 146 |
159 test_struct = Struct5::New(); | 147 test_struct = Struct5::New(); |
160 test_struct->pair.resize(2); | 148 test_struct->pair.resize(2); |
161 test_struct->pair[0] = Struct1::New(); | 149 test_struct->pair[0] = Struct1::New(); |
162 test_struct->pair[1] = Struct1::New(); | 150 test_struct->pair[1] = Struct1::New(); |
163 | 151 |
164 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); | 152 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); |
165 } | 153 } |
166 | 154 |
167 TEST_F(SerializationWarningTest, StringInStruct) { | |
168 Struct6Ptr test_struct(Struct6::New()); | |
169 EXPECT_TRUE(!test_struct->str); | |
170 | |
171 TestWarning(std::move(test_struct), | |
172 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER); | |
173 | |
174 test_struct = Struct6::New(); | |
175 test_struct->str = "hello world"; | |
176 | |
177 TestWarning(std::move(test_struct), mojo::internal::VALIDATION_ERROR_NONE); | |
178 } | |
179 | |
180 TEST_F(SerializationWarningTest, ArrayOfArraysOfHandles) { | 155 TEST_F(SerializationWarningTest, ArrayOfArraysOfHandles) { |
181 Array<Array<ScopedHandle>> test_array = CreateTestNestedHandleArray(); | 156 Array<Array<ScopedHandle>> test_array = CreateTestNestedHandleArray(); |
182 test_array[0] = nullptr; | 157 test_array[0] = nullptr; |
183 test_array[1][0] = ScopedHandle(); | 158 test_array[1][0] = ScopedHandle(); |
184 | 159 |
185 ContainerValidateParams validate_params_0( | 160 ContainerValidateParams validate_params_0( |
186 0, true, new ContainerValidateParams(0, true, nullptr)); | 161 0, true, new ContainerValidateParams(0, true, nullptr)); |
187 TestArrayWarning(std::move(test_array), mojo::internal::VALIDATION_ERROR_NONE, | 162 TestArrayWarning(std::move(test_array), mojo::internal::VALIDATION_ERROR_NONE, |
188 &validate_params_0); | 163 &validate_params_0); |
189 | 164 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 231 |
257 TestUnionWarning(std::move(handle), | 232 TestUnionWarning(std::move(handle), |
258 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); | 233 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); |
259 } | 234 } |
260 | 235 |
261 } // namespace | 236 } // namespace |
262 } // namespace test | 237 } // namespace test |
263 } // namespace mojo | 238 } // namespace mojo |
264 | 239 |
265 #endif | 240 #endif |
OLD | NEW |