| OLD | NEW |
| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); | 287 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); |
| 288 | 288 |
| 289 input = base::MakeUnique<base::Value>(false); | 289 input = base::MakeUnique<base::Value>(false); |
| 290 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); | 290 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); |
| 291 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); | 291 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); |
| 292 | 292 |
| 293 input = base::MakeUnique<base::Value>("test string"); | 293 input = base::MakeUnique<base::Value>("test string"); |
| 294 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); | 294 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); |
| 295 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); | 295 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); |
| 296 | 296 |
| 297 input = base::BinaryValue::CreateWithCopiedBuffer("mojo", 4); | 297 input = base::Value::CreateWithCopiedBuffer("mojo", 4); |
| 298 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); | 298 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); |
| 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", base::Value::CreateWithCopiedBuffer("mojo", 4)); |
| 308 base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); | |
| 309 dict->Set("null_value", base::MakeUnique<base::Value>()); | 308 dict->Set("null_value", base::MakeUnique<base::Value>()); |
| 310 dict->SetIntegerWithoutPathExpansion("non_nested.int", 10); | 309 dict->SetIntegerWithoutPathExpansion("non_nested.int", 10); |
| 311 { | 310 { |
| 312 std::unique_ptr<base::ListValue> dict_list(new base::ListValue()); | 311 std::unique_ptr<base::ListValue> dict_list(new base::ListValue()); |
| 313 dict_list->AppendString("string"); | 312 dict_list->AppendString("string"); |
| 314 dict_list->AppendBoolean(true); | 313 dict_list->AppendBoolean(true); |
| 315 dict->Set("list", std::move(dict_list)); | 314 dict->Set("list", std::move(dict_list)); |
| 316 } | 315 } |
| 317 | 316 |
| 318 std::unique_ptr<base::DictionaryValue> dict_output; | 317 std::unique_ptr<base::DictionaryValue> dict_output; |
| 319 ASSERT_TRUE(ptr->BounceDictionaryValue(dict->CreateDeepCopy(), &dict_output)); | 318 ASSERT_TRUE(ptr->BounceDictionaryValue(dict->CreateDeepCopy(), &dict_output)); |
| 320 EXPECT_TRUE(base::Value::Equals(dict.get(), dict_output.get())); | 319 EXPECT_TRUE(base::Value::Equals(dict.get(), dict_output.get())); |
| 321 | 320 |
| 322 input = std::move(dict); | 321 input = std::move(dict); |
| 323 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); | 322 ASSERT_TRUE(ptr->BounceValue(input->CreateDeepCopy(), &output)); |
| 324 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); | 323 EXPECT_TRUE(base::Value::Equals(input.get(), output.get())); |
| 325 | 324 |
| 326 auto list = base::MakeUnique<base::ListValue>(); | 325 auto list = base::MakeUnique<base::ListValue>(); |
| 327 list->AppendString("string"); | 326 list->AppendString("string"); |
| 328 list->AppendDouble(42.1); | 327 list->AppendDouble(42.1); |
| 329 list->AppendBoolean(true); | 328 list->AppendBoolean(true); |
| 330 list->Append(base::BinaryValue::CreateWithCopiedBuffer("mojo", 4)); | 329 list->Append(base::Value::CreateWithCopiedBuffer("mojo", 4)); |
| 331 list->Append(base::MakeUnique<base::Value>()); | 330 list->Append(base::MakeUnique<base::Value>()); |
| 332 { | 331 { |
| 333 std::unique_ptr<base::DictionaryValue> list_dict( | 332 std::unique_ptr<base::DictionaryValue> list_dict( |
| 334 new base::DictionaryValue()); | 333 new base::DictionaryValue()); |
| 335 list_dict->SetString("string", "str"); | 334 list_dict->SetString("string", "str"); |
| 336 list->Append(std::move(list_dict)); | 335 list->Append(std::move(list_dict)); |
| 337 } | 336 } |
| 338 std::unique_ptr<base::ListValue> list_output; | 337 std::unique_ptr<base::ListValue> list_output; |
| 339 ASSERT_TRUE(ptr->BounceListValue(list->CreateDeepCopy(), &list_output)); | 338 ASSERT_TRUE(ptr->BounceListValue(list->CreateDeepCopy(), &list_output)); |
| 340 EXPECT_TRUE(base::Value::Equals(list.get(), list_output.get())); | 339 EXPECT_TRUE(base::Value::Equals(list.get(), list_output.get())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 for (size_t i = 0; i < arraysize(kTestDirections); i++) { | 423 for (size_t i = 0; i < arraysize(kTestDirections); i++) { |
| 425 base::i18n::TextDirection direction_out; | 424 base::i18n::TextDirection direction_out; |
| 426 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out)); | 425 ASSERT_TRUE(ptr->BounceTextDirection(kTestDirections[i], &direction_out)); |
| 427 EXPECT_EQ(kTestDirections[i], direction_out); | 426 EXPECT_EQ(kTestDirections[i], direction_out); |
| 428 } | 427 } |
| 429 } | 428 } |
| 430 | 429 |
| 431 } // namespace test | 430 } // namespace test |
| 432 } // namespace common | 431 } // namespace common |
| 433 } // namespace mojo | 432 } // namespace mojo |
| OLD | NEW |