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

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

Issue 1400903002: Data reduction proxy enabled/disabled UMA for all platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for trybot components_unittests failure Created 5 years, 2 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
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 test_context_->RunUntilIdle(); 621 test_context_->RunUntilIdle();
622 histogram_tester.ExpectBucketCount( 622 histogram_tester.ExpectBucketCount(
623 kUMALoFiSessionState, 623 kUMALoFiSessionState,
624 DataReductionProxyService::LO_FI_SESSION_STATE_NOT_USED, 2); 624 DataReductionProxyService::LO_FI_SESSION_STATE_NOT_USED, 2);
625 625
626 // Total count should be equal to the number of sessions. 626 // Total count should be equal to the number of sessions.
627 histogram_tester.ExpectTotalCount( 627 histogram_tester.ExpectTotalCount(
628 kUMALoFiSessionState, settings_->lo_fi_consecutive_session_disables_ + 3); 628 kUMALoFiSessionState, settings_->lo_fi_consecutive_session_disables_ + 3);
629 } 629 }
630 630
631 TEST_F(DataReductionProxySettingsTest, TestSettingsEnabledStateHistograms) {
632 const char kUMAEnabledState[] = "DataReductionProxy.EnabledState";
633 base::HistogramTester histogram_tester;
634
635 settings_->InitPrefMembers();
636 settings_->data_reduction_proxy_service_->SetIOData(
637 test_context_->io_data()->GetWeakPtr());
638
639 // No settings state histograms should be recorded during startup
640 test_context_->RunUntilIdle();
641 scoped_ptr<base::HistogramSamples> samples(
642 histogram_tester.GetHistogramSamplesSinceCreation(kUMAEnabledState));
643 EXPECT_EQ(0, samples->TotalCount());
sclittle 2015/10/09 20:52:48 Could this be replaced with: histogram_tester.Exp
Raj 2015/10/10 01:51:47 Done.
644
645 settings_->SetDataReductionProxyEnabled(true);
646 test_context_->RunUntilIdle();
647 histogram_tester.ExpectBucketCount(
648 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_OFF_TO_ON, 1);
649 histogram_tester.ExpectBucketCount(
650 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_ON_TO_OFF, 0);
651
652 settings_->SetDataReductionProxyEnabled(false);
653 test_context_->RunUntilIdle();
654 histogram_tester.ExpectBucketCount(
655 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_OFF_TO_ON, 1);
656 histogram_tester.ExpectBucketCount(
657 kUMAEnabledState, DATA_REDUCTION_SETTINGS_ACTION_ON_TO_OFF, 1);
658 }
659
631 TEST_F(DataReductionProxySettingsTest, TestGetDailyContentLengths) { 660 TEST_F(DataReductionProxySettingsTest, TestGetDailyContentLengths) {
632 ContentLengthList result = 661 ContentLengthList result =
633 settings_->GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength); 662 settings_->GetDailyContentLengths(prefs::kDailyHttpOriginalContentLength);
634 663
635 ASSERT_FALSE(result.empty()); 664 ASSERT_FALSE(result.empty());
636 ASSERT_EQ(kNumDaysInHistory, result.size()); 665 ASSERT_EQ(kNumDaysInHistory, result.size());
637 666
638 for (size_t i = 0; i < kNumDaysInHistory; ++i) { 667 for (size_t i = 0; i < kNumDaysInHistory; ++i) {
639 long expected_length = 668 long expected_length =
640 static_cast<long>((kNumDaysInHistory - 1 - i) * 2); 669 static_cast<long>((kNumDaysInHistory - 1 - i) * 2);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 SyntheticFieldTrialRegistrationCallback, 747 SyntheticFieldTrialRegistrationCallback,
719 base::Unretained(this))); 748 base::Unretained(this)));
720 749
721 net::ProxyServer origin = 750 net::ProxyServer origin =
722 test_context_->config()->test_params()->proxies_for_http().front(); 751 test_context_->config()->test_params()->proxies_for_http().front();
723 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; 752 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i;
724 } 753 }
725 } 754 }
726 755
727 } // namespace data_reduction_proxy 756 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698