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( |
345 DeviceCapabilities::kKeyBluetoothSupported, | 345 DeviceCapabilities::kKeyBluetoothSupported, |
346 base::WrapUnique(new base::FundamentalValue(false))); | 346 base::WrapUnique(new base::Value(false))); |
347 base::RunLoop().RunUntilIdle(); | 347 base::RunLoop().RunUntilIdle(); |
348 EXPECT_FALSE(capabilities()->BluetoothSupported()); | 348 EXPECT_FALSE(capabilities()->BluetoothSupported()); |
349 } | 349 } |
350 | 350 |
351 // Tests DisplaySupported() and updating this value through SetCapability(). | 351 // Tests DisplaySupported() and updating this value through SetCapability(). |
352 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { | 352 TEST_F(DeviceCapabilitiesImplTest, DisplaySupportedAndSetCapability) { |
353 FakeCapabilityManagerSimple manager( | 353 FakeCapabilityManagerSimple manager( |
354 capabilities(), DeviceCapabilities::kKeyDisplaySupported, | 354 capabilities(), DeviceCapabilities::kKeyDisplaySupported, |
355 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 355 base::WrapUnique(new base::Value(true)), true, false); |
356 | 356 |
357 EXPECT_TRUE(capabilities()->DisplaySupported()); | 357 EXPECT_TRUE(capabilities()->DisplaySupported()); |
358 capabilities()->SetCapability( | 358 capabilities()->SetCapability( |
359 DeviceCapabilities::kKeyDisplaySupported, | 359 DeviceCapabilities::kKeyDisplaySupported, |
360 base::WrapUnique(new base::FundamentalValue(false))); | 360 base::WrapUnique(new base::Value(false))); |
361 base::RunLoop().RunUntilIdle(); | 361 base::RunLoop().RunUntilIdle(); |
362 EXPECT_FALSE(capabilities()->DisplaySupported()); | 362 EXPECT_FALSE(capabilities()->DisplaySupported()); |
363 } | 363 } |
364 | 364 |
365 // Tests HiResAudioSupported() and updating this value through SetCapability() | 365 // Tests HiResAudioSupported() and updating this value through SetCapability() |
366 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { | 366 TEST_F(DeviceCapabilitiesImplTest, HiResAudioSupportedAndSetCapability) { |
367 FakeCapabilityManagerSimple manager( | 367 FakeCapabilityManagerSimple manager( |
368 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, | 368 capabilities(), DeviceCapabilities::kKeyHiResAudioSupported, |
369 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 369 base::WrapUnique(new base::Value(true)), true, false); |
370 | 370 |
371 EXPECT_TRUE(capabilities()->HiResAudioSupported()); | 371 EXPECT_TRUE(capabilities()->HiResAudioSupported()); |
372 capabilities()->SetCapability( | 372 capabilities()->SetCapability( |
373 DeviceCapabilities::kKeyHiResAudioSupported, | 373 DeviceCapabilities::kKeyHiResAudioSupported, |
374 base::WrapUnique(new base::FundamentalValue(false))); | 374 base::WrapUnique(new base::Value(false))); |
375 base::RunLoop().RunUntilIdle(); | 375 base::RunLoop().RunUntilIdle(); |
376 EXPECT_FALSE(capabilities()->HiResAudioSupported()); | 376 EXPECT_FALSE(capabilities()->HiResAudioSupported()); |
377 } | 377 } |
378 | 378 |
379 // Tests AssistantSupported() and updating this value through SetCapability() | 379 // Tests AssistantSupported() and updating this value through SetCapability() |
380 TEST_F(DeviceCapabilitiesImplTest, AssistantSupportedAndSetCapability) { | 380 TEST_F(DeviceCapabilitiesImplTest, AssistantSupportedAndSetCapability) { |
381 FakeCapabilityManagerSimple manager( | 381 FakeCapabilityManagerSimple manager( |
382 capabilities(), DeviceCapabilities::kKeyAssistantSupported, | 382 capabilities(), DeviceCapabilities::kKeyAssistantSupported, |
383 base::WrapUnique(new base::FundamentalValue(true)), true, false); | 383 base::WrapUnique(new base::Value(true)), true, false); |
384 | 384 |
385 EXPECT_TRUE(capabilities()->AssistantSupported()); | 385 EXPECT_TRUE(capabilities()->AssistantSupported()); |
386 capabilities()->SetCapability( | 386 capabilities()->SetCapability( |
387 DeviceCapabilities::kKeyAssistantSupported, | 387 DeviceCapabilities::kKeyAssistantSupported, |
388 base::WrapUnique(new base::FundamentalValue(false))); | 388 base::WrapUnique(new base::Value(false))); |
389 base::RunLoop().RunUntilIdle(); | 389 base::RunLoop().RunUntilIdle(); |
390 EXPECT_FALSE(capabilities()->AssistantSupported()); | 390 EXPECT_FALSE(capabilities()->AssistantSupported()); |
391 } | 391 } |
392 | 392 |
393 // Tests SetCapability() for a default capability when the capability's manager | 393 // Tests SetCapability() for a default capability when the capability's manager |
394 // rejects the proposed change. | 394 // rejects the proposed change. |
395 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { | 395 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityInvalid) { |
396 std::string key; | 396 std::string key; |
397 std::unique_ptr<base::Value> init_value; | 397 std::unique_ptr<base::Value> init_value; |
398 GetSampleDefaultCapability(&key, &init_value); | 398 GetSampleDefaultCapability(&key, &init_value); |
(...skipping 22 matching lines...) Expand all Loading... |
421 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); | 421 capabilities()->SetCapability(key, new_value->CreateDeepCopy()); |
422 base::RunLoop().RunUntilIdle(); | 422 base::RunLoop().RunUntilIdle(); |
423 EXPECT_TRUE(JsonStringEquals(capabilities()->GetAllData()->json_string(), key, | 423 EXPECT_TRUE(JsonStringEquals(capabilities()->GetAllData()->json_string(), key, |
424 *new_value)); | 424 *new_value)); |
425 } | 425 } |
426 | 426 |
427 // Tests that GetPublicData() does not include private capabilities | 427 // Tests that GetPublicData() does not include private capabilities |
428 TEST_F(DeviceCapabilitiesImplTest, SetPublicPrivateCapabilities) { | 428 TEST_F(DeviceCapabilitiesImplTest, SetPublicPrivateCapabilities) { |
429 std::string key_private = "private"; | 429 std::string key_private = "private"; |
430 std::string key_public = "public"; | 430 std::string key_public = "public"; |
431 std::unique_ptr<base::Value> init_value(new base::FundamentalValue(true)); | 431 std::unique_ptr<base::Value> init_value(new base::Value(true)); |
432 | 432 |
433 // Dictionary of only public values. | 433 // Dictionary of only public values. |
434 base::DictionaryValue public_dict; | 434 base::DictionaryValue public_dict; |
435 public_dict.Set(key_public, init_value->CreateDeepCopy()); | 435 public_dict.Set(key_public, init_value->CreateDeepCopy()); |
436 // Dictionary of public and private values. | 436 // Dictionary of public and private values. |
437 base::DictionaryValue full_dict; | 437 base::DictionaryValue full_dict; |
438 full_dict.Set(key_public, init_value->CreateDeepCopy()); | 438 full_dict.Set(key_public, init_value->CreateDeepCopy()); |
439 full_dict.Set(key_private, init_value->CreateDeepCopy()); | 439 full_dict.Set(key_private, init_value->CreateDeepCopy()); |
440 | 440 |
441 FakeCapabilityManagerSimple public_manager( | 441 FakeCapabilityManagerSimple public_manager( |
442 capabilities(), key_public, init_value->CreateDeepCopy(), true, false); | 442 capabilities(), key_public, init_value->CreateDeepCopy(), true, false); |
443 FakeCapabilityManagerSimple private_manager( | 443 FakeCapabilityManagerSimple private_manager( |
444 capabilities(), key_private, init_value->CreateDeepCopy(), true, true); | 444 capabilities(), key_private, init_value->CreateDeepCopy(), true, true); |
445 | 445 |
446 EXPECT_TRUE(capabilities()->GetAllData()->dictionary().Equals(&full_dict)); | 446 EXPECT_TRUE(capabilities()->GetAllData()->dictionary().Equals(&full_dict)); |
447 EXPECT_TRUE( | 447 EXPECT_TRUE( |
448 capabilities()->GetPublicData()->dictionary().Equals(&public_dict)); | 448 capabilities()->GetPublicData()->dictionary().Equals(&public_dict)); |
449 } | 449 } |
450 | 450 |
451 // Tests that SetCapability() defaults to making a capability public | 451 // Tests that SetCapability() defaults to making a capability public |
452 TEST_F(DeviceCapabilitiesImplTest, NoValidatorDefaultsToPublicCapability) { | 452 TEST_F(DeviceCapabilitiesImplTest, NoValidatorDefaultsToPublicCapability) { |
453 std::string key_private = "private"; | 453 std::string key_private = "private"; |
454 std::string key_public = "public"; | 454 std::string key_public = "public"; |
455 std::unique_ptr<base::Value> init_value(new base::FundamentalValue(true)); | 455 std::unique_ptr<base::Value> init_value(new base::Value(true)); |
456 | 456 |
457 // Dictionary of only public values. | 457 // Dictionary of only public values. |
458 base::DictionaryValue public_dict; | 458 base::DictionaryValue public_dict; |
459 public_dict.Set(key_public, init_value->CreateDeepCopy()); | 459 public_dict.Set(key_public, init_value->CreateDeepCopy()); |
460 // Dictionary of public and private values. | 460 // Dictionary of public and private values. |
461 base::DictionaryValue full_dict; | 461 base::DictionaryValue full_dict; |
462 full_dict.Set(key_public, init_value->CreateDeepCopy()); | 462 full_dict.Set(key_public, init_value->CreateDeepCopy()); |
463 full_dict.Set(key_private, init_value->CreateDeepCopy()); | 463 full_dict.Set(key_private, init_value->CreateDeepCopy()); |
464 | 464 |
465 // We will not create a validator for the public capability; instead we will | 465 // We will not create a validator for the public capability; instead we will |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { | 552 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionary) { |
553 std::string key("dummy_dictionary_key"); | 553 std::string key("dummy_dictionary_key"); |
554 std::unique_ptr<base::Value> init_value = | 554 std::unique_ptr<base::Value> init_value = |
555 DeserializeFromJson(kSampleDictionaryCapability); | 555 DeserializeFromJson(kSampleDictionaryCapability); |
556 ASSERT_TRUE(init_value); | 556 ASSERT_TRUE(init_value); |
557 FakeCapabilityManagerSimple manager(capabilities(), key, | 557 FakeCapabilityManagerSimple manager(capabilities(), key, |
558 std::move(init_value), true, false); | 558 std::move(init_value), true, false); |
559 | 559 |
560 capabilities()->SetCapability( | 560 capabilities()->SetCapability( |
561 "dummy_dictionary_key.dummy_field_bool", | 561 "dummy_dictionary_key.dummy_field_bool", |
562 base::WrapUnique(new base::FundamentalValue(false))); | 562 base::WrapUnique(new base::Value(false))); |
563 base::RunLoop().RunUntilIdle(); | 563 base::RunLoop().RunUntilIdle(); |
564 bool value_bool = true; | 564 bool value_bool = true; |
565 std::unique_ptr<base::Value> value = | 565 std::unique_ptr<base::Value> value = |
566 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 566 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
567 ASSERT_TRUE(value); | 567 ASSERT_TRUE(value); |
568 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 568 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
569 EXPECT_FALSE(value_bool); | 569 EXPECT_FALSE(value_bool); |
570 | 570 |
571 capabilities()->SetCapability( | 571 capabilities()->SetCapability( |
572 "dummy_dictionary_key.dummy_field_int", | 572 "dummy_dictionary_key.dummy_field_int", |
573 base::WrapUnique(new base::FundamentalValue(100))); | 573 base::WrapUnique(new base::Value(100))); |
574 base::RunLoop().RunUntilIdle(); | 574 base::RunLoop().RunUntilIdle(); |
575 int value_int = 0; | 575 int value_int = 0; |
576 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 576 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
577 ASSERT_TRUE(value); | 577 ASSERT_TRUE(value); |
578 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 578 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
579 EXPECT_EQ(value_int, 100); | 579 EXPECT_EQ(value_int, 100); |
580 } | 580 } |
581 | 581 |
582 // Tests that SetCapability() works with expanded paths when there is a | 582 // Tests that SetCapability() works with expanded paths when there is a |
583 // capability of type DictionaryValue and invalid changes are proposed. | 583 // capability of type DictionaryValue and invalid changes are proposed. |
584 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { | 584 TEST_F(DeviceCapabilitiesImplTest, SetCapabilityDictionaryInvalid) { |
585 std::string key("dummy_dictionary_key"); | 585 std::string key("dummy_dictionary_key"); |
586 std::unique_ptr<base::Value> init_value = | 586 std::unique_ptr<base::Value> init_value = |
587 DeserializeFromJson(kSampleDictionaryCapability); | 587 DeserializeFromJson(kSampleDictionaryCapability); |
588 ASSERT_TRUE(init_value); | 588 ASSERT_TRUE(init_value); |
589 FakeCapabilityManagerSimple manager(capabilities(), key, | 589 FakeCapabilityManagerSimple manager(capabilities(), key, |
590 std::move(init_value), false, false); | 590 std::move(init_value), false, false); |
591 | 591 |
592 capabilities()->SetCapability( | 592 capabilities()->SetCapability( |
593 "dummy_dictionary_key.dummy_field_bool", | 593 "dummy_dictionary_key.dummy_field_bool", |
594 base::WrapUnique(new base::FundamentalValue(false))); | 594 base::WrapUnique(new base::Value(false))); |
595 base::RunLoop().RunUntilIdle(); | 595 base::RunLoop().RunUntilIdle(); |
596 bool value_bool = false; | 596 bool value_bool = false; |
597 std::unique_ptr<base::Value> value = | 597 std::unique_ptr<base::Value> value = |
598 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); | 598 capabilities()->GetCapability("dummy_dictionary_key.dummy_field_bool"); |
599 ASSERT_TRUE(value); | 599 ASSERT_TRUE(value); |
600 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); | 600 EXPECT_TRUE(value->GetAsBoolean(&value_bool)); |
601 EXPECT_TRUE(value_bool); | 601 EXPECT_TRUE(value_bool); |
602 | 602 |
603 capabilities()->SetCapability( | 603 capabilities()->SetCapability( |
604 "dummy_dictionary_key.dummy_field_int", | 604 "dummy_dictionary_key.dummy_field_int", |
605 base::WrapUnique(new base::FundamentalValue(100))); | 605 base::WrapUnique(new base::Value(100))); |
606 base::RunLoop().RunUntilIdle(); | 606 base::RunLoop().RunUntilIdle(); |
607 int value_int = 0; | 607 int value_int = 0; |
608 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); | 608 value = capabilities()->GetCapability("dummy_dictionary_key.dummy_field_int"); |
609 ASSERT_TRUE(value); | 609 ASSERT_TRUE(value); |
610 EXPECT_TRUE(value->GetAsInteger(&value_int)); | 610 EXPECT_TRUE(value->GetAsInteger(&value_int)); |
611 EXPECT_EQ(value_int, 99); | 611 EXPECT_EQ(value_int, 99); |
612 } | 612 } |
613 | 613 |
614 // Test MergeDictionary. | 614 // Test MergeDictionary. |
615 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { | 615 TEST_F(DeviceCapabilitiesImplTest, MergeDictionary) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 658 } |
659 | 659 |
660 // Tests that it is safe to call DeviceCapabilities methods in | 660 // Tests that it is safe to call DeviceCapabilities methods in |
661 // an Observer's OnCapabilitiesChanged() implementation safely with correct | 661 // an Observer's OnCapabilitiesChanged() implementation safely with correct |
662 // behavior and without deadlocking. | 662 // behavior and without deadlocking. |
663 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { | 663 TEST_F(DeviceCapabilitiesImplTest, OnCapabilitiesChangedSafe) { |
664 FakeCapabilitiesObserver observer(capabilities()); | 664 FakeCapabilitiesObserver observer(capabilities()); |
665 | 665 |
666 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() | 666 // Trigger FakeCapabilitiesObserver::OnCapabilitiesChanged() |
667 capabilities()->SetCapability( | 667 capabilities()->SetCapability( |
668 "dummy_trigger_key", base::WrapUnique(new base::FundamentalValue(true))); | 668 "dummy_trigger_key", base::WrapUnique(new base::Value(true))); |
669 base::RunLoop().RunUntilIdle(); | 669 base::RunLoop().RunUntilIdle(); |
670 | 670 |
671 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that | 671 // Check that FakeCapabilitiesObserver::OnCapabilitiesChanged() ran and that |
672 // behavior was successful | 672 // behavior was successful |
673 AssertBasicOperationsSuccessful(capabilities()); | 673 AssertBasicOperationsSuccessful(capabilities()); |
674 } | 674 } |
675 | 675 |
676 // Tests that it is safe to call DeviceCapabilities methods in a Validator's | 676 // Tests that it is safe to call DeviceCapabilities methods in a Validator's |
677 // Validate() implementation safely with correct behavior and without | 677 // Validate() implementation safely with correct behavior and without |
678 // deadlocking. | 678 // deadlocking. |
679 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { | 679 TEST_F(DeviceCapabilitiesImplTest, ValidateSafe) { |
680 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); | 680 FakeCapabilityManagerComplex manager(capabilities(), "dummy_validate_key"); |
681 | 681 |
682 // Trigger FakeCapabilityManagerComplex::Validate() | 682 // Trigger FakeCapabilityManagerComplex::Validate() |
683 capabilities()->SetCapability( | 683 capabilities()->SetCapability( |
684 "dummy_validate_key", base::WrapUnique(new base::FundamentalValue(true))); | 684 "dummy_validate_key", base::WrapUnique(new base::Value(true))); |
685 base::RunLoop().RunUntilIdle(); | 685 base::RunLoop().RunUntilIdle(); |
686 | 686 |
687 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior | 687 // Check that FakeCapabilityManagerComplex::Validate() ran and that behavior |
688 // was successful | 688 // was successful |
689 AssertBasicOperationsSuccessful(capabilities()); | 689 AssertBasicOperationsSuccessful(capabilities()); |
690 } | 690 } |
691 | 691 |
692 } // namespace chromecast | 692 } // namespace chromecast |
OLD | NEW |