| 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/cloud/cloud_policy_service.h" | 5 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 9 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
| 10 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h" | 10 #include "chrome/browser/policy/cloud/mock_cloud_policy_client.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Store reloads policy, callback gets triggered. | 111 // Store reloads policy, callback gets triggered. |
| 112 store_.policy_.reset(new em::PolicyData()); | 112 store_.policy_.reset(new em::PolicyData()); |
| 113 store_.policy_->set_request_token("token"); | 113 store_.policy_->set_request_token("token"); |
| 114 store_.policy_->set_device_id("device-id"); | 114 store_.policy_->set_device_id("device-id"); |
| 115 EXPECT_CALL(*this, OnPolicyRefresh(true)).Times(1); | 115 EXPECT_CALL(*this, OnPolicyRefresh(true)).Times(1); |
| 116 store_.NotifyStoreLoaded(); | 116 store_.NotifyStoreLoaded(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TEST_F(CloudPolicyServiceTest, RefreshPolicyNotRegistered) { | 119 TEST_F(CloudPolicyServiceTest, RefreshPolicyNotRegistered) { |
| 120 // Clear the token so the client is not registered. | 120 // Clear the token so the client is not registered. |
| 121 client_.SetDMToken(""); | 121 client_.SetDMToken(std::string()); |
| 122 | 122 |
| 123 EXPECT_CALL(client_, FetchPolicy()).Times(0); | 123 EXPECT_CALL(client_, FetchPolicy()).Times(0); |
| 124 EXPECT_CALL(*this, OnPolicyRefresh(false)).Times(1); | 124 EXPECT_CALL(*this, OnPolicyRefresh(false)).Times(1); |
| 125 service_.RefreshPolicy(base::Bind(&CloudPolicyServiceTest::OnPolicyRefresh, | 125 service_.RefreshPolicy(base::Bind(&CloudPolicyServiceTest::OnPolicyRefresh, |
| 126 base::Unretained(this))); | 126 base::Unretained(this))); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(CloudPolicyServiceTest, RefreshPolicyClientError) { | 129 TEST_F(CloudPolicyServiceTest, RefreshPolicyClientError) { |
| 130 testing::InSequence seq; | 130 testing::InSequence seq; |
| 131 | 131 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 testing::Mock::VerifyAndClearExpectations(&observer); | 228 testing::Mock::VerifyAndClearExpectations(&observer); |
| 229 | 229 |
| 230 // Now, the next time the store is loaded, the observer should not be called | 230 // Now, the next time the store is loaded, the observer should not be called |
| 231 // again. | 231 // again. |
| 232 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); | 232 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); |
| 233 store_.NotifyStoreLoaded(); | 233 store_.NotifyStoreLoaded(); |
| 234 service_.RemoveObserver(&observer); | 234 service_.RemoveObserver(&observer); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace policy | 237 } // namespace policy |
| OLD | NEW |