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 "components/policy/core/common/cloud/cloud_policy_service.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 store_.policy_.reset(new em::PolicyData()); | 73 store_.policy_.reset(new em::PolicyData()); |
74 store_.policy_->set_request_token("fake token"); | 74 store_.policy_->set_request_token("fake token"); |
75 store_.policy_->set_device_id("fake client id"); | 75 store_.policy_->set_device_id("fake client id"); |
76 store_.policy_->set_timestamp(32); | 76 store_.policy_->set_timestamp(32); |
77 store_.policy_->set_valid_serial_number_missing(true); | 77 store_.policy_->set_valid_serial_number_missing(true); |
78 store_.policy_->set_public_key_version(17); | 78 store_.policy_->set_public_key_version(17); |
79 EXPECT_CALL(client_, | 79 EXPECT_CALL(client_, |
80 SetupRegistration(store_.policy_->request_token(), | 80 SetupRegistration(store_.policy_->request_token(), |
81 store_.policy_->device_id())).Times(1); | 81 store_.policy_->device_id())).Times(1); |
82 store_.NotifyStoreLoaded(); | 82 store_.NotifyStoreLoaded(); |
83 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMilliseconds(32), | 83 EXPECT_EQ(base::Time::FromJavaTime(32), client_.last_policy_timestamp_); |
84 client_.last_policy_timestamp_); | |
85 EXPECT_TRUE(client_.submit_machine_id_); | 84 EXPECT_TRUE(client_.submit_machine_id_); |
86 EXPECT_TRUE(client_.public_key_version_valid_); | 85 EXPECT_TRUE(client_.public_key_version_valid_); |
87 EXPECT_EQ(17, client_.public_key_version_); | 86 EXPECT_EQ(17, client_.public_key_version_); |
88 } | 87 } |
89 | 88 |
90 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { | 89 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { |
91 client_.SetStatus(DM_STATUS_REQUEST_FAILED); | 90 client_.SetStatus(DM_STATUS_REQUEST_FAILED); |
92 EXPECT_CALL(store_, Store(_)).Times(0); | 91 EXPECT_CALL(store_, Store(_)).Times(0); |
93 client_.NotifyPolicyFetched(); | 92 client_.NotifyPolicyFetched(); |
94 } | 93 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 testing::Mock::VerifyAndClearExpectations(&observer); | 273 testing::Mock::VerifyAndClearExpectations(&observer); |
275 | 274 |
276 // Now, the next time the store is loaded, the observer should not be called | 275 // Now, the next time the store is loaded, the observer should not be called |
277 // again. | 276 // again. |
278 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); | 277 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); |
279 store_.NotifyStoreLoaded(); | 278 store_.NotifyStoreLoaded(); |
280 service_.RemoveObserver(&observer); | 279 service_.RemoveObserver(&observer); |
281 } | 280 } |
282 | 281 |
283 } // namespace policy | 282 } // namespace policy |
OLD | NEW |