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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/asynchronous_policy_loader.h" 5 #include "chrome/browser/policy/asynchronous_policy_loader.h"
6 #include "chrome/browser/policy/asynchronous_policy_provider.h" 6 #include "chrome/browser/policy/asynchronous_policy_provider.h"
7 #include "chrome/browser/policy/asynchronous_policy_test_base.h" 7 #include "chrome/browser/policy/asynchronous_policy_test_base.h"
8 #include "chrome/browser/policy/configuration_policy_pref_store.h" 8 #include "chrome/browser/policy/configuration_policy_pref_store.h"
9 #include "chrome/browser/policy/configuration_policy_provider.h"
10 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
9 #include "chrome/browser/policy/policy_map.h" 11 #include "chrome/browser/policy/policy_map.h"
10 #include "policy/policy_constants.h" 12 #include "policy/policy_constants.h"
11 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 using ::testing::InSequence; 16 using ::testing::InSequence;
15 using ::testing::Return; 17 using ::testing::Return;
16 using ::testing::_; 18 using ::testing::_;
17 19
18 namespace policy { 20 namespace policy {
(...skipping 22 matching lines...) Expand all
41 original_policies->SetBoolean(policy::key::kSyncDisabled, true); 43 original_policies->SetBoolean(policy::key::kSyncDisabled, true);
42 ProviderDelegateMock* delegate = new ProviderDelegateMock(); 44 ProviderDelegateMock* delegate = new ProviderDelegateMock();
43 EXPECT_CALL(*delegate, Load()).WillOnce(Return(original_policies)); 45 EXPECT_CALL(*delegate, Load()).WillOnce(Return(original_policies));
44 DictionaryValue* refresh_policies = new DictionaryValue(); 46 DictionaryValue* refresh_policies = new DictionaryValue();
45 refresh_policies->SetBoolean( 47 refresh_policies->SetBoolean(
46 policy::key::kJavascriptEnabled, 48 policy::key::kJavascriptEnabled,
47 true); 49 true);
48 EXPECT_CALL(*delegate, Load()).WillOnce(Return(refresh_policies)); 50 EXPECT_CALL(*delegate, Load()).WillOnce(Return(refresh_policies));
49 AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader(delegate, 10); 51 AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader(delegate, 10);
50 AsynchronousPolicyProvider provider(GetChromePolicyDefinitionList(), loader); 52 AsynchronousPolicyProvider provider(GetChromePolicyDefinitionList(), loader);
51 loop_.RunAllPending(); 53
52 provider.ForceReload(); 54 // The original policies have been loaded.
53 PolicyMap policy_map; 55 PolicyMap policy_map;
54 provider.Provide(&policy_map); 56 provider.Provide(&policy_map);
57 EXPECT_EQ(1U, policy_map.size());
55 EXPECT_TRUE(policy_map.Get(policy::kPolicySyncDisabled)); 58 EXPECT_TRUE(policy_map.Get(policy::kPolicySyncDisabled));
59 EXPECT_FALSE(policy_map.Get(policy::kPolicyJavascriptEnabled));
60
61 MockConfigurationPolicyObserver observer;
62 ConfigurationPolicyObserverRegistrar registrar;
63 registrar.Init(&provider, &observer);
64 EXPECT_CALL(observer, OnUpdatePolicy(&provider)).Times(1);
65 provider.RefreshPolicies();
66 loop_.RunAllPending();
67 // The refreshed policies are now provided.
68 policy_map.Clear();
69 provider.Provide(&policy_map);
56 EXPECT_EQ(1U, policy_map.size()); 70 EXPECT_EQ(1U, policy_map.size());
71 EXPECT_FALSE(policy_map.Get(policy::kPolicySyncDisabled));
72 EXPECT_TRUE(policy_map.Get(policy::kPolicyJavascriptEnabled));
57 } 73 }
58 74
59 } // namespace policy 75 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/asynchronous_policy_provider.cc ('k') | chrome/browser/policy/browser_policy_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698