| 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_client.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop/message_loop.h" | |
| 18 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" | 17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" |
| 19 #include "components/policy/core/common/cloud/mock_device_management_service.h" | 18 #include "components/policy/core/common/cloud/mock_device_management_service.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
| 22 #include "policy/proto/device_management_backend.pb.h" | 21 #include "policy/proto/device_management_backend.pb.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 24 |
| 26 using testing::ElementsAre; | 25 using testing::ElementsAre; |
| 27 using testing::Mock; | 26 using testing::Mock; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 154 |
| 156 void Register() { | 155 void Register() { |
| 157 EXPECT_CALL(observer_, OnRegistrationStateChanged(_)); | 156 EXPECT_CALL(observer_, OnRegistrationStateChanged(_)); |
| 158 client_->SetupRegistration(kDMToken, client_id_); | 157 client_->SetupRegistration(kDMToken, client_id_); |
| 159 } | 158 } |
| 160 | 159 |
| 161 void CreateClient(UserAffiliation user_affiliation) { | 160 void CreateClient(UserAffiliation user_affiliation) { |
| 162 if (client_.get()) | 161 if (client_.get()) |
| 163 client_->RemoveObserver(&observer_); | 162 client_->RemoveObserver(&observer_); |
| 164 | 163 |
| 165 request_context_ = new net::TestURLRequestContextGetter( | 164 request_context_ = |
| 166 loop_.message_loop_proxy()); | 165 new net::TestURLRequestContextGetter(loop_.task_runner()); |
| 167 client_.reset(new CloudPolicyClient(kMachineID, kMachineModel, | 166 client_.reset(new CloudPolicyClient(kMachineID, kMachineModel, |
| 168 kPolicyVerificationKeyHash, | 167 kPolicyVerificationKeyHash, |
| 169 user_affiliation, | 168 user_affiliation, |
| 170 &service_, | 169 &service_, |
| 171 request_context_)); | 170 request_context_)); |
| 172 client_->AddPolicyTypeToFetch(policy_type_, std::string()); | 171 client_->AddPolicyTypeToFetch(policy_type_, std::string()); |
| 173 client_->AddObserver(&observer_); | 172 client_->AddObserver(&observer_); |
| 174 } | 173 } |
| 175 | 174 |
| 176 void ExpectRegistration(const std::string& oauth_token) { | 175 void ExpectRegistration(const std::string& oauth_token) { |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1); | 858 EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1); |
| 860 | 859 |
| 861 CloudPolicyClient::StatusCallback callback = base::Bind( | 860 CloudPolicyClient::StatusCallback callback = base::Bind( |
| 862 &MockStatusCallbackObserver::OnCallbackComplete, | 861 &MockStatusCallbackObserver::OnCallbackComplete, |
| 863 base::Unretained(&callback_observer_)); | 862 base::Unretained(&callback_observer_)); |
| 864 client_->UpdateDeviceAttributes(kOAuthToken, kAssetId, kLocation, callback); | 863 client_->UpdateDeviceAttributes(kOAuthToken, kAssetId, kLocation, callback); |
| 865 EXPECT_EQ(DM_STATUS_SUCCESS, client_->status()); | 864 EXPECT_EQ(DM_STATUS_SUCCESS, client_->status()); |
| 866 } | 865 } |
| 867 | 866 |
| 868 } // namespace policy | 867 } // namespace policy |
| OLD | NEW |