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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 | 77 |
78 class AsyncPolicyProviderTest : public testing::Test { | 78 class AsyncPolicyProviderTest : public testing::Test { |
79 protected: | 79 protected: |
80 AsyncPolicyProviderTest(); | 80 AsyncPolicyProviderTest(); |
81 virtual ~AsyncPolicyProviderTest(); | 81 virtual ~AsyncPolicyProviderTest(); |
82 | 82 |
83 virtual void SetUp() OVERRIDE; | 83 virtual void SetUp() OVERRIDE; |
84 virtual void TearDown() OVERRIDE; | 84 virtual void TearDown() OVERRIDE; |
85 | 85 |
86 base::MessageLoop loop_; | 86 base::MessageLoop loop_; |
87 SchemaRegistry schema_registry_; | |
bartfab (slow)
2013/11/05 15:53:04
Nit: #include "chrome/browser/policy/schema_regist
Joao da Silva
2013/11/07 13:15:00
Done.
| |
87 PolicyBundle initial_bundle_; | 88 PolicyBundle initial_bundle_; |
88 MockPolicyLoader* loader_; | 89 MockPolicyLoader* loader_; |
89 scoped_ptr<AsyncPolicyProvider> provider_; | 90 scoped_ptr<AsyncPolicyProvider> provider_; |
90 | 91 |
91 private: | 92 private: |
92 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); | 93 DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProviderTest); |
93 }; | 94 }; |
94 | 95 |
95 AsyncPolicyProviderTest::AsyncPolicyProviderTest() {} | 96 AsyncPolicyProviderTest::AsyncPolicyProviderTest() {} |
96 | 97 |
97 AsyncPolicyProviderTest::~AsyncPolicyProviderTest() {} | 98 AsyncPolicyProviderTest::~AsyncPolicyProviderTest() {} |
98 | 99 |
99 void AsyncPolicyProviderTest::SetUp() { | 100 void AsyncPolicyProviderTest::SetUp() { |
100 SetPolicy(&initial_bundle_, "policy", "initial"); | 101 SetPolicy(&initial_bundle_, "policy", "initial"); |
101 loader_ = new MockPolicyLoader(loop_.message_loop_proxy()); | 102 loader_ = new MockPolicyLoader(loop_.message_loop_proxy()); |
102 EXPECT_CALL(*loader_, LastModificationTime()) | 103 EXPECT_CALL(*loader_, LastModificationTime()) |
103 .WillRepeatedly(Return(base::Time())); | 104 .WillRepeatedly(Return(base::Time())); |
104 EXPECT_CALL(*loader_, InitOnBackgroundThread()).Times(1); | 105 EXPECT_CALL(*loader_, InitOnBackgroundThread()).Times(1); |
105 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); | 106 EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_)); |
106 | 107 |
107 provider_.reset( | 108 provider_.reset(new AsyncPolicyProvider( |
108 new AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader>(loader_))); | 109 &schema_registry_, scoped_ptr<AsyncPolicyLoader>(loader_))); |
109 provider_->Init(); | 110 provider_->Init(&schema_registry_); |
110 // Verify that the initial load is done synchronously: | 111 // Verify that the initial load is done synchronously: |
111 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); | 112 EXPECT_TRUE(provider_->policies().Equals(initial_bundle_)); |
112 | 113 |
113 loop_.RunUntilIdle(); | 114 loop_.RunUntilIdle(); |
114 Mock::VerifyAndClearExpectations(loader_); | 115 Mock::VerifyAndClearExpectations(loader_); |
115 | 116 |
116 EXPECT_CALL(*loader_, LastModificationTime()) | 117 EXPECT_CALL(*loader_, LastModificationTime()) |
117 .WillRepeatedly(Return(base::Time())); | 118 .WillRepeatedly(Return(base::Time())); |
118 } | 119 } |
119 | 120 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); | 218 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); |
218 provider_->Shutdown(); | 219 provider_->Shutdown(); |
219 loop_.RunUntilIdle(); | 220 loop_.RunUntilIdle(); |
220 Mock::VerifyAndClearExpectations(&observer); | 221 Mock::VerifyAndClearExpectations(&observer); |
221 | 222 |
222 provider_->RemoveObserver(&observer); | 223 provider_->RemoveObserver(&observer); |
223 provider_.reset(); | 224 provider_.reset(); |
224 } | 225 } |
225 | 226 |
226 } // namespace policy | 227 } // namespace policy |
OLD | NEW |