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

Side by Side Diff: chrome/browser/policy/enterprise_metrics_browsertest.cc

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Fixed small bugs. Rebased to ToT. Created 9 years 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) 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/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 689
690 void ExpectInstallAttributes() { 690 void ExpectInstallAttributes() {
691 install_attributes_.ExpectUsage(); 691 install_attributes_.ExpectUsage();
692 } 692 }
693 693
694 void ExpectMockSignedSettings(chromeos::SignedSettings::ReturnCode code, 694 void ExpectMockSignedSettings(chromeos::SignedSettings::ReturnCode code,
695 int expected_retrieves) { 695 int expected_retrieves) {
696 install_attributes_.ExpectUsage(); 696 install_attributes_.ExpectUsage();
697 EXPECT_CALL(mock_signed_settings_helper_, StartStorePolicyOp(_, _)) 697 EXPECT_CALL(mock_signed_settings_helper_, StartStorePolicyOp(_, _))
698 .WillOnce(MockSignedSettingsHelperStorePolicy(code)); 698 .WillOnce(MockSignedSettingsHelperStorePolicy(code));
699 EXPECT_CALL(mock_signed_settings_helper_, CancelCallback(_))
700 .Times(1)
701 .RetiresOnSaturation();
702 EXPECT_CALL(mock_signed_settings_helper_, 699 EXPECT_CALL(mock_signed_settings_helper_,
703 StartRetrievePolicyOp(_)).Times(expected_retrieves); 700 StartRetrievePolicyOp(_)).Times(expected_retrieves);
704 } 701 }
705 702
706 const em::PolicyFetchResponse& response() { 703 const em::PolicyFetchResponse& response() {
707 return response_; 704 return response_;
708 } 705 }
709 706
710 private: 707 private:
711 void Init() { 708 void Init() {
712 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); 709 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies());
713 device_policy_cache_.reset(new DevicePolicyCache(data_store_.get(), 710 device_policy_cache_.reset(new DevicePolicyCache(data_store_.get(),
714 install_attributes_.install_attributes(), 711 install_attributes_.install_attributes(),
715 &mock_signed_settings_helper_)); 712 &mock_signed_settings_helper_));
716 data_store_->SetupForTesting("", "id", "user", "gaia_token", false); 713 data_store_->SetupForTesting("", "id", "user", "gaia_token", false);
717 EXPECT_CALL(mock_signed_settings_helper_, CancelCallback(_)).Times(1);
718 } 714 }
719 715
720 chromeos::MockSignedSettingsHelper mock_signed_settings_helper_; 716 chromeos::MockSignedSettingsHelper mock_signed_settings_helper_;
721 scoped_ptr<CloudPolicyDataStore> data_store_; 717 scoped_ptr<CloudPolicyDataStore> data_store_;
722 scoped_ptr<DevicePolicyCache> device_policy_cache_; 718 scoped_ptr<DevicePolicyCache> device_policy_cache_;
723 em::PolicyFetchResponse response_; 719 em::PolicyFetchResponse response_;
724 TestInstallAttributes install_attributes_; 720 TestInstallAttributes install_attributes_;
725 721
726 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper); 722 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper);
727 }; 723 };
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND); 858 helper.CompleteRetrieve(chromeos::SignedSettings::NOT_FOUND);
863 helper.SetData("\xff"); 859 helper.SetData("\xff");
864 helper.SetPolicy(); 860 helper.SetPolicy();
865 ExpectSample(kMetricPolicyFetchInvalidPolicy); 861 ExpectSample(kMetricPolicyFetchInvalidPolicy);
866 EXPECT_TRUE(CheckSamples()); 862 EXPECT_TRUE(CheckSamples());
867 } 863 }
868 864
869 #endif 865 #endif
870 866
871 } // namespace policy 867 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_policy_cache_unittest.cc ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698