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

Side by Side Diff: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); 572 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery);
573 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse( 573 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse(
574 profile(), &BuildTestEasyUnlockService); 574 profile(), &BuildTestEasyUnlockService);
575 575
576 scoped_refptr<TestableGetRemoteDevicesFunction> function( 576 scoped_refptr<TestableGetRemoteDevicesFunction> function(
577 new TestableGetRemoteDevicesFunction()); 577 new TestableGetRemoteDevicesFunction());
578 std::unique_ptr<base::Value> value( 578 std::unique_ptr<base::Value> value(
579 extensions::api_test_utils::RunFunctionAndReturnSingleResult( 579 extensions::api_test_utils::RunFunctionAndReturnSingleResult(
580 function.get(), "[]", profile())); 580 function.get(), "[]", profile()));
581 ASSERT_TRUE(value.get()); 581 ASSERT_TRUE(value.get());
582 ASSERT_EQ(base::Value::TYPE_LIST, value->GetType()); 582 ASSERT_EQ(base::Value::Type::LIST, value->GetType());
583 583
584 base::ListValue* list_value = static_cast<base::ListValue*>(value.get()); 584 base::ListValue* list_value = static_cast<base::ListValue*>(value.get());
585 EXPECT_EQ(2u, list_value->GetSize()); 585 EXPECT_EQ(2u, list_value->GetSize());
586 586
587 base::Value* remote_device1; 587 base::Value* remote_device1;
588 base::Value* remote_device2; 588 base::Value* remote_device2;
589 ASSERT_TRUE(list_value->Get(0, &remote_device1)); 589 ASSERT_TRUE(list_value->Get(0, &remote_device1));
590 ASSERT_TRUE(list_value->Get(1, &remote_device2)); 590 ASSERT_TRUE(list_value->Get(1, &remote_device2));
591 EXPECT_EQ(base::Value::TYPE_DICTIONARY, remote_device1->GetType()); 591 EXPECT_EQ(base::Value::Type::DICTIONARY, remote_device1->GetType());
592 EXPECT_EQ(base::Value::TYPE_DICTIONARY, remote_device2->GetType()); 592 EXPECT_EQ(base::Value::Type::DICTIONARY, remote_device2->GetType());
593 593
594 std::string name1, name2; 594 std::string name1, name2;
595 EXPECT_TRUE(static_cast<base::DictionaryValue*>(remote_device1) 595 EXPECT_TRUE(static_cast<base::DictionaryValue*>(remote_device1)
596 ->GetString("name", &name1)); 596 ->GetString("name", &name1));
597 EXPECT_TRUE(static_cast<base::DictionaryValue*>(remote_device2) 597 EXPECT_TRUE(static_cast<base::DictionaryValue*>(remote_device2)
598 ->GetString("name", &name2)); 598 ->GetString("name", &name2));
599 599
600 EXPECT_EQ("test phone 1", name1); 600 EXPECT_EQ("test phone 1", name1);
601 EXPECT_EQ("test phone 2", name2); 601 EXPECT_EQ("test phone 2", name2);
602 } 602 }
603 603
604 // Checks that the chrome.easyUnlockPrivate.getRemoteDevices API returns the 604 // Checks that the chrome.easyUnlockPrivate.getRemoteDevices API returns the
605 // stored value if the kEnableBluetoothLowEnergyDiscovery switch is not set. 605 // stored value if the kEnableBluetoothLowEnergyDiscovery switch is not set.
606 TEST_F(EasyUnlockPrivateApiTest, GetRemoteDevicesNonExperimental) { 606 TEST_F(EasyUnlockPrivateApiTest, GetRemoteDevicesNonExperimental) {
607 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse( 607 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse(
608 profile(), &BuildTestEasyUnlockService); 608 profile(), &BuildTestEasyUnlockService);
609 609
610 scoped_refptr<TestableGetRemoteDevicesFunction> function( 610 scoped_refptr<TestableGetRemoteDevicesFunction> function(
611 new TestableGetRemoteDevicesFunction()); 611 new TestableGetRemoteDevicesFunction());
612 std::unique_ptr<base::Value> value( 612 std::unique_ptr<base::Value> value(
613 extensions::api_test_utils::RunFunctionAndReturnSingleResult( 613 extensions::api_test_utils::RunFunctionAndReturnSingleResult(
614 function.get(), "[]", profile())); 614 function.get(), "[]", profile()));
615 ASSERT_TRUE(value.get()); 615 ASSERT_TRUE(value.get());
616 ASSERT_EQ(base::Value::TYPE_LIST, value->GetType()); 616 ASSERT_EQ(base::Value::Type::LIST, value->GetType());
617 617
618 base::ListValue* list_value = static_cast<base::ListValue*>(value.get()); 618 base::ListValue* list_value = static_cast<base::ListValue*>(value.get());
619 EXPECT_EQ(0u, list_value->GetSize()); 619 EXPECT_EQ(0u, list_value->GetSize());
620 } 620 }
621 621
622 // Checks that the chrome.easyUnlockPrivate.getPermitAccess API returns the 622 // Checks that the chrome.easyUnlockPrivate.getPermitAccess API returns the
623 // native permit access if the kEnableBluetoothLowEnergyDiscovery switch is 623 // native permit access if the kEnableBluetoothLowEnergyDiscovery switch is
624 // set. 624 // set.
625 TEST_F(EasyUnlockPrivateApiTest, GetPermitAccessExperimental) { 625 TEST_F(EasyUnlockPrivateApiTest, GetPermitAccessExperimental) {
626 base::CommandLine::ForCurrentProcess()->AppendSwitch( 626 base::CommandLine::ForCurrentProcess()->AppendSwitch(
627 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery); 627 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery);
628 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse( 628 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse(
629 profile(), &BuildTestEasyUnlockService); 629 profile(), &BuildTestEasyUnlockService);
630 630
631 scoped_refptr<TestableGetPermitAccessFunction> function( 631 scoped_refptr<TestableGetPermitAccessFunction> function(
632 new TestableGetPermitAccessFunction()); 632 new TestableGetPermitAccessFunction());
633 std::unique_ptr<base::Value> value( 633 std::unique_ptr<base::Value> value(
634 extensions::api_test_utils::RunFunctionAndReturnSingleResult( 634 extensions::api_test_utils::RunFunctionAndReturnSingleResult(
635 function.get(), "[]", profile())); 635 function.get(), "[]", profile()));
636 ASSERT_TRUE(value); 636 ASSERT_TRUE(value);
637 ASSERT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); 637 ASSERT_EQ(base::Value::Type::DICTIONARY, value->GetType());
638 base::DictionaryValue* permit_access = 638 base::DictionaryValue* permit_access =
639 static_cast<base::DictionaryValue*>(value.get()); 639 static_cast<base::DictionaryValue*>(value.get());
640 640
641 std::string user_public_key, user_private_key; 641 std::string user_public_key, user_private_key;
642 EXPECT_TRUE(permit_access->GetString("id", &user_public_key)); 642 EXPECT_TRUE(permit_access->GetString("id", &user_public_key));
643 EXPECT_TRUE(permit_access->GetString("data", &user_private_key)); 643 EXPECT_TRUE(permit_access->GetString("data", &user_private_key));
644 EXPECT_EQ("user public key", user_public_key); 644 EXPECT_EQ("user public key", user_public_key);
645 EXPECT_EQ("user private key", user_private_key); 645 EXPECT_EQ("user private key", user_private_key);
646 } 646 }
647 647
648 // Checks that the chrome.easyUnlockPrivate.getPermitAccess API returns the 648 // Checks that the chrome.easyUnlockPrivate.getPermitAccess API returns the
649 // stored value if the kEnableBluetoothLowEnergyDiscovery switch is not set. 649 // stored value if the kEnableBluetoothLowEnergyDiscovery switch is not set.
650 TEST_F(EasyUnlockPrivateApiTest, GetPermitAccessNonExperimental) { 650 TEST_F(EasyUnlockPrivateApiTest, GetPermitAccessNonExperimental) {
651 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse( 651 EasyUnlockServiceFactory::GetInstance()->SetTestingFactoryAndUse(
652 profile(), &BuildTestEasyUnlockService); 652 profile(), &BuildTestEasyUnlockService);
653 653
654 scoped_refptr<TestableGetPermitAccessFunction> function( 654 scoped_refptr<TestableGetPermitAccessFunction> function(
655 new TestableGetPermitAccessFunction()); 655 new TestableGetPermitAccessFunction());
656 std::unique_ptr<base::Value> value( 656 std::unique_ptr<base::Value> value(
657 extensions::api_test_utils::RunFunctionAndReturnSingleResult( 657 extensions::api_test_utils::RunFunctionAndReturnSingleResult(
658 function.get(), "[]", profile())); 658 function.get(), "[]", profile()));
659 EXPECT_FALSE(value); 659 EXPECT_FALSE(value);
660 } 660 }
661 661
662 } // namespace 662 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698