Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/mock_configuration_policy_store.h" | 9 #include "chrome/browser/policy/mock_configuration_policy_store.h" |
| 10 #include "chrome/common/policy_constants.h" | 10 #include "chrome/common/policy_constants.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using ::testing::_; | 14 using ::testing::_; |
| 15 using ::testing::InSequence; | 15 using ::testing::InSequence; |
| 16 using ::testing::Return; | 16 using ::testing::Return; |
| 17 | 17 |
| 18 namespace policy { | 18 namespace policy { |
| 19 | 19 |
| 20 // Creating the provider should provide initial policy. | |
| 20 TEST_F(AsynchronousPolicyTestBase, Provide) { | 21 TEST_F(AsynchronousPolicyTestBase, Provide) { |
| 21 InSequence s; | 22 InSequence s; |
| 22 DictionaryValue* policies = new DictionaryValue(); | 23 DictionaryValue* policies = new DictionaryValue(); |
| 23 policies->SetBoolean(policy::key::kSyncDisabled, true); | 24 policies->SetBoolean(policy::key::kSyncDisabled, true); |
| 24 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(policies)); | 25 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(policies)); |
| 25 EXPECT_CALL(*store_, Apply(policy::kPolicySyncDisabled, _)).Times(1); | 26 EXPECT_CALL(*store_, Apply(policy::kPolicySyncDisabled, _)).Times(1); |
| 26 AsynchronousPolicyProvider provider( | 27 AsynchronousPolicyProvider provider( |
| 27 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | 28 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
| 28 new AsynchronousPolicyLoader(delegate_.release())); | 29 new AsynchronousPolicyLoader(delegate_.release(), 10)); |
| 29 provider.Provide(store_.get()); | 30 provider.Provide(store_.get()); |
| 30 } | 31 } |
| 31 | 32 |
| 33 | |
| 34 // Trigger a refresh manually and ensure that policy gets reloaded. | |
| 32 TEST_F(AsynchronousPolicyTestBase, ProvideAfterRefresh) { | 35 TEST_F(AsynchronousPolicyTestBase, ProvideAfterRefresh) { |
| 33 InSequence s; | 36 InSequence s; |
| 34 DictionaryValue* original_policies = new DictionaryValue(); | 37 DictionaryValue* original_policies = new DictionaryValue(); |
| 35 original_policies->SetBoolean(policy::key::kSyncDisabled, true); | 38 original_policies->SetBoolean(policy::key::kSyncDisabled, true); |
| 36 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(original_policies)); | 39 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(original_policies)); |
| 37 DictionaryValue* refresh_policies = new DictionaryValue(); | 40 DictionaryValue* refresh_policies = new DictionaryValue(); |
| 38 refresh_policies->SetBoolean( | 41 refresh_policies->SetBoolean( |
| 39 policy::key::kJavascriptEnabled, | 42 policy::key::kJavascriptEnabled, |
| 40 true); | 43 true); |
| 41 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(refresh_policies)); | 44 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(refresh_policies)); |
| 42 AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader( | 45 AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader( |
| 43 delegate_.release()); | 46 delegate_.release(), |
| 47 10); | |
|
Mattias Nissler (ping if slow)
2010/12/21 16:42:24
Linebreak after = and all arguments on the same li
danno
2010/12/22 11:02:17
Done.
| |
| 44 AsynchronousPolicyProvider provider( | 48 AsynchronousPolicyProvider provider( |
| 45 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), | 49 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
| 46 loader); | 50 loader); |
| 47 loop_.RunAllPending(); | 51 loop_.RunAllPending(); |
| 48 loader->Reload(); | 52 loader->Reload(); |
| 49 loop_.RunAllPending(); | 53 loop_.RunAllPending(); |
| 50 EXPECT_CALL(*store_, Apply(policy::kPolicyJavascriptEnabled, _)).Times(1); | 54 EXPECT_CALL(*store_, Apply(policy::kPolicyJavascriptEnabled, _)).Times(1); |
| 51 provider.Provide(store_.get()); | 55 provider.Provide(store_.get()); |
| 52 } | 56 } |
| 53 | 57 |
| 54 } // namespace policy | 58 } // namespace policy |
| OLD | NEW |