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

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

Issue 12189011: Split up chrome/browser/policy subdirectory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, add chrome/browser/chromeos/policy/OWNERS Created 7 years, 9 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
« no previous file with comments | « chrome/browser/policy/proxy_policy_provider.cc ('k') | chrome/browser/policy/rate_limiter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
7 #include "chrome/browser/policy/proxy_policy_provider.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 using testing::Mock;
12
13 namespace policy {
14
15 class ProxyPolicyProviderTest : public testing::Test {
16 protected:
17 ProxyPolicyProviderTest() {
18 mock_provider_.Init();
19 proxy_provider_.Init();
20 proxy_provider_.AddObserver(&observer_);
21 }
22
23 virtual ~ProxyPolicyProviderTest() {
24 proxy_provider_.RemoveObserver(&observer_);
25 proxy_provider_.Shutdown();
26 mock_provider_.Shutdown();
27 }
28
29 MockConfigurationPolicyObserver observer_;
30 MockConfigurationPolicyProvider mock_provider_;
31 ProxyPolicyProvider proxy_provider_;
32
33 static scoped_ptr<PolicyBundle> CopyBundle(const PolicyBundle& bundle) {
34 scoped_ptr<PolicyBundle> copy(new PolicyBundle());
35 copy->CopyFrom(bundle);
36 return copy.Pass();
37 }
38
39 DISALLOW_COPY_AND_ASSIGN(ProxyPolicyProviderTest);
40 };
41
42 TEST_F(ProxyPolicyProviderTest, Init) {
43 EXPECT_TRUE(proxy_provider_.IsInitializationComplete(POLICY_DOMAIN_CHROME));
44 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
45 }
46
47 TEST_F(ProxyPolicyProviderTest, Delegate) {
48 PolicyBundle bundle;
49 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
50 .Set("policy",
51 POLICY_LEVEL_MANDATORY,
52 POLICY_SCOPE_USER,
53 Value::CreateStringValue("value"));
54 mock_provider_.UpdatePolicy(CopyBundle(bundle));
55
56 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
57 proxy_provider_.SetDelegate(&mock_provider_);
58 Mock::VerifyAndClearExpectations(&observer_);
59 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
60
61 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
62 bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
63 .Set("policy",
64 POLICY_LEVEL_MANDATORY,
65 POLICY_SCOPE_USER,
66 Value::CreateStringValue("new value"));
67 mock_provider_.UpdatePolicy(CopyBundle(bundle));
68 Mock::VerifyAndClearExpectations(&observer_);
69 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
70
71 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
72 proxy_provider_.SetDelegate(NULL);
73 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
74 }
75
76 TEST_F(ProxyPolicyProviderTest, RefreshPolicies) {
77 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
78 proxy_provider_.RefreshPolicies();
79 Mock::VerifyAndClearExpectations(&observer_);
80
81 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
82 proxy_provider_.SetDelegate(&mock_provider_);
83 Mock::VerifyAndClearExpectations(&observer_);
84
85 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)).Times(0);
86 EXPECT_CALL(mock_provider_, RefreshPolicies());
87 proxy_provider_.RefreshPolicies();
88 Mock::VerifyAndClearExpectations(&observer_);
89 Mock::VerifyAndClearExpectations(&mock_provider_);
90
91 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
92 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
93 Mock::VerifyAndClearExpectations(&observer_);
94 }
95
96 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/proxy_policy_provider.cc ('k') | chrome/browser/policy/rate_limiter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698