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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove incorrect DCHECK from drp_statistics_prefs.cc Created 6 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 kDailyContentLengthUnknownWithDataReductionProxyEnabled); 76 kDailyContentLengthUnknownWithDataReductionProxyEnabled);
77 registry->RegisterListPref( 77 registry->RegisterListPref(
78 data_reduction_proxy::prefs:: 78 data_reduction_proxy::prefs::
79 kDailyOriginalContentLengthViaDataReductionProxy); 79 kDailyOriginalContentLengthViaDataReductionProxy);
80 registry->RegisterListPref( 80 registry->RegisterListPref(
81 data_reduction_proxy::prefs:: 81 data_reduction_proxy::prefs::
82 kDailyContentLengthViaDataReductionProxy); 82 kDailyContentLengthViaDataReductionProxy);
83 registry->RegisterInt64Pref( 83 registry->RegisterInt64Pref(
84 data_reduction_proxy::prefs:: 84 data_reduction_proxy::prefs::
85 kDailyHttpContentLengthLastUpdateDate, 0L); 85 kDailyHttpContentLengthLastUpdateDate, 0L);
86 registry->RegisterBooleanPref(
87 data_reduction_proxy::prefs::kDataReductionProxyEnabled, false);
86 } 88 }
87 89
88 TestingPrefServiceSimple pref_service_; 90 TestingPrefServiceSimple pref_service_;
89 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; 91 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_;
90 }; 92 };
91 93
92 TEST_F(ChromeNetworkDataSavingMetricsTest, TotalLengths) { 94 TEST_F(ChromeNetworkDataSavingMetricsTest, TotalLengths) {
93 const int64 kOriginalLength = 200; 95 const int64 kOriginalLength = 200;
94 const int64 kReceivedLength = 100; 96 const int64 kReceivedLength = 100;
95 97
96 UpdateContentLengthPrefs( 98 UpdateContentLengthPrefs(
97 kReceivedLength, kOriginalLength, 99 kReceivedLength, kOriginalLength,
98 false, UNKNOWN_TYPE, statistics_prefs_.get()); 100 &pref_service_, UNKNOWN_TYPE, statistics_prefs_.get());
101
99 EXPECT_EQ(kReceivedLength, 102 EXPECT_EQ(kReceivedLength,
100 statistics_prefs_->GetInt64( 103 statistics_prefs_->GetInt64(
101 data_reduction_proxy::prefs::kHttpReceivedContentLength)); 104 data_reduction_proxy::prefs::kHttpReceivedContentLength));
105 EXPECT_FALSE(pref_service_.GetBoolean(
106 data_reduction_proxy::prefs::kDataReductionProxyEnabled));
102 EXPECT_EQ(kOriginalLength, 107 EXPECT_EQ(kOriginalLength,
103 statistics_prefs_->GetInt64( 108 statistics_prefs_->GetInt64(
104 data_reduction_proxy::prefs::kHttpOriginalContentLength)); 109 data_reduction_proxy::prefs::kHttpOriginalContentLength));
105 110
106 // Record the same numbers again, and total lengths should be doubled. 111 // Record the same numbers again, and total lengths should be doubled.
107 UpdateContentLengthPrefs( 112 UpdateContentLengthPrefs(
108 kReceivedLength, kOriginalLength, 113 kReceivedLength, kOriginalLength,
109 false, UNKNOWN_TYPE, statistics_prefs_.get()); 114 &pref_service_, UNKNOWN_TYPE, statistics_prefs_.get());
115
110 EXPECT_EQ(kReceivedLength * 2, 116 EXPECT_EQ(kReceivedLength * 2,
111 statistics_prefs_->GetInt64( 117 statistics_prefs_->GetInt64(
112 data_reduction_proxy::prefs::kHttpReceivedContentLength)); 118 data_reduction_proxy::prefs::kHttpReceivedContentLength));
119 EXPECT_FALSE(pref_service_.GetBoolean(
120 data_reduction_proxy::prefs::kDataReductionProxyEnabled));
113 EXPECT_EQ(kOriginalLength * 2, 121 EXPECT_EQ(kOriginalLength * 2,
114 statistics_prefs_->GetInt64( 122 statistics_prefs_->GetInt64(
115 data_reduction_proxy::prefs::kHttpOriginalContentLength)); 123 data_reduction_proxy::prefs::kHttpOriginalContentLength));
116 } 124 }
117 125
118 // The initial last update time used in test. There is no leap second a few 126 // The initial last update time used in test. There is no leap second a few
119 // days around this time used in the test. 127 // days around this time used in the test.
120 // Note: No time zone is specified. Local time will be assumed by 128 // Note: No time zone is specified. Local time will be assumed by
121 // base::Time::FromString below. 129 // base::Time::FromString below.
122 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26"; 130 const char kLastUpdateTime[] = "Wed, 18 Sep 2013 03:45:26";
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 kReceivedLength, kOriginalLength, 685 kReceivedLength, kOriginalLength,
678 true, VIA_DATA_REDUCTION_PROXY, 686 true, VIA_DATA_REDUCTION_PROXY,
679 FakeNow(), statistics_prefs_.get()); 687 FakeNow(), statistics_prefs_.get());
680 VerifyDailyDataSavingContentLengthPrefLists( 688 VerifyDailyDataSavingContentLengthPrefLists(
681 original, 1, received, 1, 689 original, 1, received, 1,
682 original, 1, received, 1, 690 original, 1, received, 1,
683 original, 1, received, 1); 691 original, 1, received, 1);
684 } 692 }
685 693
686 } // namespace data_reduction_proxy 694 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698