| OLD | NEW |
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
| 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" | 15 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_
names.h" |
| 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" | 16 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // TODO Make kNumDaysInHistory accessible from DataReductionProxySettings. | 21 // TODO Make kNumDaysInHistory accessible from DataReductionProxySettings. |
| 22 const size_t kNumDaysInHistory = 60; | 22 const size_t kNumDaysInHistory = 60; |
| 23 const int kWriteDelayMinutes = 60; | 23 const int kWriteDelayMinutes = 60; |
| 24 | 24 |
| 25 int64 GetListPrefInt64Value( | 25 int64 GetListPrefInt64Value( |
| 26 const base::ListValue& list_update, size_t index) { | 26 const base::ListValue& list_update, size_t index) { |
| 27 std::string string_value; | 27 std::string string_value; |
| 28 EXPECT_TRUE(list_update.GetString(index, &string_value)); | 28 EXPECT_TRUE(list_update.GetString(index, &string_value)); |
| 29 | 29 |
| 30 int64 value = 0; | 30 int64 value = 0; |
| 31 EXPECT_TRUE(base::StringToInt64(string_value, &value)); | 31 EXPECT_TRUE(base::StringToInt64(string_value, &value)); |
| 32 return value; | 32 return value; |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 namespace data_reduction_proxy { | 37 namespace data_reduction_proxy { |
| 38 | 38 |
| 39 class DataReductionProxyStatisticsPrefsTest : public testing::Test { | 39 class DataReductionProxyCompressionStatsTest : public testing::Test { |
| 40 protected: | 40 protected: |
| 41 DataReductionProxyStatisticsPrefsTest() | 41 DataReductionProxyCompressionStatsTest() |
| 42 : task_runner_(scoped_refptr<base::TestSimpleTaskRunner>( | 42 : task_runner_(scoped_refptr<base::TestSimpleTaskRunner>( |
| 43 new base::TestSimpleTaskRunner())) {} | 43 new base::TestSimpleTaskRunner())) {} |
| 44 | 44 |
| 45 void SetUp() override { RegisterPrefs(simple_pref_service_.registry()); } | 45 void SetUp() override { RegisterPrefs(simple_pref_service_.registry()); } |
| 46 | 46 |
| 47 void SetUpPrefs() { | 47 void SetUpPrefs() { |
| 48 CreatePrefList(prefs::kDailyHttpOriginalContentLength); | 48 CreatePrefList(prefs::kDailyHttpOriginalContentLength); |
| 49 CreatePrefList(prefs::kDailyHttpReceivedContentLength); | 49 CreatePrefList(prefs::kDailyHttpReceivedContentLength); |
| 50 | 50 |
| 51 const int64 kOriginalLength = 150; | 51 const int64 kOriginalLength = 150; |
| 52 const int64 kReceivedLength = 100; | 52 const int64 kReceivedLength = 100; |
| 53 | 53 |
| 54 statistics_prefs_->SetInt64( | 54 compression_stats_->SetInt64( |
| 55 prefs::kHttpOriginalContentLength, kOriginalLength); | 55 prefs::kHttpOriginalContentLength, kOriginalLength); |
| 56 statistics_prefs_->SetInt64( | 56 compression_stats_->SetInt64( |
| 57 prefs::kHttpReceivedContentLength, kReceivedLength); | 57 prefs::kHttpReceivedContentLength, kReceivedLength); |
| 58 | 58 |
| 59 base::ListValue* original_daily_content_length_list = | 59 base::ListValue* original_daily_content_length_list = |
| 60 statistics_prefs_->GetList(prefs::kDailyHttpOriginalContentLength); | 60 compression_stats_->GetList(prefs::kDailyHttpOriginalContentLength); |
| 61 base::ListValue* received_daily_content_length_list = | 61 base::ListValue* received_daily_content_length_list = |
| 62 statistics_prefs_->GetList(prefs::kDailyHttpReceivedContentLength); | 62 compression_stats_->GetList(prefs::kDailyHttpReceivedContentLength); |
| 63 | 63 |
| 64 for (size_t i = 0; i < kNumDaysInHistory; ++i) { | 64 for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
| 65 original_daily_content_length_list->Set( | 65 original_daily_content_length_list->Set( |
| 66 i, new base::StringValue(base::Int64ToString(i))); | 66 i, new base::StringValue(base::Int64ToString(i))); |
| 67 } | 67 } |
| 68 | 68 |
| 69 received_daily_content_length_list->Clear(); | 69 received_daily_content_length_list->Clear(); |
| 70 for (size_t i = 0; i < kNumDaysInHistory/2; ++i) { | 70 for (size_t i = 0; i < kNumDaysInHistory / 2; ++i) { |
| 71 received_daily_content_length_list->Set( | 71 received_daily_content_length_list->Set( |
| 72 i, new base::StringValue(base::Int64ToString(i))); | 72 i, new base::StringValue(base::Int64ToString(i))); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Create daily pref list of |kNumDaysInHistory| zero values. | 76 // Create daily pref list of |kNumDaysInHistory| zero values. |
| 77 void CreatePrefList(const char* pref) { | 77 void CreatePrefList(const char* pref) { |
| 78 base::ListValue* update = statistics_prefs_->GetList(pref); | 78 base::ListValue* update = compression_stats_->GetList(pref); |
| 79 update->Clear(); | 79 update->Clear(); |
| 80 for (size_t i = 0; i < kNumDaysInHistory; ++i) { | 80 for (size_t i = 0; i < kNumDaysInHistory; ++i) { |
| 81 update->Insert(0, new base::StringValue(base::Int64ToString(0))); | 81 update->Insert(0, new base::StringValue(base::Int64ToString(0))); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Verify the pref list values in |pref_service_| are equal to those in | 85 // Verify the pref list values in |pref_service_| are equal to those in |
| 86 // |simple_pref_service| for |pref|. | 86 // |simple_pref_service| for |pref|. |
| 87 void VerifyPrefListWasWritten(const char* pref) { | 87 void VerifyPrefListWasWritten(const char* pref) { |
| 88 const base::ListValue* delayed_list = statistics_prefs_->GetList(pref); | 88 const base::ListValue* delayed_list = compression_stats_->GetList(pref); |
| 89 const base::ListValue* written_list = simple_pref_service_.GetList(pref); | 89 const base::ListValue* written_list = simple_pref_service_.GetList(pref); |
| 90 ASSERT_EQ(delayed_list->GetSize(), written_list->GetSize()); | 90 ASSERT_EQ(delayed_list->GetSize(), written_list->GetSize()); |
| 91 size_t count = delayed_list->GetSize(); | 91 size_t count = delayed_list->GetSize(); |
| 92 | 92 |
| 93 for (size_t i = 0; i < count; ++i) { | 93 for (size_t i = 0; i < count; ++i) { |
| 94 EXPECT_EQ(GetListPrefInt64Value(*delayed_list, i), | 94 EXPECT_EQ(GetListPrefInt64Value(*delayed_list, i), |
| 95 GetListPrefInt64Value(*written_list, i)); | 95 GetListPrefInt64Value(*written_list, i)); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Verify the pref value in |pref_service_| are equal to that in | 99 // Verify the pref value in |pref_service_| are equal to that in |
| 100 // |simple_pref_service|. | 100 // |simple_pref_service|. |
| 101 void VerifyPrefWasWritten(const char* pref) { | 101 void VerifyPrefWasWritten(const char* pref) { |
| 102 int64 delayed_pref = statistics_prefs_->GetInt64(pref); | 102 int64 delayed_pref = compression_stats_->GetInt64(pref); |
| 103 int64 written_pref = simple_pref_service_.GetInt64(pref); | 103 int64 written_pref = simple_pref_service_.GetInt64(pref); |
| 104 EXPECT_EQ(delayed_pref, written_pref); | 104 EXPECT_EQ(delayed_pref, written_pref); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Verify the pref values in |dict| are equal to that in |statistics_prefs_|. | 107 // Verify the pref values in |dict| are equal to that in |compression_stats_|. |
| 108 void VerifyPrefs(base::DictionaryValue* dict) { | 108 void VerifyPrefs(base::DictionaryValue* dict) { |
| 109 base::string16 dict_pref_string; | 109 base::string16 dict_pref_string; |
| 110 int64 dict_pref; | 110 int64 dict_pref; |
| 111 int64 service_pref; | 111 int64 service_pref; |
| 112 | 112 |
| 113 dict->GetString("historic_original_content_length", &dict_pref_string); | 113 dict->GetString("historic_original_content_length", &dict_pref_string); |
| 114 base::StringToInt64(dict_pref_string, &dict_pref); | 114 base::StringToInt64(dict_pref_string, &dict_pref); |
| 115 service_pref = statistics_prefs_->GetInt64( | 115 service_pref = |
| 116 prefs::kHttpOriginalContentLength); | 116 compression_stats_->GetInt64(prefs::kHttpOriginalContentLength); |
| 117 EXPECT_EQ(service_pref, dict_pref); | 117 EXPECT_EQ(service_pref, dict_pref); |
| 118 | 118 |
| 119 dict->GetString("historic_received_content_length", &dict_pref_string); | 119 dict->GetString("historic_received_content_length", &dict_pref_string); |
| 120 base::StringToInt64(dict_pref_string, &dict_pref); | 120 base::StringToInt64(dict_pref_string, &dict_pref); |
| 121 service_pref = statistics_prefs_->GetInt64( | 121 service_pref = |
| 122 prefs::kHttpReceivedContentLength); | 122 compression_stats_->GetInt64(prefs::kHttpReceivedContentLength); |
| 123 EXPECT_EQ(service_pref, dict_pref); | 123 EXPECT_EQ(service_pref, dict_pref); |
| 124 } | 124 } |
| 125 | 125 |
| 126 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 126 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 127 TestingPrefServiceSimple simple_pref_service_; | 127 TestingPrefServiceSimple simple_pref_service_; |
| 128 scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; | 128 scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDirect) { | 131 TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDirect) { |
| 132 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 132 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 133 &simple_pref_service_, | 133 &simple_pref_service_, |
| 134 task_runner_, | 134 task_runner_, |
| 135 base::TimeDelta())); | 135 base::TimeDelta())); |
| 136 SetUpPrefs(); | 136 SetUpPrefs(); |
| 137 | 137 |
| 138 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); | 138 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); |
| 139 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); | 139 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); |
| 140 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); | 140 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); |
| 141 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); | 141 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); |
| 142 } | 142 } |
| 143 | 143 |
| 144 TEST_F(DataReductionProxyStatisticsPrefsTest, WritePrefsDelayed) { | 144 TEST_F(DataReductionProxyCompressionStatsTest, WritePrefsDelayed) { |
| 145 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 145 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 146 &simple_pref_service_, | 146 &simple_pref_service_, |
| 147 task_runner_, | 147 task_runner_, |
| 148 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); | 148 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); |
| 149 SetUpPrefs(); | 149 SetUpPrefs(); |
| 150 | 150 |
| 151 task_runner_->RunPendingTasks(); | 151 task_runner_->RunPendingTasks(); |
| 152 | 152 |
| 153 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); | 153 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); |
| 154 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); | 154 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); |
| 155 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); | 155 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); |
| 156 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); | 156 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST_F(DataReductionProxyStatisticsPrefsTest, | 159 TEST_F(DataReductionProxyCompressionStatsTest, |
| 160 WritePrefsOnUpdateDailyReceivedContentLengths) { | 160 WritePrefsOnUpdateDailyReceivedContentLengths) { |
| 161 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 161 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 162 &simple_pref_service_, | 162 &simple_pref_service_, |
| 163 task_runner_, | 163 task_runner_, |
| 164 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); | 164 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); |
| 165 SetUpPrefs(); | 165 SetUpPrefs(); |
| 166 | 166 |
| 167 simple_pref_service_.SetBoolean( | 167 simple_pref_service_.SetBoolean( |
| 168 prefs::kUpdateDailyReceivedContentLengths, true); | 168 prefs::kUpdateDailyReceivedContentLengths, true); |
| 169 | 169 |
| 170 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); | 170 VerifyPrefWasWritten(prefs::kHttpOriginalContentLength); |
| 171 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); | 171 VerifyPrefWasWritten(prefs::kHttpReceivedContentLength); |
| 172 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); | 172 VerifyPrefListWasWritten(prefs::kDailyHttpOriginalContentLength); |
| 173 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); | 173 VerifyPrefListWasWritten(prefs::kDailyHttpReceivedContentLength); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(DataReductionProxyStatisticsPrefsTest, | 176 TEST_F(DataReductionProxyCompressionStatsTest, |
| 177 HistoricNetworkStatsInfoToValue) { | 177 HistoricNetworkStatsInfoToValue) { |
| 178 const int64 kOriginalLength = 150; | 178 const int64 kOriginalLength = 150; |
| 179 const int64 kReceivedLength = 100; | 179 const int64 kReceivedLength = 100; |
| 180 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 180 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 181 &simple_pref_service_, | 181 &simple_pref_service_, |
| 182 task_runner_, | 182 task_runner_, |
| 183 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); | 183 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); |
| 184 | 184 |
| 185 base::DictionaryValue* dict = nullptr; | 185 base::DictionaryValue* dict = nullptr; |
| 186 scoped_ptr<base::Value> stats_value( | 186 scoped_ptr<base::Value> stats_value( |
| 187 statistics_prefs_->HistoricNetworkStatsInfoToValue()); | 187 compression_stats_->HistoricNetworkStatsInfoToValue()); |
| 188 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); | 188 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); |
| 189 VerifyPrefs(dict); | 189 VerifyPrefs(dict); |
| 190 | 190 |
| 191 statistics_prefs_->SetInt64(prefs::kHttpOriginalContentLength, | 191 compression_stats_->SetInt64(prefs::kHttpOriginalContentLength, |
| 192 kOriginalLength); | 192 kOriginalLength); |
| 193 statistics_prefs_->SetInt64(prefs::kHttpReceivedContentLength, | 193 compression_stats_->SetInt64(prefs::kHttpReceivedContentLength, |
| 194 kReceivedLength); | 194 kReceivedLength); |
| 195 | 195 |
| 196 stats_value.reset(statistics_prefs_->HistoricNetworkStatsInfoToValue()); | 196 stats_value.reset(compression_stats_->HistoricNetworkStatsInfoToValue()); |
| 197 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); | 197 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); |
| 198 VerifyPrefs(dict); | 198 VerifyPrefs(dict); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST_F(DataReductionProxyStatisticsPrefsTest, | 201 TEST_F(DataReductionProxyCompressionStatsTest, |
| 202 HistoricNetworkStatsInfoToValueDirect) { | 202 HistoricNetworkStatsInfoToValueDirect) { |
| 203 const int64 kOriginalLength = 150; | 203 const int64 kOriginalLength = 150; |
| 204 const int64 kReceivedLength = 100; | 204 const int64 kReceivedLength = 100; |
| 205 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 205 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 206 &simple_pref_service_, | 206 &simple_pref_service_, |
| 207 task_runner_, | 207 task_runner_, |
| 208 base::TimeDelta())); | 208 base::TimeDelta())); |
| 209 | 209 |
| 210 base::DictionaryValue* dict = nullptr; | 210 base::DictionaryValue* dict = nullptr; |
| 211 scoped_ptr<base::Value> stats_value( | 211 scoped_ptr<base::Value> stats_value( |
| 212 statistics_prefs_->HistoricNetworkStatsInfoToValue()); | 212 compression_stats_->HistoricNetworkStatsInfoToValue()); |
| 213 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); | 213 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); |
| 214 VerifyPrefs(dict); | 214 VerifyPrefs(dict); |
| 215 | 215 |
| 216 statistics_prefs_->SetInt64(prefs::kHttpOriginalContentLength, | 216 compression_stats_->SetInt64(prefs::kHttpOriginalContentLength, |
| 217 kOriginalLength); | 217 kOriginalLength); |
| 218 statistics_prefs_->SetInt64(prefs::kHttpReceivedContentLength, | 218 compression_stats_->SetInt64(prefs::kHttpReceivedContentLength, |
| 219 kReceivedLength); | 219 kReceivedLength); |
| 220 | 220 |
| 221 stats_value.reset(statistics_prefs_->HistoricNetworkStatsInfoToValue()); | 221 stats_value.reset(compression_stats_->HistoricNetworkStatsInfoToValue()); |
| 222 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); | 222 EXPECT_TRUE(stats_value->GetAsDictionary(&dict)); |
| 223 VerifyPrefs(dict); | 223 VerifyPrefs(dict); |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(DataReductionProxyStatisticsPrefsTest, | 226 TEST_F(DataReductionProxyCompressionStatsTest, |
| 227 ClearPrefsOnRestartEnabled) { | 227 ClearPrefsOnRestartEnabled) { |
| 228 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 228 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 229 command_line->AppendSwitch( | 229 command_line->AppendSwitch( |
| 230 data_reduction_proxy::switches::kClearDataReductionProxyDataSavings); | 230 data_reduction_proxy::switches::kClearDataReductionProxyDataSavings); |
| 231 | 231 |
| 232 base::ListValue list_value; | 232 base::ListValue list_value; |
| 233 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); | 233 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); |
| 234 simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); | 234 simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); |
| 235 | 235 |
| 236 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 236 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 237 &simple_pref_service_, | 237 &simple_pref_service_, |
| 238 task_runner_, | 238 task_runner_, |
| 239 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); | 239 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); |
| 240 | 240 |
| 241 const base::ListValue* value = simple_pref_service_.GetList( | 241 const base::ListValue* value = simple_pref_service_.GetList( |
| 242 prefs::kDailyHttpOriginalContentLength); | 242 prefs::kDailyHttpOriginalContentLength); |
| 243 EXPECT_EQ(0u, value->GetSize()); | 243 EXPECT_EQ(0u, value->GetSize()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(DataReductionProxyStatisticsPrefsTest, | 246 TEST_F(DataReductionProxyCompressionStatsTest, |
| 247 ClearPrefsOnRestartDisabled) { | 247 ClearPrefsOnRestartDisabled) { |
| 248 base::ListValue list_value; | 248 base::ListValue list_value; |
| 249 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); | 249 list_value.Insert(0, new base::StringValue(base::Int64ToString(1234))); |
| 250 simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); | 250 simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value); |
| 251 | 251 |
| 252 statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs( | 252 compression_stats_.reset(new DataReductionProxyCompressionStats( |
| 253 &simple_pref_service_, | 253 &simple_pref_service_, |
| 254 task_runner_, | 254 task_runner_, |
| 255 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); | 255 base::TimeDelta::FromMinutes(kWriteDelayMinutes))); |
| 256 | 256 |
| 257 const base::ListValue* value = simple_pref_service_.GetList( | 257 const base::ListValue* value = simple_pref_service_.GetList( |
| 258 prefs::kDailyHttpOriginalContentLength); | 258 prefs::kDailyHttpOriginalContentLength); |
| 259 std::string string_value; | 259 std::string string_value; |
| 260 value->GetString(0, &string_value); | 260 value->GetString(0, &string_value); |
| 261 EXPECT_EQ("1234", string_value); | 261 EXPECT_EQ("1234", string_value); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace data_reduction_proxy | 264 } // namespace data_reduction_proxy |
| OLD | NEW |