| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/base/device_capabilities_impl.h" | 5 #include "chromecast/base/device_capabilities_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver); | 146 DISALLOW_COPY_AND_ASSIGN(MockCapabilitiesObserver); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // Test fixtures needs an example default capability to test DeviceCapabilities | 149 // Test fixtures needs an example default capability to test DeviceCapabilities |
| 150 // methods. Gets a sample key and initial value. | 150 // methods. Gets a sample key and initial value. |
| 151 void GetSampleDefaultCapability(std::string* key, | 151 void GetSampleDefaultCapability(std::string* key, |
| 152 std::unique_ptr<base::Value>* init_value) { | 152 std::unique_ptr<base::Value>* init_value) { |
| 153 DCHECK(key); | 153 DCHECK(key); |
| 154 DCHECK(init_value); | 154 DCHECK(init_value); |
| 155 *key = DeviceCapabilities::kKeyBluetoothSupported; | 155 *key = DeviceCapabilities::kKeyBluetoothSupported; |
| 156 *init_value = base::MakeUnique<base::FundamentalValue>(true); | 156 *init_value = base::MakeUnique<base::Value>(true); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // For test fixtures that test dynamic capabilities, gets a sample key | 159 // For test fixtures that test dynamic capabilities, gets a sample key |
| 160 // and initial value. | 160 // and initial value. |
| 161 void GetSampleDynamicCapability(std::string* key, | 161 void GetSampleDynamicCapability(std::string* key, |
| 162 std::unique_ptr<base::Value>* init_value) { | 162 std::unique_ptr<base::Value>* init_value) { |
| 163 DCHECK(key); | 163 DCHECK(key); |
| 164 DCHECK(init_value); | 164 DCHECK(init_value); |
| 165 *key = "dummy_dynamic_key"; | 165 *key = "dummy_dynamic_key"; |
| 166 *init_value = base::MakeUnique<base::FundamentalValue>(99); | 166 *init_value = base::MakeUnique<base::Value>(99); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Gets a value for sample default capability different from |init_value| | 169 // Gets a value for sample default capability different from |init_value| |
| 170 // returned in GetSampleDefaultCapability(). Must be of same type as | 170 // returned in GetSampleDefaultCapability(). Must be of same type as |
| 171 // |init_value| of course. | 171 // |init_value| of course. |
| 172 std::unique_ptr<base::Value> GetSampleDefaultCapabilityNewValue() { | 172 std::unique_ptr<base::Value> GetSampleDefaultCapabilityNewValue() { |
| 173 return base::MakeUnique<base::FundamentalValue>(false); | 173 return base::MakeUnique<base::Value>(false); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Gets a value for sample dynamic capability different from |init_value| | 176 // Gets a value for sample dynamic capability different from |init_value| |
| 177 // returned in GetSampleDynamicCapability(). Must be of same type as | 177 // returned in GetSampleDynamicCapability(). Must be of same type as |
| 178 // |init_value| of course. | 178 // |init_value| of course. |
| 179 std::unique_ptr<base::Value> GetSampleDynamicCapabilityNewValue() { | 179 std::unique_ptr<base::Value> GetSampleDynamicCapabilityNewValue() { |
| 180 return base::MakeUnique<base::FundamentalValue>(100); | 180 return base::MakeUnique<base::Value>(100); |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Tests that |json| string matches contents of a DictionaryValue with one entry | 183 // Tests that |json| string matches contents of a DictionaryValue with one entry |
| 184 // specified by |key| and |value|. | 184 // specified by |key| and |value|. |
| 185 bool JsonStringEquals(const std::string& json, | 185 bool JsonStringEquals(const std::string& json, |
| 186 const std::string& key, | 186 const std::string& key, |
| 187 const base::Value& value) { | 187 const base::Value& value) { |
| 188 base::DictionaryValue dict_value; | 188 base::DictionaryValue dict_value; |
| 189 dict_value.Set(key, value.CreateDeepCopy()); | 189 dict_value.Set(key, value.CreateDeepCopy()); |
| 190 std::unique_ptr<const std::string> dict_json(SerializeToJson(dict_value)); | 190 std::unique_ptr<const std::string> dict_json(SerializeToJson(dict_value)); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 331 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
| 332 base::RunLoop().RunUntilIdle(); | 332 base::RunLoop().RunUntilIdle(); |
| 333 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), | 333 EXPECT_TRUE(base::Value::Equals(capabilities()->GetCapability(key).get(), |
| 334 new_value.get())); | 334 new_value.get())); |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Tests BluetoothSupported() and updating this value through SetCapability(). | 337 // Tests BluetoothSupported() and updating this value through SetCapability(). |
| 338 TEST_F(DeviceCapabilitiesImplTest, BluetoothSupportedAndSetCapability) { | 338 TEST_F(DeviceCapabilitiesImplTest, BluetoothSupportedAndSetCapability) { |
| 339 FakeCapabilityManagerSimple manager( | 339 FakeCapabilityManagerSimple manager( |
| 340 capabilities(), DeviceCapabilities::kKeyBluetoothSupported, | 340 capabilities(), DeviceCapabilities::kKeyBluetoothSupported, |
| 341 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 341 base::WrapUnique(new base::Value(true)), true, false); |
| 342 | 342 |
| 343 EXPECT_TRUE(capabilities()->BluetoothSupported()); | 343 EXPECT_TRUE(capabilities()->BluetoothSupported()); |
| 344 capabilities()->SetCapability( | 344 capabilities()->SetCapability(DeviceCapabilities::kKeyBluetoothSupported, |
| 345 DeviceCapabilities::kKeyBluetoothSupported, | 345 base::WrapUnique(new base::Value(false))); |
| 346 base::WrapUnique(new base::FundamentalValue(false))); | |
| 347 base::RunLoop().RunUntilIdle(); | 346 base::RunLoop().RunUntilIdle(); |
| 348 EXPECT_FALSE(capabilities()->BluetoothSupported()); | 347 EXPECT_FALSE(capabilities()->BluetoothSupported()); |
| 349 } | 348 } |
| 350 | 349 |
| 351 // Tests DisplaySupported() and updating this value through SetCapability(). | 350 // Tests DisplaySupported() and updating this value through SetCapability(). |
| 352 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { | 351 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { |
| 353 FakeCapabilityManagerSimple manager( | 352 FakeCapabilityManagerSimple manager( |
| 354 capabilities(), DeviceCapabilities::kKeyDisplaySupported, | 353 capabilities(), DeviceCapabilities::kKeyDisplaySupported, |
| 355 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 354 base::WrapUnique(new base::Value(true)), true, false); |
| 356 | 355 |
| 357 EXPECT_TRUE(capabilities()->DisplaySupported()); | 356 EXPECT_TRUE(capabilities()->DisplaySupported()); |
| 358 capabilities()->SetCapability( | 357 capabilities()->SetCapability(DeviceCapabilities::kKeyDisplaySupported, |
| 359 DeviceCapabilities::kKeyDisplaySupported, | 358 base::WrapUnique(new base::Value(false))); |
| 360 base::WrapUnique(new base::FundamentalValue(false))); | |
| 361 base::RunLoop().RunUntilIdle(); | 359 base::RunLoop().RunUntilIdle(); |
| 362 EXPECT_FALSE(capabilities()->DisplaySupported()); | 360 EXPECT_FALSE(capabilities()->DisplaySupported()); |
| 363 } | 361 } |
| 364 | 362 |
| 365 // Tests HiResAudioSupported() and updating this value through SetCapability() | 363 // Tests HiResAudioSupported() and updating this value through SetCapability() |
| 366 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { | 364 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { |
| 367 FakeCapabilityManagerSimple manager( | 365 FakeCapabilityManagerSimple manager( |
| 368 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, | 366 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, |
| 369 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 367 base::WrapUnique(new base::Value(true)), true, false); |
| 370 | 368 |
| 371 EXPECT_TRUE(capabilities()->HiResAudioSupported()); | 369 EXPECT_TRUE(capabilities()->HiResAudioSupported()); |
| 372 capabilities()->SetCapability( | 370 capabilities()->SetCapability(DeviceCapabilities::kKeyHiResAudioSupported, |
| 373 DeviceCapabilities::kKeyHiResAudioSupported, | 371 base::WrapUnique(new base::Value(false))); |
| 374 base::WrapUnique(new base::FundamentalValue(false))); | |
| 375 base::RunLoop().RunUntilIdle(); | 372 base::RunLoop().RunUntilIdle(); |
| 376 EXPECT_FALSE(capabilities()->HiResAudioSupported()); | 373 EXPECT_FALSE(capabilities()->HiResAudioSupported()); |
| 377 } | 374 } |
| 378 | 375 |
| 379 // Tests AssistantSupported() and updating this value through SetCapability() | 376 // Tests AssistantSupported() and updating this value through SetCapability() |
| 380 TEST_F(DeviceCapabilitiesImplTest, AssistantSupportedAndSetCapability) { | 377 TEST_F(DeviceCapabilitiesImplTest, AssistantSupportedAndSetCapability) { |
| 381 FakeCapabilityManagerSimple manager( | 378 FakeCapabilityManagerSimple manager( |
| 382 capabilities(), DeviceCapabilities::kKeyAssistantSupported, | 379 capabilities(), DeviceCapabilities::kKeyAssistantSupported, |
| 383 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 380 base::WrapUnique(new base::Value(true)), true, false); |
| 384 | 381 |
| 385 EXPECT_TRUE(capabilities()->AssistantSupported()); | 382 EXPECT_TRUE(capabilities()->AssistantSupported()); |
| 386 capabilities()->SetCapability( | 383 capabilities()->SetCapability(DeviceCapabilities::kKeyAssistantSupported, |
| 387 DeviceCapabilities::kKeyAssistantSupported, | 384 base::WrapUnique(new base::Value(false))); |
| 388 base::WrapUnique(new base::FundamentalValue(false))); | |
| 389 base::RunLoop().RunUntilIdle(); | 385 base::RunLoop().RunUntilIdle(); |
| 390 EXPECT_FALSE(capabilities()->AssistantSupported()); | 386 EXPECT_FALSE(capabilities()->AssistantSupported()); |
| 391 } | 387 } |
| 392 | 388 |
| 393 // Tests SetCapability() for a default capability when the capability's manager | 389 // Tests SetCapability() for a default capability when the capability's manager |
| 394 // rejects the proposed change. | 390 // rejects the proposed change. |
| 395 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { | 391 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { |
| 396 std::string key; | 392 std::string key; |
| 397 std::unique_ptr<base::Value> init_value; | 393 std::unique_ptr<base::Value> init_value; |
| 398 GetSampleDefaultCapability(&key, &init_value); | 394 GetSampleDefaultCapability(&key, &init_value); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 421 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 417 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
| 422 base::RunLoop().RunUntilIdle(); | 418 base::RunLoop().RunUntilIdle(); |
| 423 EXPECT_TRUE(JsonStringEquals(capabilities()->GetAllData()->json_string(), key, | 419 EXPECT_TRUE(JsonStringEquals(capabilities()->GetAllData()->json_string(), key, |
| 424 *new_value)); | 420 *new_value)); |
| 425 } | 421 } |
| 426 | 422 |
| 427 // Tests that GetPublicData() does not include private capabilities | 423 // Tests that GetPublicData() does not include private capabilities |
| 428 TEST_F(DeviceCapabilitiesImplTest, SetPublicPrivateCapabilities) { | 424 TEST_F(DeviceCapabilitiesImplTest, SetPublicPrivateCapabilities) { |
| 429 std::string key_private = "private"; | 425 std::string key_private = "private"; |
| 430 std::string key_public = "public"; | 426 std::string key_public = "public"; |
| 431 std::unique_ptr<base::Value> init_value(new base::FundamentalValue(true)); | 427 std::unique_ptr<base::Value> init_value(new base::Value(true)); |
| 432 | 428 |
| 433 // Dictionary of only public values. | 429 // Dictionary of only public values. |
| 434 base::DictionaryValue public_dict; | 430 base::DictionaryValue public_dict; |
| 435 public_dict.Set(key_public, init_value->CreateDeepCopy()); | 431 public_dict.Set(key_public, init_value->CreateDeepCopy()); |
| 436 // Dictionary of public and private values. | 432 // Dictionary of public and private values. |
| 437 base::DictionaryValue full_dict; | 433 base::DictionaryValue full_dict; |
| 438 full_dict.Set(key_public, init_value->CreateDeepCopy()); | 434 full_dict.Set(key_public, init_value->CreateDeepCopy()); |
| 439 full_dict.Set(key_private, init_value->CreateDeepCopy()); | 435 full_dict.Set(key_private, init_value->CreateDeepCopy()); |
| 440 | 436 |
| 441 FakeCapabilityManagerSimple public_manager( | 437 FakeCapabilityManagerSimple public_manager( |
| 442 capabilities(), key_public, init_value->CreateDeepCopy(), true, false); | 438 capabilities(), key_public, init_value->CreateDeepCopy(), true, false); |
| 443 FakeCapabilityManagerSimple private_manager( | 439 FakeCapabilityManagerSimple private_manager( |
| 444 capabilities(), key_private, init_value->CreateDeepCopy(), true, true); | 440 capabilities(), key_private, init_value->CreateDeepCopy(), true, true); |
| 445 | 441 |
| 446 EXPECT_TRUE(capabilities()->GetAllData()->dictionary().Equals(&full_dict)); | 442 EXPECT_TRUE(capabilities()->GetAllData()->dictionary().Equals(&full_dict)); |
| 447 EXPECT_TRUE( | 443 EXPECT_TRUE( |
| 448 capabilities()->GetPublicData()->dictionary().Equals(&public_dict)); | 444 capabilities()->GetPublicData()->dictionary().Equals(&public_dict)); |
| 449 } | 445 } |
| 450 | 446 |
| 451 // Tests that SetCapability() defaults to making a capability public | 447 // Tests that SetCapability() defaults to making a capability public |
| 452 TEST_F(DeviceCapabilitiesImplTest, NoValidatorDefaultsToPublicCapability) { | 448 TEST_F(DeviceCapabilitiesImplTest, NoValidatorDefaultsToPublicCapability) { |
| 453 std::string key_private = "private"; | 449 std::string key_private = "private"; |
| 454 std::string key_public = "public"; | 450 std::string key_public = "public"; |
| 455 std::unique_ptr<base::Value> init_value(new base::FundamentalValue(true)); | 451 std::unique_ptr<base::Value> init_value(new base::Value(true)); |
| 456 | 452 |
| 457 // Dictionary of only public values. | 453 // Dictionary of only public values. |
| 458 base::DictionaryValue public_dict; | 454 base::DictionaryValue public_dict; |
| 459 public_dict.Set(key_public, init_value->CreateDeepCopy()); | 455 public_dict.Set(key_public, init_value->CreateDeepCopy()); |
| 460 // Dictionary of public and private values. | 456 // Dictionary of public and private values. |
| 461 base::DictionaryValue full_dict; | 457 base::DictionaryValue full_dict; |
| 462 full_dict.Set(key_public, init_value->CreateDeepCopy()); | 458 full_dict.Set(key_public, init_value->CreateDeepCopy()); |
| 463 full_dict.Set(key_private, init_value->CreateDeepCopy()); | 459 full_dict.Set(key_private, init_value->CreateDeepCopy()); |
| 464 | 460 |
| 465 // We will not create a validator for the public capability; instead we will | 461 // We will not create a validator for the public capability; instead we will |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // Tests that SetCapability() works with expanded paths when there is a | 546 // Tests that SetCapability() works with expanded paths when there is a |
| 551 // capability of type DictionaryValue. | 547 // capability of type DictionaryValue. |
| 552 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { | 548 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { |
| 553 std::string key("dummy_dictionary_key"); | 549 std::string key("dummy_dictionary_key"); |
| 554 std::unique_ptr<base::Value> init_value = | 550 std::unique_ptr<base::Value> init_value = |
| 555 DeserializeFromJson(kSampleDictionaryCapability); | 551 DeserializeFromJson(kSampleDictionaryCapability); |
| 556 ASSERT_TRUE(init_value); | 552 ASSERT_TRUE(init_value); |
| 557 FakeCapabilityManagerSimple manager(capabilities(), key, | 553 FakeCapabilityManagerSimple manager(capabilities(), key, |
| 558 std::move(init_value), true, false); | 554 std::move(init_value), true, false); |
| 559 | 555 |
| 560 capabilities()->SetCapability( | 556 capabilities()->SetCapability("dummy_dictionary_key.dummy_field_bool", |
| 561 "dummy_dictionary_key.dummy_field_bool", | 557 base::WrapUnique(new base::Value(false))); |
| 562 base::WrapUnique(new base::FundamentalValue(false))); | |
| 563 base::RunLoop().RunUntilIdle(); | 558 base::RunLoop().RunUntilIdle(); |
| 564 bool value_bool = true; | 559 bool value_bool = true; |
| 565 std::unique_ptr<base::Value> value = | 560 std::unique_ptr<base::Value> value = |
| 566 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 561 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
| 567 ASSERT_TRUE(value); | 562 ASSERT_TRUE(value); |
| 568 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 563 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
| 569 EXPECT_FALSE(value_bool); | 564 EXPECT_FALSE(value_bool); |
| 570 | 565 |
| 571 capabilities()->SetCapability( | 566 capabilities()->SetCapability("dummy_dictionary_key.dummy_field_int", |
| 572 "dummy_dictionary_key.dummy_field_int", | 567 base::WrapUnique(new base::Value(100))); |
| 573 base::WrapUnique(new base::FundamentalValue(100))); | |
| 574 base::RunLoop().RunUntilIdle(); | 568 base::RunLoop().RunUntilIdle(); |
| 575 int value_int = 0; | 569 int value_int = 0; |
| 576 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 570 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
| 577 ASSERT_TRUE(value); | 571 ASSERT_TRUE(value); |
| 578 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 572 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
| 579 EXPECT_EQ(value_int, 100); | 573 EXPECT_EQ(value_int, 100); |
| 580 } | 574 } |
| 581 | 575 |
| 582 // Tests that SetCapability() works with expanded paths when there is a | 576 // Tests that SetCapability() works with expanded paths when there is a |
| 583 // capability of type DictionaryValue and invalid changes are proposed. | 577 // capability of type DictionaryValue and invalid changes are proposed. |
| 584 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { | 578 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { |
| 585 std::string key("dummy_dictionary_key"); | 579 std::string key("dummy_dictionary_key"); |
| 586 std::unique_ptr<base::Value> init_value = | 580 std::unique_ptr<base::Value> init_value = |
| 587 DeserializeFromJson(kSampleDictionaryCapability); | 581 DeserializeFromJson(kSampleDictionaryCapability); |
| 588 ASSERT_TRUE(init_value); | 582 ASSERT_TRUE(init_value); |
| 589 FakeCapabilityManagerSimple manager(capabilities(), key, | 583 FakeCapabilityManagerSimple manager(capabilities(), key, |
| 590 std::move(init_value), false, false); | 584 std::move(init_value), false, false); |
| 591 | 585 |
| 592 capabilities()->SetCapability( | 586 capabilities()->SetCapability("dummy_dictionary_key.dummy_field_bool", |
| 593 "dummy_dictionary_key.dummy_field_bool", | 587 base::WrapUnique(new base::Value(false))); |
| 594 base::WrapUnique(new base::FundamentalValue(false))); | |
| 595 base::RunLoop().RunUntilIdle(); | 588 base::RunLoop().RunUntilIdle(); |
| 596 bool value_bool = false; | 589 bool value_bool = false; |
| 597 std::unique_ptr<base::Value> value = | 590 std::unique_ptr<base::Value> value = |
| 598 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 591 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
| 599 ASSERT_TRUE(value); | 592 ASSERT_TRUE(value); |
| 600 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 593 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
| 601 EXPECT_TRUE(value_bool); | 594 EXPECT_TRUE(value_bool); |
| 602 | 595 |
| 603 capabilities()->SetCapability( | 596 capabilities()->SetCapability("dummy_dictionary_key.dummy_field_int", |
| 604 "dummy_dictionary_key.dummy_field_int", | 597 base::WrapUnique(new base::Value(100))); |
| 605 base::WrapUnique(new base::FundamentalValue(100))); | |
| 606 base::RunLoop().RunUntilIdle(); | 598 base::RunLoop().RunUntilIdle(); |
| 607 int value_int = 0; | 599 int value_int = 0; |
| 608 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 600 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
| 609 ASSERT_TRUE(value); | 601 ASSERT_TRUE(value); |
| 610 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 602 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
| 611 EXPECT_EQ(value_int, 99); | 603 EXPECT_EQ(value_int, 99); |
| 612 } | 604 } |
| 613 | 605 |
| 614 // Test MergeDictionary. | 606 // Test MergeDictionary. |
| 615 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { | 607 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 EXPECT_EQ(value_int, 100); | 649 EXPECT_EQ(value_int, 100); |
| 658 } | 650 } |
| 659 | 651 |
| 660 // Tests that it is safe to call DeviceCapabilities methods in | 652 // Tests that it is safe to call DeviceCapabilities methods in |
| 661 // an Observer's OnCapabilitiesChanged() implementation safely with correct | 653 // an Observer's OnCapabilitiesChanged() implementation safely with correct |
| 662 // behavior and without deadlocking. | 654 // behavior and without deadlocking. |
| 663 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { | 655 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { |
| 664 FakeCapabilitiesObserver observer(capabilities()); | 656 FakeCapabilitiesObserver observer(capabilities()); |
| 665 | 657 |
| 666 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() | 658 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() |
| 667 capabilities()->SetCapability( | 659 capabilities()->SetCapability("dummy_trigger_key", |
| 668 "dummy_trigger_key", base::WrapUnique(new base::FundamentalValue(true))); | 660 base::WrapUnique(new base::Value(true))); |
| 669 base::RunLoop().RunUntilIdle(); | 661 base::RunLoop().RunUntilIdle(); |
| 670 | 662 |
| 671 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that | 663 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that |
| 672 // behavior was successful | 664 // behavior was successful |
| 673 AssertBasicOperationsSuccessful(capabilities()); | 665 AssertBasicOperationsSuccessful(capabilities()); |
| 674 } | 666 } |
| 675 | 667 |
| 676 // Tests that it is safe to call DeviceCapabilities methods in a Validator's | 668 // Tests that it is safe to call DeviceCapabilities methods in a Validator's |
| 677 // Validate() implementation safely with correct behavior and without | 669 // Validate() implementation safely with correct behavior and without |
| 678 // deadlocking. | 670 // deadlocking. |
| 679 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { | 671 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { |
| 680 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); | 672 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); |
| 681 | 673 |
| 682 // Trigger FakeCapabilityManagerComplex::Validate() | 674 // Trigger FakeCapabilityManagerComplex::Validate() |
| 683 capabilities()->SetCapability( | 675 capabilities()->SetCapability("dummy_validate_key", |
| 684 "dummy_validate_key", base::WrapUnique(new base::FundamentalValue(true))); | 676 base::WrapUnique(new base::Value(true))); |
| 685 base::RunLoop().RunUntilIdle(); | 677 base::RunLoop().RunUntilIdle(); |
| 686 | 678 |
| 687 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior | 679 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior |
| 688 // was successful | 680 // was successful |
| 689 AssertBasicOperationsSuccessful(capabilities()); | 681 AssertBasicOperationsSuccessful(capabilities()); |
| 690 } | 682 } |
| 691 | 683 |
| 692 } // namespace chromecast | 684 } // namespace chromecast |
| OLD | NEW |