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

Side by Side Diff: chrome/browser/policy/policy_service_impl_unittest.cc

Issue 17948002: Update Linux to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/policy_service_impl.h" 5 #include "chrome/browser/policy/policy_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 EXPECT_TRUE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME)); 623 EXPECT_TRUE(policy_service_->IsInitializationComplete(POLICY_DOMAIN_CHROME));
624 EXPECT_TRUE( 624 EXPECT_TRUE(
625 policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS)); 625 policy_service_->IsInitializationComplete(POLICY_DOMAIN_EXTENSIONS));
626 626
627 // Cleanup. 627 // Cleanup.
628 policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, &observer); 628 policy_service_->RemoveObserver(POLICY_DOMAIN_CHROME, &observer);
629 policy_service_->RemoveObserver(POLICY_DOMAIN_EXTENSIONS, &observer); 629 policy_service_->RemoveObserver(POLICY_DOMAIN_EXTENSIONS, &observer);
630 } 630 }
631 631
632 TEST_F(PolicyServiceTest, RegisterPolicyDomain) { 632 TEST_F(PolicyServiceTest, RegisterPolicyDomain) {
633 EXPECT_FALSE( 633 EXPECT_FALSE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)
634 policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)); 634 .get());
635 EXPECT_FALSE( 635 EXPECT_FALSE(policy_service_->GetPolicyDomainDescriptor(
636 policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS)); 636 POLICY_DOMAIN_EXTENSIONS).get());
637 637
638 EXPECT_CALL(provider1_, RegisterPolicyDomain(_)).Times(AnyNumber()); 638 EXPECT_CALL(provider1_, RegisterPolicyDomain(_)).Times(AnyNumber());
639 EXPECT_CALL(provider2_, RegisterPolicyDomain(_)).Times(AnyNumber()); 639 EXPECT_CALL(provider2_, RegisterPolicyDomain(_)).Times(AnyNumber());
640 640
641 scoped_refptr<const PolicyDomainDescriptor> chrome_descriptor = 641 scoped_refptr<const PolicyDomainDescriptor> chrome_descriptor =
642 new PolicyDomainDescriptor(POLICY_DOMAIN_CHROME); 642 new PolicyDomainDescriptor(POLICY_DOMAIN_CHROME);
643 EXPECT_CALL(provider0_, RegisterPolicyDomain(chrome_descriptor)); 643 EXPECT_CALL(provider0_, RegisterPolicyDomain(chrome_descriptor));
644 policy_service_->RegisterPolicyDomain(chrome_descriptor); 644 policy_service_->RegisterPolicyDomain(chrome_descriptor);
645 Mock::VerifyAndClearExpectations(&provider0_); 645 Mock::VerifyAndClearExpectations(&provider0_);
646 646
647 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)); 647 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)
648 EXPECT_FALSE( 648 .get());
649 policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS)); 649 EXPECT_FALSE(policy_service_->GetPolicyDomainDescriptor(
650 POLICY_DOMAIN_EXTENSIONS).get());
650 651
651 // Register another namespace. 652 // Register another namespace.
652 std::string error; 653 std::string error;
653 scoped_ptr<PolicySchema> schema = PolicySchema::Parse( 654 scoped_ptr<PolicySchema> schema = PolicySchema::Parse(
654 "{" 655 "{"
655 " \"$schema\":\"http://json-schema.org/draft-03/schema#\"," 656 " \"$schema\":\"http://json-schema.org/draft-03/schema#\","
656 " \"type\":\"object\"," 657 " \"type\":\"object\","
657 " \"properties\": {" 658 " \"properties\": {"
658 " \"Boolean\": { \"type\": \"boolean\" }," 659 " \"Boolean\": { \"type\": \"boolean\" },"
659 " \"Integer\": { \"type\": \"integer\" }," 660 " \"Integer\": { \"type\": \"integer\" },"
660 " \"Null\": { \"type\": \"null\" }," 661 " \"Null\": { \"type\": \"null\" },"
661 " \"Number\": { \"type\": \"number\" }," 662 " \"Number\": { \"type\": \"number\" },"
662 " \"Object\": { \"type\": \"object\" }," 663 " \"Object\": { \"type\": \"object\" },"
663 " \"String\": { \"type\": \"string\" }" 664 " \"String\": { \"type\": \"string\" }"
664 " }" 665 " }"
665 "}", &error); 666 "}", &error);
666 ASSERT_TRUE(schema); 667 ASSERT_TRUE(schema);
667 scoped_refptr<PolicyDomainDescriptor> extensions_descriptor = 668 scoped_refptr<PolicyDomainDescriptor> extensions_descriptor =
668 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); 669 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS);
669 extensions_descriptor->RegisterComponent(kExtension, schema.Pass()); 670 extensions_descriptor->RegisterComponent(kExtension, schema.Pass());
670 EXPECT_CALL(provider0_, RegisterPolicyDomain( 671 EXPECT_CALL(provider0_, RegisterPolicyDomain(
671 scoped_refptr<const PolicyDomainDescriptor>(extensions_descriptor))); 672 scoped_refptr<const PolicyDomainDescriptor>(extensions_descriptor)));
672 policy_service_->RegisterPolicyDomain(extensions_descriptor); 673 policy_service_->RegisterPolicyDomain(extensions_descriptor);
673 Mock::VerifyAndClearExpectations(&provider0_); 674 Mock::VerifyAndClearExpectations(&provider0_);
674 675
675 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)); 676 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME)
676 EXPECT_TRUE( 677 .get());
677 policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS)); 678 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(
679 POLICY_DOMAIN_EXTENSIONS).get());
678 680
679 // Remove those components. 681 // Remove those components.
680 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor = 682 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor =
681 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); 683 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS);
682 EXPECT_CALL(provider0_, RegisterPolicyDomain( 684 EXPECT_CALL(provider0_, RegisterPolicyDomain(
683 scoped_refptr<const PolicyDomainDescriptor>( 685 scoped_refptr<const PolicyDomainDescriptor>(
684 empty_extensions_descriptor))); 686 empty_extensions_descriptor)));
685 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor); 687 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor);
686 Mock::VerifyAndClearExpectations(&provider0_); 688 Mock::VerifyAndClearExpectations(&provider0_);
687 } 689 }
688 690
689 } // namespace policy 691 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698