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

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

Issue 18153007: Add policies to control power management on the Chrome OS login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct example in policy_templates.json. Created 7 years, 5 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/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/policy/external_data_fetcher.h" 15 #include "chrome/browser/policy/external_data_fetcher.h"
16 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 16 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
17 #include "chrome/browser/policy/mock_policy_service.h"
17 #include "chrome/browser/policy/policy_domain_descriptor.h" 18 #include "chrome/browser/policy/policy_domain_descriptor.h"
18 #include "chrome/common/policy/policy_schema.h" 19 #include "chrome/common/policy/policy_schema.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using ::testing::AnyNumber; 25 using ::testing::AnyNumber;
25 using ::testing::Mock; 26 using ::testing::Mock;
26 using ::testing::Return; 27 using ::testing::Return;
27 using ::testing::_; 28 using ::testing::_;
28 29
29 namespace policy { 30 namespace policy {
30 31
31 namespace { 32 namespace {
32 33
33 const char kExtension[] = "extension-id"; 34 const char kExtension[] = "extension-id";
34 const char kSameLevelPolicy[] = "policy-same-level-and-scope"; 35 const char kSameLevelPolicy[] = "policy-same-level-and-scope";
35 const char kDiffLevelPolicy[] = "chrome-diff-level-and-scope"; 36 const char kDiffLevelPolicy[] = "chrome-diff-level-and-scope";
36 37
37 class MockPolicyServiceObserver : public PolicyService::Observer {
38 public:
39 virtual ~MockPolicyServiceObserver() {}
40 MOCK_METHOD3(OnPolicyUpdated, void(const PolicyNamespace&,
41 const PolicyMap& previous,
42 const PolicyMap& current));
43 MOCK_METHOD1(OnPolicyServiceInitialized, void(PolicyDomain));
44 };
45
46 // Helper to compare the arguments to an EXPECT_CALL of OnPolicyUpdated() with 38 // Helper to compare the arguments to an EXPECT_CALL of OnPolicyUpdated() with
47 // their expected values. 39 // their expected values.
48 MATCHER_P(PolicyEquals, expected, "") { 40 MATCHER_P(PolicyEquals, expected, "") {
49 return arg.Equals(*expected); 41 return arg.Equals(*expected);
50 } 42 }
51 43
52 // Helper to compare the arguments to an EXPECT_CALL of OnPolicyValueUpdated() 44 // Helper to compare the arguments to an EXPECT_CALL of OnPolicyValueUpdated()
53 // with their expected values. 45 // with their expected values.
54 MATCHER_P(ValueEquals, expected, "") { 46 MATCHER_P(ValueEquals, expected, "") {
55 return base::Value::Equals(arg, expected); 47 return base::Value::Equals(arg, expected);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor = 677 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor =
686 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); 678 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS);
687 EXPECT_CALL(provider0_, RegisterPolicyDomain( 679 EXPECT_CALL(provider0_, RegisterPolicyDomain(
688 scoped_refptr<const PolicyDomainDescriptor>( 680 scoped_refptr<const PolicyDomainDescriptor>(
689 empty_extensions_descriptor))); 681 empty_extensions_descriptor)));
690 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor); 682 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor);
691 Mock::VerifyAndClearExpectations(&provider0_); 683 Mock::VerifyAndClearExpectations(&provider0_);
692 } 684 }
693 685
694 } // namespace policy 686 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/mock_policy_service.cc ('k') | chrome/browser/policy/proto/chromeos/chrome_device_policy.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698