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

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

Issue 10449071: Enable user policy handling through the new cloud policy stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 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
(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 registrar_.Init(&proxy_provider_, &observer_);
19 }
20
21 MockConfigurationPolicyObserver observer_;
22 MockConfigurationPolicyProvider mock_provider_;
23 ProxyPolicyProvider proxy_provider_;
24 ConfigurationPolicyObserverRegistrar registrar_;
25
26 static scoped_ptr<PolicyBundle> CopyBundle(const PolicyBundle& bundle) {
27 scoped_ptr<PolicyBundle> copy(new PolicyBundle());
28 copy->CopyFrom(bundle);
29 return copy.Pass();
30 }
31
32 DISALLOW_COPY_AND_ASSIGN(ProxyPolicyProviderTest);
33 };
34
35 TEST_F(ProxyPolicyProviderTest, Init) {
36 EXPECT_TRUE(proxy_provider_.IsInitializationComplete());
37 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
38 }
39
40 TEST_F(ProxyPolicyProviderTest, Delegate) {
41 PolicyBundle bundle;
42 bundle.Get(POLICY_DOMAIN_CHROME, std::string())
43 .Set("policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
44 Value::CreateStringValue("value"));
45 mock_provider_.UpdatePolicy(CopyBundle(bundle));
46
47 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
48 proxy_provider_.SetDelegate(&mock_provider_);
49 Mock::VerifyAndClearExpectations(&observer_);
50 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
51
52 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
53 bundle.Get(POLICY_DOMAIN_CHROME, std::string())
54 .Set("policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
55 Value::CreateStringValue("new value"));
56 mock_provider_.UpdatePolicy(CopyBundle(bundle));
57 Mock::VerifyAndClearExpectations(&observer_);
58 EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
59
60 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
61 proxy_provider_.SetDelegate(NULL);
62 EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
63 }
64
65 TEST_F(ProxyPolicyProviderTest, RefreshPolicies) {
66 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
67 proxy_provider_.RefreshPolicies();
68 Mock::VerifyAndClearExpectations(&observer_);
69
70 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
71 proxy_provider_.SetDelegate(&mock_provider_);
72 Mock::VerifyAndClearExpectations(&observer_);
73
74 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)).Times(0);
75 EXPECT_CALL(mock_provider_, RefreshPolicies());
76 proxy_provider_.RefreshPolicies();
77 Mock::VerifyAndClearExpectations(&observer_);
78 Mock::VerifyAndClearExpectations(&mock_provider_);
79
80 EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
81 mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
82 Mock::VerifyAndClearExpectations(&observer_);
83 }
84
85 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/proxy_policy_provider.cc ('k') | chrome/browser/policy/user_cloud_policy_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698