Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: mojo/public/cpp/bindings/tests/serialization_warning_unittest.cc

Issue 2608513002: Remove mojo::String. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "mojo/public/cpp/bindings/array.h" 11 #include "mojo/public/cpp/bindings/array.h"
12 #include "mojo/public/cpp/bindings/lib/array_internal.h" 12 #include "mojo/public/cpp/bindings/lib/array_internal.h"
13 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" 13 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
14 #include "mojo/public/cpp/bindings/lib/serialization.h" 14 #include "mojo/public/cpp/bindings/lib/serialization.h"
15 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 15 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
16 #include "mojo/public/cpp/bindings/string.h"
17 #include "mojo/public/cpp/system/message_pipe.h" 16 #include "mojo/public/cpp/system/message_pipe.h"
18 #include "mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom .h" 17 #include "mojo/public/interfaces/bindings/tests/serialization_test_structs.mojom .h"
19 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom.h" 18 #include "mojo/public/interfaces/bindings/tests/test_unions.mojom.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 namespace mojo { 21 namespace mojo {
23 namespace test { 22 namespace test {
24 namespace { 23 namespace {
25 24
26 using mojo::internal::ContainerValidateParams; 25 using mojo::internal::ContainerValidateParams;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 0, true, new ContainerValidateParams(0, false, nullptr)); 183 0, true, new ContainerValidateParams(0, false, nullptr));
185 TestArrayWarning<MojomType>( 184 TestArrayWarning<MojomType>(
186 std::move(test_array), 185 std::move(test_array),
187 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, 186 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE,
188 &validate_params_2); 187 &validate_params_2);
189 } 188 }
190 189
191 TEST_F(SerializationWarningTest, ArrayOfStrings) { 190 TEST_F(SerializationWarningTest, ArrayOfStrings) {
192 using MojomType = ArrayDataView<StringDataView>; 191 using MojomType = ArrayDataView<StringDataView>;
193 192
194 Array<String> test_array(3); 193 Array<std::string> test_array(3);
195 for (size_t i = 0; i < test_array.size(); ++i) 194 for (size_t i = 0; i < test_array.size(); ++i)
196 test_array[i] = "hello"; 195 test_array[i] = "hello";
197 196
198 ContainerValidateParams validate_params_0( 197 ContainerValidateParams validate_params_0(
199 0, true, new ContainerValidateParams(0, false, nullptr)); 198 0, true, new ContainerValidateParams(0, false, nullptr));
200 TestArrayWarning<MojomType>(std::move(test_array), 199 TestArrayWarning<MojomType>(std::move(test_array),
201 mojo::internal::VALIDATION_ERROR_NONE, 200 mojo::internal::VALIDATION_ERROR_NONE,
202 &validate_params_0); 201 &validate_params_0);
203 202
204 test_array = Array<String>(3); 203 test_array = Array<std::string>(2);
yzshen1 2017/01/03 21:44:41 Please consider keeping this test case, using Arra
Sam McNally 2017/01/03 23:44:28 Done.
205 for (size_t i = 0; i < test_array.size(); ++i)
206 test_array[i] = nullptr;
207 ContainerValidateParams validate_params_1(
208 0, false, new ContainerValidateParams(0, false, nullptr));
209 TestArrayWarning<MojomType>(
210 std::move(test_array),
211 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
212 &validate_params_1);
213
214 test_array = Array<String>(2);
215 ContainerValidateParams validate_params_2( 204 ContainerValidateParams validate_params_2(
216 3, true, new ContainerValidateParams(0, false, nullptr)); 205 3, true, new ContainerValidateParams(0, false, nullptr));
217 TestArrayWarning<MojomType>( 206 TestArrayWarning<MojomType>(
218 std::move(test_array), 207 std::move(test_array),
219 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER, 208 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER,
220 &validate_params_2); 209 &validate_params_2);
221 } 210 }
222 211
223 TEST_F(SerializationWarningTest, StructInUnion) { 212 TEST_F(SerializationWarningTest, StructInUnion) {
224 DummyStructPtr dummy(nullptr); 213 DummyStructPtr dummy(nullptr);
(...skipping 20 matching lines...) Expand all
245 234
246 TestUnionWarning(std::move(handle), 235 TestUnionWarning(std::move(handle),
247 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); 236 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE);
248 } 237 }
249 238
250 } // namespace 239 } // namespace
251 } // namespace test 240 } // namespace test
252 } // namespace mojo 241 } // namespace mojo
253 242
254 #endif 243 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698