OLD | NEW |
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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 policy_service_->RegisterPolicyDomain(chrome_descriptor); | 620 policy_service_->RegisterPolicyDomain(chrome_descriptor); |
621 Mock::VerifyAndClearExpectations(&provider0_); | 621 Mock::VerifyAndClearExpectations(&provider0_); |
622 | 622 |
623 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME) | 623 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME) |
624 .get()); | 624 .get()); |
625 EXPECT_FALSE(policy_service_->GetPolicyDomainDescriptor( | 625 EXPECT_FALSE(policy_service_->GetPolicyDomainDescriptor( |
626 POLICY_DOMAIN_EXTENSIONS).get()); | 626 POLICY_DOMAIN_EXTENSIONS).get()); |
627 | 627 |
628 // Register another namespace. | 628 // Register another namespace. |
629 std::string error; | 629 std::string error; |
630 scoped_ptr<SchemaOwner> schema = SchemaOwner::Parse( | 630 Schema schema = Schema::Parse( |
631 "{" | 631 "{" |
632 " \"type\":\"object\"," | 632 " \"type\":\"object\"," |
633 " \"properties\": {" | 633 " \"properties\": {" |
634 " \"Boolean\": { \"type\": \"boolean\" }," | 634 " \"Boolean\": { \"type\": \"boolean\" }," |
635 " \"Integer\": { \"type\": \"integer\" }," | 635 " \"Integer\": { \"type\": \"integer\" }," |
636 " \"Null\": { \"type\": \"null\" }," | 636 " \"Null\": { \"type\": \"null\" }," |
637 " \"Number\": { \"type\": \"number\" }," | 637 " \"Number\": { \"type\": \"number\" }," |
638 " \"Object\": { \"type\": \"object\" }," | 638 " \"Object\": { \"type\": \"object\" }," |
639 " \"String\": { \"type\": \"string\" }" | 639 " \"String\": { \"type\": \"string\" }" |
640 " }" | 640 " }" |
641 "}", &error); | 641 "}", &error); |
642 ASSERT_TRUE(schema); | 642 ASSERT_TRUE(schema.valid()) << error; |
643 scoped_refptr<PolicyDomainDescriptor> extensions_descriptor = | 643 scoped_refptr<PolicyDomainDescriptor> extensions_descriptor = |
644 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); | 644 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); |
645 extensions_descriptor->RegisterComponent(kExtension, schema.Pass()); | 645 extensions_descriptor->RegisterComponent(kExtension, schema); |
646 EXPECT_CALL(provider0_, RegisterPolicyDomain( | 646 EXPECT_CALL(provider0_, RegisterPolicyDomain( |
647 scoped_refptr<const PolicyDomainDescriptor>(extensions_descriptor))); | 647 scoped_refptr<const PolicyDomainDescriptor>(extensions_descriptor))); |
648 policy_service_->RegisterPolicyDomain(extensions_descriptor); | 648 policy_service_->RegisterPolicyDomain(extensions_descriptor); |
649 Mock::VerifyAndClearExpectations(&provider0_); | 649 Mock::VerifyAndClearExpectations(&provider0_); |
650 | 650 |
651 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME) | 651 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor(POLICY_DOMAIN_CHROME) |
652 .get()); | 652 .get()); |
653 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor( | 653 EXPECT_TRUE(policy_service_->GetPolicyDomainDescriptor( |
654 POLICY_DOMAIN_EXTENSIONS).get()); | 654 POLICY_DOMAIN_EXTENSIONS).get()); |
655 | 655 |
656 // Remove those components. | 656 // Remove those components. |
657 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor = | 657 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor = |
658 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); | 658 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); |
659 EXPECT_CALL(provider0_, RegisterPolicyDomain( | 659 EXPECT_CALL(provider0_, RegisterPolicyDomain( |
660 scoped_refptr<const PolicyDomainDescriptor>( | 660 scoped_refptr<const PolicyDomainDescriptor>( |
661 empty_extensions_descriptor))); | 661 empty_extensions_descriptor))); |
662 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor); | 662 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor); |
663 Mock::VerifyAndClearExpectations(&provider0_); | 663 Mock::VerifyAndClearExpectations(&provider0_); |
664 } | 664 } |
665 | 665 |
666 } // namespace policy | 666 } // namespace policy |
OLD | NEW |