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

Side by Side Diff: mojo/common/common_custom_types_unittest.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « media/base/video_frame_unittest.cc ('k') | mojo/common/values_struct_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/numerics/safe_math.h" 9 #include "base/numerics/safe_math.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 TEST_F(CommonCustomTypesTest, Value) { 268 TEST_F(CommonCustomTypesTest, Value) {
269 TestValuePtr ptr; 269 TestValuePtr ptr;
270 TestValueImpl impl(MakeRequest(&ptr)); 270 TestValueImpl impl(MakeRequest(&ptr));
271 271
272 std::unique_ptr<base::Value> output; 272 std::unique_ptr<base::Value> output;
273 273
274 ASSERT_TRUE(ptr->BounceValue(nullptr, &output)); 274 ASSERT_TRUE(ptr->BounceValue(nullptr, &output));
275 EXPECT_FALSE(output); 275 EXPECT_FALSE(output);
276 276
277 std::unique_ptr<base::Value> input = base::Value::CreateNullValue(); 277 auto input = base::MakeUnique<base::Value>();
278 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); 278 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
279 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); 279 EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
280 280
281 input = base::MakeUnique<base::Value>(123); 281 input = base::MakeUnique<base::Value>(123);
282 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); 282 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
283 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); 283 EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
284 284
285 input = base::MakeUnique<base::Value>(1.23); 285 input = base::MakeUnique<base::Value>(1.23);
286 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); 286 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
287 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); 287 EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
(...skipping 11 matching lines...) Expand all
299 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); 299 EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
300 300
301 auto dict = base::MakeUnique<base::DictionaryValue>(); 301 auto dict = base::MakeUnique<base::DictionaryValue>();
302 dict->SetBoolean("bool", false); 302 dict->SetBoolean("bool", false);
303 dict->SetInteger("int", 2); 303 dict->SetInteger("int", 2);
304 dict->SetString("string", "some string"); 304 dict->SetString("string", "some string");
305 dict->SetBoolean("nested.bool", true); 305 dict->SetBoolean("nested.bool", true);
306 dict->SetInteger("nested.int", 9); 306 dict->SetInteger("nested.int", 9);
307 dict->Set("some_binary", 307 dict->Set("some_binary",
308 base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); 308 base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
309 dict->Set("null_value", base::Value::CreateNullValue()); 309 dict->Set("null_value", base::MakeUnique<base::Value>());
310 dict->SetIntegerWithoutPathExpansion("non_nested.int", 10); 310 dict->SetIntegerWithoutPathExpansion("non_nested.int", 10);
311 { 311 {
312 std::unique_ptr<base::ListValue> dict_list(new base::ListValue()); 312 std::unique_ptr<base::ListValue> dict_list(new base::ListValue());
313 dict_list->AppendString("string"); 313 dict_list->AppendString("string");
314 dict_list->AppendBoolean(true); 314 dict_list->AppendBoolean(true);
315 dict->Set("list", std::move(dict_list)); 315 dict->Set("list", std::move(dict_list));
316 } 316 }
317 317
318 std::unique_ptr<base::DictionaryValue> dict_output; 318 std::unique_ptr<base::DictionaryValue> dict_output;
319 ASSERT_TRUE(ptr->BounceDictionaryValue(dict->CreateDeepCopy(), &dict_output)); 319 ASSERT_TRUE(ptr->BounceDictionaryValue(dict->CreateDeepCopy(), &dict_output));
320 EXPECT_TRUE(base::Value::Equals(dict.get(), dict_output.get())); 320 EXPECT_TRUE(base::Value::Equals(dict.get(), dict_output.get()));
321 321
322 input = std::move(dict); 322 input = std::move(dict);
323 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); 323 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output));
324 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); 324 EXPECT_TRUE(base::Value::Equals(input.get(), output.get()));
325 325
326 auto list = base::MakeUnique<base::ListValue>(); 326 auto list = base::MakeUnique<base::ListValue>();
327 list->AppendString("string"); 327 list->AppendString("string");
328 list->AppendDouble(42.1); 328 list->AppendDouble(42.1);
329 list->AppendBoolean(true); 329 list->AppendBoolean(true);
330 list->Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); 330 list->Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4));
331 list->Append(base::Value::CreateNullValue()); 331 list->Append(base::MakeUnique<base::Value>());
332 { 332 {
333 std::unique_ptr<base::DictionaryValue> list_dict( 333 std::unique_ptr<base::DictionaryValue> list_dict(
334 new base::DictionaryValue()); 334 new base::DictionaryValue());
335 list_dict->SetString("string", "str"); 335 list_dict->SetString("string", "str");
336 list->Append(std::move(list_dict)); 336 list->Append(std::move(list_dict));
337 } 337 }
338 std::unique_ptr<base::ListValue> list_output; 338 std::unique_ptr<base::ListValue> list_output;
339 ASSERT_TRUE(ptr->BounceListValue(list->CreateDeepCopy(), &list_output)); 339 ASSERT_TRUE(ptr->BounceListValue(list->CreateDeepCopy(), &list_output));
340 EXPECT_TRUE(base::Value::Equals(list.get(), list_output.get())); 340 EXPECT_TRUE(base::Value::Equals(list.get(), list_output.get()));
341 341
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 for (size_t i = 0; i < arraysize(kTestDirections); i++) { 424 for (size_t i = 0; i < arraysize(kTestDirections); i++) {
425 base::i18n::TextDirection direction_out; 425 base::i18n::TextDirection direction_out;
426 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out)); 426 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out));
427 EXPECT_EQ(kTestDirections[i], direction_out); 427 EXPECT_EQ(kTestDirections[i], direction_out);
428 } 428 }
429 } 429 }
430 430
431 } // namespace test 431 } // namespace test
432 } // namespace common 432 } // namespace common
433 } // namespace mojo 433 } // namespace mojo
OLDNEW
« no previous file with comments | « media/base/video_frame_unittest.cc ('k') | mojo/common/values_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698