| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "chrome/browser/policy/asynchronous_policy_loader.h" | 7 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
| 8 #include "chrome/browser/policy/asynchronous_policy_provider.h" | 8 #include "chrome/browser/policy/asynchronous_policy_provider.h" |
| 9 #include "chrome/browser/policy/asynchronous_policy_test_base.h" | 9 #include "chrome/browser/policy/asynchronous_policy_test_base.h" |
| 10 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 10 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 MockConfigurationPolicyObserver observer; | 113 MockConfigurationPolicyObserver observer; |
| 114 int dictionary_number_1 = 0; | 114 int dictionary_number_1 = 0; |
| 115 int dictionary_number_2 = 0; | 115 int dictionary_number_2 = 0; |
| 116 | 116 |
| 117 ProviderDelegateMock* delegate = new ProviderDelegateMock(); | 117 ProviderDelegateMock* delegate = new ProviderDelegateMock(); |
| 118 EXPECT_CALL(*delegate, Load()).WillOnce( | 118 EXPECT_CALL(*delegate, Load()).WillOnce( |
| 119 CreateSequencedTestDictionary(&dictionary_number_1)); | 119 CreateSequencedTestDictionary(&dictionary_number_1)); |
| 120 | 120 |
| 121 scoped_refptr<AsynchronousPolicyLoader> loader = | 121 scoped_refptr<AsynchronousPolicyLoader> loader = |
| 122 new AsynchronousPolicyLoader(delegate, 10); | 122 new AsynchronousPolicyLoader(delegate, 10); |
| 123 AsynchronousPolicyProvider provider(NULL, loader); | 123 AsynchronousPolicyProvider provider(NULL, |
| 124 POLICY_LEVEL_MANDATORY, |
| 125 POLICY_SCOPE_USER, |
| 126 loader); |
| 124 // |registrar| must be declared last so that it is destroyed first. | 127 // |registrar| must be declared last so that it is destroyed first. |
| 125 ConfigurationPolicyObserverRegistrar registrar; | 128 ConfigurationPolicyObserverRegistrar registrar; |
| 126 registrar.Init(&provider, &observer); | 129 registrar.Init(&provider, &observer); |
| 127 Mock::VerifyAndClearExpectations(delegate); | 130 Mock::VerifyAndClearExpectations(delegate); |
| 128 | 131 |
| 129 EXPECT_CALL(*delegate, Load()).WillOnce( | 132 EXPECT_CALL(*delegate, Load()).WillOnce( |
| 130 CreateSequencedTestDictionary(&dictionary_number_2)); | 133 CreateSequencedTestDictionary(&dictionary_number_2)); |
| 131 EXPECT_CALL(observer, OnUpdatePolicy(_)).Times(1); | 134 EXPECT_CALL(observer, OnUpdatePolicy(_)).Times(1); |
| 132 provider.RefreshPolicies(); | 135 provider.RefreshPolicies(); |
| 133 loop_.RunAllPending(); | 136 loop_.RunAllPending(); |
| 134 Mock::VerifyAndClearExpectations(delegate); | 137 Mock::VerifyAndClearExpectations(delegate); |
| 135 Mock::VerifyAndClearExpectations(&observer); | 138 Mock::VerifyAndClearExpectations(&observer); |
| 136 | 139 |
| 137 EXPECT_CALL(*delegate, Load()).WillOnce( | 140 EXPECT_CALL(*delegate, Load()).WillOnce( |
| 138 CreateSequencedTestDictionary(&dictionary_number_1)); | 141 CreateSequencedTestDictionary(&dictionary_number_1)); |
| 139 EXPECT_CALL(observer, OnUpdatePolicy(_)).Times(1); | 142 EXPECT_CALL(observer, OnUpdatePolicy(_)).Times(1); |
| 140 provider.RefreshPolicies(); | 143 provider.RefreshPolicies(); |
| 141 loop_.RunAllPending(); | 144 loop_.RunAllPending(); |
| 142 Mock::VerifyAndClearExpectations(delegate); | 145 Mock::VerifyAndClearExpectations(delegate); |
| 143 Mock::VerifyAndClearExpectations(&observer); | 146 Mock::VerifyAndClearExpectations(&observer); |
| 144 } | 147 } |
| 145 | 148 |
| 146 } // namespace policy | 149 } // namespace policy |
| OLD | NEW |