Chromium Code Reviews| 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/chromeos/policy/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/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 "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 _)) | 406 _)) |
| 407 .WillOnce(SaveArg<6>(&request)); | 407 .WillOnce(SaveArg<6>(&request)); |
| 408 // This will be called twice, because the ComponentCloudPolicyService will | 408 // This will be called twice, because the ComponentCloudPolicyService will |
| 409 // also become ready after flushing all the pending tasks. | 409 // also become ready after flushing all the pending tasks. |
| 410 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)).Times(2); | 410 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)).Times(2); |
| 411 broker->core()->client()->FetchPolicy(); | 411 broker->core()->client()->FetchPolicy(); |
| 412 FlushDeviceSettings(); | 412 FlushDeviceSettings(); |
| 413 Mock::VerifyAndClearExpectations(&service_observer_); | 413 Mock::VerifyAndClearExpectations(&service_observer_); |
| 414 Mock::VerifyAndClearExpectations(&mock_device_management_service_); | 414 Mock::VerifyAndClearExpectations(&mock_device_management_service_); |
| 415 EXPECT_TRUE(request.has_policy_request()); | 415 EXPECT_TRUE(request.has_policy_request()); |
| 416 EXPECT_EQ(1, request.policy_request().request_size()); | 416 ASSERT_EQ(2, request.policy_request().request_size()); |
| 417 | |
| 418 const em::PolicyFetchRequest* public_account = | |
|
bartfab (slow)
2014/06/23 09:53:37
Nit: #include "policy/proto/device_management_back
Joao da Silva
2014/07/16 11:47:52
Done.
| |
| 419 &request.policy_request().request(0); | |
| 420 const em::PolicyFetchRequest* extensions = | |
| 421 &request.policy_request().request(1); | |
| 422 // The order is not guarateed. | |
| 423 if (extensions->policy_type() == | |
| 424 dm_protocol::kChromePublicAccountPolicyType) { | |
| 425 const em::PolicyFetchRequest* tmp = public_account; | |
|
bartfab (slow)
2014/06/23 09:53:37
Nit: Use std::swap() from <algorithm>
Joao da Silva
2014/07/16 11:47:52
Done.
| |
| 426 public_account = extensions; | |
| 427 extensions = tmp; | |
| 428 } | |
| 429 | |
| 417 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType, | 430 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType, |
| 418 request.policy_request().request(0).policy_type()); | 431 public_account->policy_type()); |
| 419 EXPECT_FALSE(request.policy_request().request(0).has_machine_id()); | 432 EXPECT_FALSE(public_account->has_machine_id()); |
| 420 EXPECT_EQ(kAccount1, | 433 EXPECT_EQ(kAccount1, public_account->settings_entity_id()); |
| 421 request.policy_request().request(0).settings_entity_id()); | 434 |
| 435 EXPECT_EQ(dm_protocol::kChromeExtensionPolicyType, | |
| 436 extensions->policy_type()); | |
| 437 EXPECT_FALSE(extensions->has_machine_id()); | |
| 438 EXPECT_FALSE(extensions->has_settings_entity_id()); | |
| 422 | 439 |
| 423 ASSERT_TRUE(broker->core()->store()); | 440 ASSERT_TRUE(broker->core()->store()); |
| 424 EXPECT_EQ(CloudPolicyStore::STATUS_OK, | 441 EXPECT_EQ(CloudPolicyStore::STATUS_OK, |
| 425 broker->core()->store()->status()); | 442 broker->core()->store()->status()); |
| 426 ASSERT_TRUE(broker->core()->store()->policy()); | 443 ASSERT_TRUE(broker->core()->store()->policy()); |
| 427 EXPECT_EQ(device_local_account_policy_.policy_data().SerializeAsString(), | 444 EXPECT_EQ(device_local_account_policy_.policy_data().SerializeAsString(), |
| 428 broker->core()->store()->policy()->SerializeAsString()); | 445 broker->core()->store()->policy()->SerializeAsString()); |
| 429 EXPECT_TRUE(expected_policy_map_.Equals( | 446 EXPECT_TRUE(expected_policy_map_.Equals( |
| 430 broker->core()->store()->policy_map())); | 447 broker->core()->store()->policy_map())); |
| 431 EXPECT_TRUE(service_->IsPolicyAvailableForUser(account_1_user_id_)); | 448 EXPECT_TRUE(service_->IsPolicyAvailableForUser(account_1_user_id_)); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 em::DeviceManagementResponse response; | 965 em::DeviceManagementResponse response; |
| 949 device_local_account_policy_.Build(); | 966 device_local_account_policy_.Build(); |
| 950 response.mutable_policy_response()->add_response()->CopyFrom( | 967 response.mutable_policy_response()->add_response()->CopyFrom( |
| 951 device_local_account_policy_.policy()); | 968 device_local_account_policy_.policy()); |
| 952 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 969 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
| 953 FlushDeviceSettings(); | 970 FlushDeviceSettings(); |
| 954 Mock::VerifyAndClearExpectations(&provider_observer_); | 971 Mock::VerifyAndClearExpectations(&provider_observer_); |
| 955 } | 972 } |
| 956 | 973 |
| 957 } // namespace policy | 974 } // namespace policy |
| OLD | NEW |