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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/proxy_policy_provider_unittest.cc
diff --git a/chrome/browser/policy/proxy_policy_provider_unittest.cc b/chrome/browser/policy/proxy_policy_provider_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e226efbfa1f466031594b2628e11e2a817df5d0
--- /dev/null
+++ b/chrome/browser/policy/proxy_policy_provider_unittest.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/basictypes.h"
+#include "chrome/browser/policy/mock_configuration_policy_provider.h"
+#include "chrome/browser/policy/proxy_policy_provider.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::Mock;
+
+namespace policy {
+
+class ProxyPolicyProviderTest : public testing::Test {
+ protected:
+ ProxyPolicyProviderTest() {
+ registrar_.Init(&proxy_provider_, &observer_);
+ }
+
+ MockConfigurationPolicyObserver observer_;
+ MockConfigurationPolicyProvider mock_provider_;
+ ProxyPolicyProvider proxy_provider_;
+ ConfigurationPolicyObserverRegistrar registrar_;
+
+ static scoped_ptr<PolicyBundle> CopyBundle(const PolicyBundle& bundle) {
+ scoped_ptr<PolicyBundle> copy(new PolicyBundle());
+ copy->CopyFrom(bundle);
+ return copy.Pass();
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(ProxyPolicyProviderTest);
+};
+
+TEST_F(ProxyPolicyProviderTest, Init) {
+ EXPECT_TRUE(proxy_provider_.IsInitializationComplete());
+ EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
+}
+
+TEST_F(ProxyPolicyProviderTest, Delegate) {
+ PolicyBundle bundle;
+ bundle.Get(POLICY_DOMAIN_CHROME, std::string())
+ .Set("policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ Value::CreateStringValue("value"));
+ mock_provider_.UpdatePolicy(CopyBundle(bundle));
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ proxy_provider_.SetDelegate(&mock_provider_);
+ Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ bundle.Get(POLICY_DOMAIN_CHROME, std::string())
+ .Set("policy", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ Value::CreateStringValue("new value"));
+ mock_provider_.UpdatePolicy(CopyBundle(bundle));
+ Mock::VerifyAndClearExpectations(&observer_);
+ EXPECT_TRUE(bundle.Equals(proxy_provider_.policies()));
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ proxy_provider_.SetDelegate(NULL);
+ EXPECT_TRUE(PolicyBundle().Equals(proxy_provider_.policies()));
+}
+
+TEST_F(ProxyPolicyProviderTest, RefreshPolicies) {
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ proxy_provider_.RefreshPolicies();
+ Mock::VerifyAndClearExpectations(&observer_);
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ proxy_provider_.SetDelegate(&mock_provider_);
+ Mock::VerifyAndClearExpectations(&observer_);
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_)).Times(0);
+ EXPECT_CALL(mock_provider_, RefreshPolicies());
+ proxy_provider_.RefreshPolicies();
+ Mock::VerifyAndClearExpectations(&observer_);
+ Mock::VerifyAndClearExpectations(&mock_provider_);
+
+ EXPECT_CALL(observer_, OnUpdatePolicy(&proxy_provider_));
+ mock_provider_.UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
+ Mock::VerifyAndClearExpectations(&observer_);
+}
+
+} // namespace policy
« 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