| 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/device_local_account_policy_service.h" | 5 #include "chrome/browser/policy/device_local_account_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 "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 9 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 10 #include "chrome/browser/policy/cloud_policy_client.h" | 10 #include "chrome/browser/policy/cloud_policy_client.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 DeviceSettingsTestBase::TearDown(); | 66 DeviceSettingsTestBase::TearDown(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void InstallDevicePolicy() { | 69 void InstallDevicePolicy() { |
| 70 EXPECT_CALL(service_observer_, OnDeviceLocalAccountsChanged()); | 70 EXPECT_CALL(service_observer_, OnDeviceLocalAccountsChanged()); |
| 71 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); | 71 device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob()); |
| 72 ReloadDeviceSettings(); | 72 ReloadDeviceSettings(); |
| 73 Mock::VerifyAndClearExpectations(&service_observer_); | 73 Mock::VerifyAndClearExpectations(&service_observer_); |
| 74 } | 74 } |
| 75 | 75 |
| 76 MOCK_METHOD0(OnRefreshDone, void(void)); | 76 MOCK_METHOD1(OnRefreshDone, void(bool)); |
| 77 | 77 |
| 78 PolicyMap expected_policy_map_; | 78 PolicyMap expected_policy_map_; |
| 79 UserPolicyBuilder device_local_account_policy_; | 79 UserPolicyBuilder device_local_account_policy_; |
| 80 MockDeviceLocalAccountPolicyServiceObserver service_observer_; | 80 MockDeviceLocalAccountPolicyServiceObserver service_observer_; |
| 81 MockDeviceManagementService mock_device_management_service_; | 81 MockDeviceManagementService mock_device_management_service_; |
| 82 DeviceLocalAccountPolicyService service_; | 82 DeviceLocalAccountPolicyService service_; |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTest); | 85 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyServiceTest); |
| 86 }; | 86 }; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 ASSERT_TRUE(broker); | 276 ASSERT_TRUE(broker); |
| 277 | 277 |
| 278 service_.Connect(&mock_device_management_service_); | 278 service_.Connect(&mock_device_management_service_); |
| 279 | 279 |
| 280 em::DeviceManagementResponse response; | 280 em::DeviceManagementResponse response; |
| 281 response.mutable_policy_response()->add_response()->CopyFrom( | 281 response.mutable_policy_response()->add_response()->CopyFrom( |
| 282 device_local_account_policy_.policy()); | 282 device_local_account_policy_.policy()); |
| 283 EXPECT_CALL(mock_device_management_service_, CreateJob(_)) | 283 EXPECT_CALL(mock_device_management_service_, CreateJob(_)) |
| 284 .WillOnce(mock_device_management_service_.SucceedJob(response)); | 284 .WillOnce(mock_device_management_service_.SucceedJob(response)); |
| 285 EXPECT_CALL(mock_device_management_service_, StartJob(_, _, _, _, _, _, _)); | 285 EXPECT_CALL(mock_device_management_service_, StartJob(_, _, _, _, _, _, _)); |
| 286 EXPECT_CALL(*this, OnRefreshDone()).Times(1); | 286 EXPECT_CALL(*this, OnRefreshDone(true)).Times(1); |
| 287 EXPECT_CALL(service_observer_, OnPolicyUpdated(PolicyBuilder::kFakeUsername)); | 287 EXPECT_CALL(service_observer_, OnPolicyUpdated(PolicyBuilder::kFakeUsername)); |
| 288 broker->RefreshPolicy( | 288 broker->RefreshPolicy( |
| 289 base::Bind(&DeviceLocalAccountPolicyServiceTest::OnRefreshDone, | 289 base::Bind(&DeviceLocalAccountPolicyServiceTest::OnRefreshDone, |
| 290 base::Unretained(this))); | 290 base::Unretained(this))); |
| 291 FlushDeviceSettings(); | 291 FlushDeviceSettings(); |
| 292 Mock::VerifyAndClearExpectations(&service_observer_); | 292 Mock::VerifyAndClearExpectations(&service_observer_); |
| 293 Mock::VerifyAndClearExpectations(this); | 293 Mock::VerifyAndClearExpectations(this); |
| 294 Mock::VerifyAndClearExpectations(&mock_device_management_service_); | 294 Mock::VerifyAndClearExpectations(&mock_device_management_service_); |
| 295 | 295 |
| 296 ASSERT_TRUE(broker->store()); | 296 ASSERT_TRUE(broker->store()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 ASSERT_TRUE(request_job); | 447 ASSERT_TRUE(request_job); |
| 448 em::DeviceManagementResponse response; | 448 em::DeviceManagementResponse response; |
| 449 response.mutable_policy_response()->add_response()->CopyFrom( | 449 response.mutable_policy_response()->add_response()->CopyFrom( |
| 450 device_local_account_policy_.policy()); | 450 device_local_account_policy_.policy()); |
| 451 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 451 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
| 452 FlushDeviceSettings(); | 452 FlushDeviceSettings(); |
| 453 Mock::VerifyAndClearExpectations(&provider_observer_); | 453 Mock::VerifyAndClearExpectations(&provider_observer_); |
| 454 } | 454 } |
| 455 | 455 |
| 456 } // namespace policy | 456 } // namespace policy |
| OLD | NEW |