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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc

Issue 2546273002: Record DRP histogram on how long back savings were cleared (Closed)
Patch Set: Rebased Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 // Simulate Chromium startup with data reduction proxy already enabled. 725 // Simulate Chromium startup with data reduction proxy already enabled.
726 settings_->spdy_proxy_auth_enabled_.SetValue(true); 726 settings_->spdy_proxy_auth_enabled_.SetValue(true);
727 settings_->MaybeActivateDataReductionProxy(true /* at_startup */); 727 settings_->MaybeActivateDataReductionProxy(true /* at_startup */);
728 test_context_->RunUntilIdle(); 728 test_context_->RunUntilIdle();
729 histogram_tester.ExpectTotalCount("DataReductionProxy.DaysSinceEnabled", 0); 729 histogram_tester.ExpectTotalCount("DataReductionProxy.DaysSinceEnabled", 0);
730 EXPECT_EQ(0, test_context_->pref_service()->GetInt64( 730 EXPECT_EQ(0, test_context_->pref_service()->GetInt64(
731 prefs::kDataReductionProxyLastEnabledTime)); 731 prefs::kDataReductionProxyLastEnabledTime));
732 } 732 }
733 733
734 TEST_F(DataReductionProxySettingsTest, TestDaysSinceSavingsCleared) {
735 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock());
736 base::SimpleTestClock* clock_ptr = clock.get();
737 clock_ptr->Advance(base::TimeDelta::FromDays(1));
738 ResetSettings(std::move(clock), true, true, false, false);
739
740 InitPrefMembers();
741 base::HistogramTester histogram_tester;
742 test_context_->pref_service()->SetInt64(
743 prefs::kDataReductionProxySavingsClearedNegativeSystemClock,
744 clock_ptr->Now().ToInternalValue());
745
746 settings_->data_reduction_proxy_service_->SetIOData(
747 test_context_->io_data()->GetWeakPtr());
748 test_context_->RunUntilIdle();
749
750 clock_ptr->Advance(base::TimeDelta::FromDays(100));
751
752 // Simulate Chromium startup with data reduction proxy already enabled.
753 settings_->spdy_proxy_auth_enabled_.SetValue(true);
754 settings_->MaybeActivateDataReductionProxy(true /* at_startup */);
755 test_context_->RunUntilIdle();
756 histogram_tester.ExpectUniqueSample(
757 "DataReductionProxy.DaysSinceSavingsCleared.NegativeSystemClock", 100, 1);
758 }
759
734 TEST_F(DataReductionProxySettingsTest, TestGetDailyContentLengths) { 760 TEST_F(DataReductionProxySettingsTest, TestGetDailyContentLengths) {
735 ContentLengthList result = 761 ContentLengthList result =
736 settings_->GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength); 762 settings_->GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength);
737 763
738 ASSERT_FALSE(result.empty()); 764 ASSERT_FALSE(result.empty());
739 ASSERT_EQ(kNumDaysInHistory, result.size()); 765 ASSERT_EQ(kNumDaysInHistory, result.size());
740 766
741 for (size_t i = 0; i < kNumDaysInHistory; ++i) { 767 for (size_t i = 0; i < kNumDaysInHistory; ++i) {
742 long expected_length = 768 long expected_length =
743 static_cast<long>((kNumDaysInHistory - 1 - i) * 2); 769 static_cast<long>((kNumDaysInHistory - 1 - i) * 2);
(...skipping 18 matching lines...) Expand all
762 test_context_->CreateDataReductionProxyService(settings_.get())); 788 test_context_->CreateDataReductionProxyService(settings_.get()));
763 settings_->SetCallbackToRegisterSyntheticFieldTrial( 789 settings_->SetCallbackToRegisterSyntheticFieldTrial(
764 base::Bind(&DataReductionProxySettingsTestBase:: 790 base::Bind(&DataReductionProxySettingsTestBase::
765 SyntheticFieldTrialRegistrationCallback, 791 SyntheticFieldTrialRegistrationCallback,
766 base::Unretained(this))); 792 base::Unretained(this)));
767 793
768 test_context_->RunUntilIdle(); 794 test_context_->RunUntilIdle();
769 } 795 }
770 796
771 } // namespace data_reduction_proxy 797 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698