| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 | 688 |
| 689 void ExpectInstallAttributes() { | 689 void ExpectInstallAttributes() { |
| 690 install_attributes_.ExpectUsage(); | 690 install_attributes_.ExpectUsage(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 void ExpectMockSignedSettings(chromeos::SignedSettings::ReturnCode code, | 693 void ExpectMockSignedSettings(chromeos::SignedSettings::ReturnCode code, |
| 694 int expected_retrieves) { | 694 int expected_retrieves) { |
| 695 install_attributes_.ExpectUsage(); | 695 install_attributes_.ExpectUsage(); |
| 696 EXPECT_CALL(mock_signed_settings_helper_, StartStorePolicyOp(_, _)) | 696 EXPECT_CALL(mock_signed_settings_helper_, StartStorePolicyOp(_, _)) |
| 697 .WillOnce(MockSignedSettingsHelperStorePolicy(code)); | 697 .WillOnce(MockSignedSettingsHelperStorePolicy(code)); |
| 698 EXPECT_CALL(mock_signed_settings_helper_, CancelCallback(_)) | |
| 699 .Times(1) | |
| 700 .RetiresOnSaturation(); | |
| 701 EXPECT_CALL(mock_signed_settings_helper_, | 698 EXPECT_CALL(mock_signed_settings_helper_, |
| 702 StartRetrievePolicyOp(_)).Times(expected_retrieves); | 699 StartRetrievePolicyOp(_)).Times(expected_retrieves); |
| 703 } | 700 } |
| 704 | 701 |
| 705 const em::PolicyFetchResponse& response() { | 702 const em::PolicyFetchResponse& response() { |
| 706 return response_; | 703 return response_; |
| 707 } | 704 } |
| 708 | 705 |
| 709 private: | 706 private: |
| 710 void Init() { | 707 void Init() { |
| 711 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | 708 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); |
| 712 device_policy_cache_.reset(new DevicePolicyCache(data_store_.get(), | 709 device_policy_cache_.reset(new DevicePolicyCache(data_store_.get(), |
| 713 install_attributes_.install_attributes(), | 710 install_attributes_.install_attributes(), |
| 714 &mock_signed_settings_helper_)); | 711 &mock_signed_settings_helper_)); |
| 715 data_store_->SetupForTesting("", "id", "user", "gaia_token", false); | 712 data_store_->SetupForTesting("", "id", "user", "gaia_token", false); |
| 716 EXPECT_CALL(mock_signed_settings_helper_, CancelCallback(_)).Times(1); | |
| 717 } | 713 } |
| 718 | 714 |
| 719 chromeos::MockSignedSettingsHelper mock_signed_settings_helper_; | 715 chromeos::MockSignedSettingsHelper mock_signed_settings_helper_; |
| 720 scoped_ptr<CloudPolicyDataStore> data_store_; | 716 scoped_ptr<CloudPolicyDataStore> data_store_; |
| 721 scoped_ptr<DevicePolicyCache> device_policy_cache_; | 717 scoped_ptr<DevicePolicyCache> device_policy_cache_; |
| 722 em::PolicyFetchResponse response_; | 718 em::PolicyFetchResponse response_; |
| 723 TestInstallAttributes install_attributes_; | 719 TestInstallAttributes install_attributes_; |
| 724 | 720 |
| 725 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper); | 721 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper); |
| 726 }; | 722 }; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND); | 857 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND); |
| 862 helper.SetData("\xff"); | 858 helper.SetData("\xff"); |
| 863 helper.SetPolicy(); | 859 helper.SetPolicy(); |
| 864 ExpectSample(kMetricPolicyFetchInvalidPolicy); | 860 ExpectSample(kMetricPolicyFetchInvalidPolicy); |
| 865 EXPECT_TRUE(CheckSamples()); | 861 EXPECT_TRUE(CheckSamples()); |
| 866 } | 862 } |
| 867 | 863 |
| 868 #endif | 864 #endif |
| 869 | 865 |
| 870 } // namespace policy | 866 } // namespace policy |
| OLD | NEW |