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

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 Array<base::Optional<std::string>> optional_test_array(3);
205 for (size_t i = 0; i < test_array.size(); ++i) 204 for (size_t i = 0; i < optional_test_array.size(); ++i)
206 test_array[i] = nullptr; 205 optional_test_array[i] = base::nullopt;
yzshen1 2017/01/04 00:05:35 They are nullopt by default, right?
Sam McNally 2017/01/04 00:28:25 Done.
207 ContainerValidateParams validate_params_1( 206 ContainerValidateParams validate_params_1(
208 0, false, new ContainerValidateParams(0, false, nullptr)); 207 0, false, new ContainerValidateParams(0, false, nullptr));
209 TestArrayWarning<MojomType>( 208 TestArrayWarning<MojomType>(
210 std::move(test_array), 209 std::move(optional_test_array),
211 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, 210 mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
212 &validate_params_1); 211 &validate_params_1);
213 212
214 test_array = Array<String>(2); 213 test_array = Array<std::string>(2);
215 ContainerValidateParams validate_params_2( 214 ContainerValidateParams validate_params_2(
216 3, true, new ContainerValidateParams(0, false, nullptr)); 215 3, true, new ContainerValidateParams(0, false, nullptr));
217 TestArrayWarning<MojomType>( 216 TestArrayWarning<MojomType>(
218 std::move(test_array), 217 std::move(test_array),
219 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER, 218 mojo::internal::VALIDATION_ERROR_UNEXPECTED_ARRAY_HEADER,
220 &validate_params_2); 219 &validate_params_2);
221 } 220 }
222 221
223 TEST_F(SerializationWarningTest, StructInUnion) { 222 TEST_F(SerializationWarningTest, StructInUnion) {
224 DummyStructPtr dummy(nullptr); 223 DummyStructPtr dummy(nullptr);
(...skipping 20 matching lines...) Expand all
245 244
246 TestUnionWarning(std::move(handle), 245 TestUnionWarning(std::move(handle),
247 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE); 246 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE);
248 } 247 }
249 248
250 } // namespace 249 } // namespace
251 } // namespace test 250 } // namespace test
252 } // namespace mojo 251 } // namespace mojo
253 252
254 #endif 253 #endif
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/binding_callback_unittest.cc ('k') | mojo/public/cpp/bindings/tests/string_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698