Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_service_unittest.cc

Issue 342233005: Move ownership of the ComponentCloudPolicyService to the broker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH, _)) 398 CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH, _))
399 .WillOnce(mock_device_management_service_.SucceedJob(response)); 399 .WillOnce(mock_device_management_service_.SucceedJob(response));
400 EXPECT_CALL(mock_device_management_service_, 400 EXPECT_CALL(mock_device_management_service_,
401 StartJob(dm_protocol::kValueRequestPolicy, 401 StartJob(dm_protocol::kValueRequestPolicy,
402 std::string(), std::string(), 402 std::string(), std::string(),
403 device_policy_.policy_data().request_token(), 403 device_policy_.policy_data().request_token(),
404 dm_protocol::kValueUserAffiliationManaged, 404 dm_protocol::kValueUserAffiliationManaged,
405 device_policy_.policy_data().device_id(), 405 device_policy_.policy_data().device_id(),
406 _)) 406 _))
407 .WillOnce(SaveArg<6>(&request)); 407 .WillOnce(SaveArg<6>(&request));
408 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)); 408 // This will be called twice, because the ComponentCloudPolicyService will
409 // also become ready after flushing all the pending tasks.
410 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)).Times(2);
409 broker->core()->client()->FetchPolicy(); 411 broker->core()->client()->FetchPolicy();
410 FlushDeviceSettings(); 412 FlushDeviceSettings();
411 Mock::VerifyAndClearExpectations(&service_observer_); 413 Mock::VerifyAndClearExpectations(&service_observer_);
412 Mock::VerifyAndClearExpectations(&mock_device_management_service_); 414 Mock::VerifyAndClearExpectations(&mock_device_management_service_);
413 EXPECT_TRUE(request.has_policy_request()); 415 EXPECT_TRUE(request.has_policy_request());
414 EXPECT_EQ(1, request.policy_request().request_size()); 416 EXPECT_EQ(1, request.policy_request().request_size());
415 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType, 417 EXPECT_EQ(dm_protocol::kChromePublicAccountPolicyType,
416 request.policy_request().request(0).policy_type()); 418 request.policy_request().request(0).policy_type());
417 EXPECT_FALSE(request.policy_request().request(0).has_machine_id()); 419 EXPECT_FALSE(request.policy_request().request(0).has_machine_id());
418 EXPECT_EQ(kAccount1, 420 EXPECT_EQ(kAccount1,
(...skipping 23 matching lines...) Expand all
442 service_->Connect(&mock_device_management_service_); 444 service_->Connect(&mock_device_management_service_);
443 ASSERT_TRUE(broker->core()->service()); 445 ASSERT_TRUE(broker->core()->service());
444 446
445 em::DeviceManagementResponse response; 447 em::DeviceManagementResponse response;
446 response.mutable_policy_response()->add_response()->CopyFrom( 448 response.mutable_policy_response()->add_response()->CopyFrom(
447 device_local_account_policy_.policy()); 449 device_local_account_policy_.policy());
448 EXPECT_CALL(mock_device_management_service_, CreateJob(_, _)) 450 EXPECT_CALL(mock_device_management_service_, CreateJob(_, _))
449 .WillOnce(mock_device_management_service_.SucceedJob(response)); 451 .WillOnce(mock_device_management_service_.SucceedJob(response));
450 EXPECT_CALL(mock_device_management_service_, StartJob(_, _, _, _, _, _, _)); 452 EXPECT_CALL(mock_device_management_service_, StartJob(_, _, _, _, _, _, _));
451 EXPECT_CALL(*this, OnRefreshDone(true)).Times(1); 453 EXPECT_CALL(*this, OnRefreshDone(true)).Times(1);
452 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)); 454 // This will be called twice, because the ComponentCloudPolicyService will
455 // also become ready after flushing all the pending tasks.
456 EXPECT_CALL(service_observer_, OnPolicyUpdated(account_1_user_id_)).Times(2);
453 broker->core()->service()->RefreshPolicy( 457 broker->core()->service()->RefreshPolicy(
454 base::Bind(&DeviceLocalAccountPolicyServiceTest::OnRefreshDone, 458 base::Bind(&DeviceLocalAccountPolicyServiceTest::OnRefreshDone,
455 base::Unretained(this))); 459 base::Unretained(this)));
456 FlushDeviceSettings(); 460 FlushDeviceSettings();
457 Mock::VerifyAndClearExpectations(&service_observer_); 461 Mock::VerifyAndClearExpectations(&service_observer_);
458 Mock::VerifyAndClearExpectations(this); 462 Mock::VerifyAndClearExpectations(this);
459 Mock::VerifyAndClearExpectations(&mock_device_management_service_); 463 Mock::VerifyAndClearExpectations(&mock_device_management_service_);
460 464
461 ASSERT_TRUE(broker->core()->store()); 465 ASSERT_TRUE(broker->core()->store());
462 EXPECT_EQ(CloudPolicyStore::STATUS_OK, 466 EXPECT_EQ(CloudPolicyStore::STATUS_OK,
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 em::DeviceManagementResponse response; 948 em::DeviceManagementResponse response;
945 device_local_account_policy_.Build(); 949 device_local_account_policy_.Build();
946 response.mutable_policy_response()->add_response()->CopyFrom( 950 response.mutable_policy_response()->add_response()->CopyFrom(
947 device_local_account_policy_.policy()); 951 device_local_account_policy_.policy());
948 request_job->SendResponse(DM_STATUS_SUCCESS, response); 952 request_job->SendResponse(DM_STATUS_SUCCESS, response);
949 FlushDeviceSettings(); 953 FlushDeviceSettings();
950 Mock::VerifyAndClearExpectations(&provider_observer_); 954 Mock::VerifyAndClearExpectations(&provider_observer_);
951 } 955 }
952 956
953 } // namespace policy 957 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698