| OLD | NEW |
| 1 // Copyright (c) 2012 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 "chrome/browser/policy/async_policy_provider.h" | 5 #include "chrome/browser/policy/async_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/policy/async_policy_loader.h" | 9 #include "chrome/browser/policy/async_policy_loader.h" |
| 10 #include "chrome/browser/policy/mock_configuration_policy_provider.h" | 10 #include "chrome/browser/policy/mock_configuration_policy_provider.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 void AsyncPolicyProviderTest::SetUp() { | 96 void AsyncPolicyProviderTest::SetUp() { |
| 97 SetPolicy(&initial_bundle_, "policy", "initial"); | 97 SetPolicy(&initial_bundle_, "policy", "initial"); |
| 98 loader_ = new MockPolicyLoader(); | 98 loader_ = new MockPolicyLoader(); |
| 99 EXPECT_CALL(*loader_, LastModificationTime()) | 99 EXPECT_CALL(*loader_, LastModificationTime()) |
| 100 .WillRepeatedly(Return(base::Time())); | 100 .WillRepeatedly(Return(base::Time())); |
| 101 EXPECT_CALL(*loader_, InitOnFile()).Times(1); | 101 EXPECT_CALL(*loader_, InitOnFile()).Times(1); |
| 102 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); | 102 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); |
| 103 | 103 |
| 104 provider_.reset( | 104 provider_.reset( |
| 105 new AsyncPolicyProvider(GetChromePolicyDefinitionList(), | 105 new AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader>(loader_))); |
| 106 scoped_ptr<AsyncPolicyLoader>(loader_))); | |
| 107 // Verify that the initial load is done synchronously: | 106 // Verify that the initial load is done synchronously: |
| 108 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); | 107 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); |
| 109 | 108 |
| 110 loop_.RunAllPending(); | 109 loop_.RunAllPending(); |
| 111 Mock::VerifyAndClearExpectations(loader_); | 110 Mock::VerifyAndClearExpectations(loader_); |
| 112 | 111 |
| 113 EXPECT_CALL(*loader_, LastModificationTime()) | 112 EXPECT_CALL(*loader_, LastModificationTime()) |
| 114 .WillRepeatedly(Return(base::Time())); | 113 .WillRepeatedly(Return(base::Time())); |
| 115 } | 114 } |
| 116 | 115 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 Mock::VerifyAndClearExpectations(&observer); | 209 Mock::VerifyAndClearExpectations(&observer); |
| 211 | 210 |
| 212 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 211 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
| 213 EXPECT_CALL(observer, OnProviderGoingAway(provider_.get())); | 212 EXPECT_CALL(observer, OnProviderGoingAway(provider_.get())); |
| 214 provider_.reset(); | 213 provider_.reset(); |
| 215 loop_.RunAllPending(); | 214 loop_.RunAllPending(); |
| 216 Mock::VerifyAndClearExpectations(&observer); | 215 Mock::VerifyAndClearExpectations(&observer); |
| 217 } | 216 } |
| 218 | 217 |
| 219 } // namespace policy | 218 } // namespace policy |
| OLD | NEW |