| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc
|
| index 3629386e02f59b53730d0c6ffa6e99641038113e..e9a5338c84caf64d4a4a6af129491d9dc9d19207 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc
|
| @@ -226,17 +226,20 @@ class DataReductionProxyCompressionStatsTest : public testing::Test {
|
| // Verify the pref list values are equal to the given values.
|
| // If the count of values is less than kNumDaysInHistory, zeros are assumed
|
| // at the beginning.
|
| - void VerifyPrefList(const char* pref, const int64_t* values, size_t count) {
|
| - ASSERT_GE(kNumDaysInHistory, count);
|
| + void VerifyPrefList(const char* pref,
|
| + const int64_t* values,
|
| + size_t count,
|
| + size_t num_days_in_history) {
|
| + ASSERT_GE(num_days_in_history, count);
|
| base::ListValue* update = compression_stats_->GetList(pref);
|
| - ASSERT_EQ(kNumDaysInHistory, update->GetSize()) << "Pref: " << pref;
|
| + ASSERT_EQ(num_days_in_history, update->GetSize()) << "Pref: " << pref;
|
|
|
| for (size_t i = 0; i < count; ++i) {
|
| EXPECT_EQ(values[i],
|
| - GetListPrefInt64Value(*update, kNumDaysInHistory - count + i))
|
| - << pref << "; index=" << (kNumDaysInHistory - count + i);
|
| + GetListPrefInt64Value(*update, num_days_in_history - count + i))
|
| + << pref << "; index=" << (num_days_in_history - count + i);
|
| }
|
| - for (size_t i = 0; i < kNumDaysInHistory - count; ++i) {
|
| + for (size_t i = 0; i < num_days_in_history - count; ++i) {
|
| EXPECT_EQ(0, GetListPrefInt64Value(*update, i)) << "index=" << i;
|
| }
|
| }
|
| @@ -259,31 +262,31 @@ class DataReductionProxyCompressionStatsTest : public testing::Test {
|
| const int64_t* original_via_data_reduction_proxy_values,
|
| size_t original_via_data_reduction_proxy_count,
|
| const int64_t* received_via_data_reduction_proxy_values,
|
| - size_t received_via_data_reduction_proxy_count) {
|
| + size_t received_via_data_reduction_proxy_count,
|
| + size_t num_days_in_history) {
|
| VerifyPrefList(data_reduction_proxy::prefs::kDailyHttpOriginalContentLength,
|
| - original_values, original_count);
|
| + original_values, original_count, num_days_in_history);
|
| VerifyPrefList(data_reduction_proxy::prefs::kDailyHttpReceivedContentLength,
|
| - received_values, received_count);
|
| + received_values, received_count, num_days_in_history);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyOriginalContentLengthWithDataReductionProxyEnabled,
|
| + original_with_data_reduction_proxy_enabled_values,
|
| + original_with_data_reduction_proxy_enabled_count,
|
| + num_days_in_history);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyContentLengthWithDataReductionProxyEnabled,
|
| + received_with_data_reduction_proxy_enabled_values,
|
| + received_with_data_reduction_proxy_count,
|
| + num_days_in_history);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyOriginalContentLengthViaDataReductionProxy,
|
| + original_via_data_reduction_proxy_values,
|
| + original_via_data_reduction_proxy_count,
|
| + num_days_in_history);
|
| VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyOriginalContentLengthWithDataReductionProxyEnabled,
|
| - original_with_data_reduction_proxy_enabled_values,
|
| - original_with_data_reduction_proxy_enabled_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyContentLengthWithDataReductionProxyEnabled,
|
| - received_with_data_reduction_proxy_enabled_values,
|
| - received_with_data_reduction_proxy_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyOriginalContentLengthViaDataReductionProxy,
|
| - original_via_data_reduction_proxy_values,
|
| - original_via_data_reduction_proxy_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyContentLengthViaDataReductionProxy,
|
| + data_reduction_proxy::prefs::kDailyContentLengthViaDataReductionProxy,
|
| received_via_data_reduction_proxy_values,
|
| - received_via_data_reduction_proxy_count);
|
| + received_via_data_reduction_proxy_count, num_days_in_history);
|
|
|
| VerifyPrefInt64(
|
| data_reduction_proxy::prefs::kDailyHttpOriginalContentLengthApplication,
|
| @@ -341,39 +344,39 @@ class DataReductionProxyCompressionStatsTest : public testing::Test {
|
| const int64_t* unknown_with_data_reduction_proxy_enabled_values,
|
| size_t unknown_with_data_reduction_proxy_enabled_count) {
|
| VerifyPrefList(data_reduction_proxy::prefs::kDailyHttpOriginalContentLength,
|
| - original_values, original_count);
|
| + original_values, original_count, kNumDaysInHistory);
|
| VerifyPrefList(data_reduction_proxy::prefs::kDailyHttpReceivedContentLength,
|
| - received_values, received_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyOriginalContentLengthWithDataReductionProxyEnabled,
|
| - original_with_data_reduction_proxy_enabled_values,
|
| - original_with_data_reduction_proxy_enabled_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyContentLengthWithDataReductionProxyEnabled,
|
| - received_with_data_reduction_proxy_enabled_values,
|
| - received_with_data_reduction_proxy_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyContentLengthHttpsWithDataReductionProxyEnabled,
|
| - https_with_data_reduction_proxy_enabled_values,
|
| - https_with_data_reduction_proxy_enabled_count);
|
| + received_values, received_count, kNumDaysInHistory);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyOriginalContentLengthWithDataReductionProxyEnabled,
|
| + original_with_data_reduction_proxy_enabled_values,
|
| + original_with_data_reduction_proxy_enabled_count,
|
| + kNumDaysInHistory);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyContentLengthWithDataReductionProxyEnabled,
|
| + received_with_data_reduction_proxy_enabled_values,
|
| + received_with_data_reduction_proxy_count, kNumDaysInHistory);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyContentLengthHttpsWithDataReductionProxyEnabled,
|
| + https_with_data_reduction_proxy_enabled_values,
|
| + https_with_data_reduction_proxy_enabled_count,
|
| + kNumDaysInHistory);
|
| VerifyPrefList(
|
| data_reduction_proxy::prefs::
|
| kDailyContentLengthShortBypassWithDataReductionProxyEnabled,
|
| short_bypass_with_data_reduction_proxy_enabled_values,
|
| - short_bypass_with_data_reduction_proxy_enabled_count);
|
| + short_bypass_with_data_reduction_proxy_enabled_count,
|
| + kNumDaysInHistory);
|
| VerifyPrefList(
|
| data_reduction_proxy::prefs::
|
| kDailyContentLengthLongBypassWithDataReductionProxyEnabled,
|
| long_bypass_with_data_reduction_proxy_enabled_values,
|
| - long_bypass_with_data_reduction_proxy_enabled_count);
|
| - VerifyPrefList(
|
| - data_reduction_proxy::prefs::
|
| - kDailyContentLengthUnknownWithDataReductionProxyEnabled,
|
| - unknown_with_data_reduction_proxy_enabled_values,
|
| - unknown_with_data_reduction_proxy_enabled_count);
|
| + long_bypass_with_data_reduction_proxy_enabled_count, kNumDaysInHistory);
|
| + VerifyPrefList(data_reduction_proxy::prefs::
|
| + kDailyContentLengthUnknownWithDataReductionProxyEnabled,
|
| + unknown_with_data_reduction_proxy_enabled_values,
|
| + unknown_with_data_reduction_proxy_enabled_count,
|
| + kNumDaysInHistory);
|
| }
|
|
|
| int64_t GetInt64(const char* pref_path) {
|
| @@ -432,6 +435,10 @@ class DataReductionProxyCompressionStatsTest : public testing::Test {
|
| compression_stats_->DeleteHistoricalDataUsage();
|
| }
|
|
|
| + void ClearDataSavingStatistics() {
|
| + compression_stats_->ClearDataSavingStatistics();
|
| + }
|
| +
|
| void DeleteBrowsingHistory(const base::Time& start, const base::Time& end) {
|
| compression_stats_->DeleteBrowsingHistory(start, end);
|
| }
|
| @@ -594,9 +601,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, OneResponse) {
|
| FakeNow());
|
|
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original, 1, received, 1,
|
| - original, 1, received, 1);
|
| + original, 1, received, 1, original, 1, received, 1, original, 1, received,
|
| + 1, kNumDaysInHistory);
|
| }
|
|
|
| TEST_F(DataReductionProxyCompressionStatsTest, MultipleResponses) {
|
| @@ -606,9 +612,9 @@ TEST_F(DataReductionProxyCompressionStatsTest, MultipleResponses) {
|
| int64_t received[] = {kReceivedLength};
|
| RecordContentLengthPrefs(
|
| kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, FakeNow());
|
| - VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - NULL, 0, NULL, 0, NULL, 0, NULL, 0);
|
| + VerifyDailyDataSavingContentLengthPrefLists(original, 1, received, 1, NULL, 0,
|
| + NULL, 0, NULL, 0, NULL, 0,
|
| + kNumDaysInHistory);
|
|
|
| RecordContentLengthPrefs(
|
| kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, FakeNow());
|
| @@ -617,9 +623,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, MultipleResponses) {
|
| int64_t original_proxy_enabled[] = {kOriginalLength};
|
| int64_t received_proxy_enabled[] = {kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original_proxy_enabled, 1, received_proxy_enabled, 1,
|
| - NULL, 0, NULL, 0);
|
| + original, 1, received, 1, original_proxy_enabled, 1,
|
| + received_proxy_enabled, 1, NULL, 0, NULL, 0, kNumDaysInHistory);
|
|
|
| RecordContentLengthPrefs(
|
| kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
|
| @@ -631,9 +636,9 @@ TEST_F(DataReductionProxyCompressionStatsTest, MultipleResponses) {
|
| int64_t original_via_proxy[] = {kOriginalLength};
|
| int64_t received_via_proxy[] = {kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original_proxy_enabled, 1, received_proxy_enabled, 1,
|
| - original_via_proxy, 1, received_via_proxy, 1);
|
| + original, 1, received, 1, original_proxy_enabled, 1,
|
| + received_proxy_enabled, 1, original_via_proxy, 1, received_via_proxy, 1,
|
| + kNumDaysInHistory);
|
|
|
| RecordContentLengthPrefs(
|
| kReceivedLength, kOriginalLength, true, UNKNOWN_TYPE, FakeNow());
|
| @@ -642,18 +647,18 @@ TEST_F(DataReductionProxyCompressionStatsTest, MultipleResponses) {
|
| original_proxy_enabled[0] += kOriginalLength;
|
| received_proxy_enabled[0] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original_proxy_enabled, 1, received_proxy_enabled, 1,
|
| - original_via_proxy, 1, received_via_proxy, 1);
|
| + original, 1, received, 1, original_proxy_enabled, 1,
|
| + received_proxy_enabled, 1, original_via_proxy, 1, received_via_proxy, 1,
|
| + kNumDaysInHistory);
|
|
|
| RecordContentLengthPrefs(
|
| kReceivedLength, kOriginalLength, false, UNKNOWN_TYPE, FakeNow());
|
| original[0] += kOriginalLength;
|
| received[0] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original_proxy_enabled, 1, received_proxy_enabled, 1,
|
| - original_via_proxy, 1, received_via_proxy, 1);
|
| + original, 1, received, 1, original_proxy_enabled, 1,
|
| + received_proxy_enabled, 1, original_via_proxy, 1, received_via_proxy, 1,
|
| + kNumDaysInHistory);
|
| }
|
|
|
| TEST_F(DataReductionProxyCompressionStatsTest, RequestType) {
|
| @@ -761,12 +766,10 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardOneDay) {
|
| int64_t original_via_data_reduction_proxy[] = {kOriginalLength, 0};
|
| int64_t received_via_data_reduction_proxy[] = {kReceivedLength, 0};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 2,
|
| - received, 2,
|
| - original_with_data_reduction_proxy_enabled, 2,
|
| + original, 2, received, 2, original_with_data_reduction_proxy_enabled, 2,
|
| received_with_data_reduction_proxy_enabled, 2,
|
| - original_via_data_reduction_proxy, 2,
|
| - received_via_data_reduction_proxy, 2);
|
| + original_via_data_reduction_proxy, 2, received_via_data_reduction_proxy,
|
| + 2, kNumDaysInHistory);
|
|
|
| // Proxy enabled. Not via proxy.
|
| RecordContentLengthPrefs(
|
| @@ -776,12 +779,10 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardOneDay) {
|
| original_with_data_reduction_proxy_enabled[1] += kOriginalLength;
|
| received_with_data_reduction_proxy_enabled[1] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 2,
|
| - received, 2,
|
| - original_with_data_reduction_proxy_enabled, 2,
|
| + original, 2, received, 2, original_with_data_reduction_proxy_enabled, 2,
|
| received_with_data_reduction_proxy_enabled, 2,
|
| - original_via_data_reduction_proxy, 2,
|
| - received_via_data_reduction_proxy, 2);
|
| + original_via_data_reduction_proxy, 2, received_via_data_reduction_proxy,
|
| + 2, kNumDaysInHistory);
|
|
|
| // Proxy enabled and via proxy.
|
| RecordContentLengthPrefs(
|
| @@ -794,12 +795,10 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardOneDay) {
|
| original_via_data_reduction_proxy[1] += kOriginalLength;
|
| received_via_data_reduction_proxy[1] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 2,
|
| - received, 2,
|
| - original_with_data_reduction_proxy_enabled, 2,
|
| + original, 2, received, 2, original_with_data_reduction_proxy_enabled, 2,
|
| received_with_data_reduction_proxy_enabled, 2,
|
| - original_via_data_reduction_proxy, 2,
|
| - received_via_data_reduction_proxy, 2);
|
| + original_via_data_reduction_proxy, 2, received_via_data_reduction_proxy,
|
| + 2, kNumDaysInHistory);
|
|
|
| // Proxy enabled and via proxy, with content length greater than max int32_t.
|
| const int64_t kBigOriginalLength = 0x300000000LL; // 12G.
|
| @@ -816,7 +815,7 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardOneDay) {
|
| original, 2, received, 2, original_with_data_reduction_proxy_enabled, 2,
|
| received_with_data_reduction_proxy_enabled, 2,
|
| original_via_data_reduction_proxy, 2, received_via_data_reduction_proxy,
|
| - 2);
|
| + 2, kNumDaysInHistory);
|
| }
|
|
|
| TEST_F(DataReductionProxyCompressionStatsTest, PartialDayTimeChange) {
|
| @@ -829,9 +828,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, PartialDayTimeChange) {
|
| kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
|
| FakeNow());
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 2, received, 2,
|
| - original, 2, received, 2,
|
| - original, 2, received, 2);
|
| + original, 2, received, 2, original, 2, received, 2, original, 2, received,
|
| + 2, kNumDaysInHistory);
|
|
|
| // Forward 10 hours, stay in the same day.
|
| // See kLastUpdateTime: "Now" in test is 03:45am.
|
| @@ -842,9 +840,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, PartialDayTimeChange) {
|
| original[1] += kOriginalLength;
|
| received[1] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 2, received, 2,
|
| - original, 2, received, 2,
|
| - original, 2, received, 2);
|
| + original, 2, received, 2, original, 2, received, 2, original, 2, received,
|
| + 2, kNumDaysInHistory);
|
|
|
| // Forward 11 more hours, comes to tomorrow.
|
| AddFakeTimeDeltaInHours(11);
|
| @@ -854,9 +851,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, PartialDayTimeChange) {
|
| int64_t original2[] = {kOriginalLength * 2, kOriginalLength};
|
| int64_t received2[] = {kReceivedLength * 2, kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original2, 2, received2, 2,
|
| - original2, 2, received2, 2,
|
| - original2, 2, received2, 2);
|
| + original2, 2, received2, 2, original2, 2, received2, 2, original2, 2,
|
| + received2, 2, kNumDaysInHistory);
|
| }
|
|
|
| TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
|
| @@ -881,9 +877,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
|
| int64_t original[] = {kOriginalLength, 0, 0, kOriginalLength};
|
| int64_t received[] = {kReceivedLength, 0, 0, kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 4, received, 4,
|
| - original, 4, received, 4,
|
| - original, 4, received, 4);
|
| + original, 4, received, 4, original, 4, received, 4, original, 4, received,
|
| + 4, kNumDaysInHistory);
|
|
|
| // Forward four more days.
|
| AddFakeTimeDeltaInHours(4 * 24);
|
| @@ -897,9 +892,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
|
| kReceivedLength, 0, 0, kReceivedLength, 0, 0, 0, kReceivedLength,
|
| };
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original2, 8, received2, 8,
|
| - original2, 8, received2, 8,
|
| - original2, 8, received2, 8);
|
| + original2, 8, received2, 8, original2, 8, received2, 8, original2, 8,
|
| + received2, 8, kNumDaysInHistory);
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 3);
|
|
|
| @@ -911,9 +905,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
|
| int64_t original3[] = {kOriginalLength};
|
| int64_t received3[] = {kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original3, 1, received3, 1,
|
| - original3, 1, received3, 1,
|
| - original3, 1, received3, 1);
|
| + original3, 1, received3, 1, original3, 1, received3, 1, original3, 1,
|
| + received3, 1, kNumDaysInHistory);
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 4);
|
|
|
| @@ -923,9 +916,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
|
| kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
|
| FakeNow());
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original3, 1, received3, 1,
|
| - original3, 1, received3, 1,
|
| - original3, 1, received3, 1);
|
| + original3, 1, received3, 1, original3, 1, received3, 1, original3, 1,
|
| + received3, 1, kNumDaysInHistory);
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 5);
|
| }
|
| @@ -951,9 +943,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
|
| original[0] += kOriginalLength;
|
| received[0] += kReceivedLength;
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original, 1, received, 1,
|
| - original, 1, received, 1);
|
| + original, 1, received, 1, original, 1, received, 1, original, 1, received,
|
| + 1, kNumDaysInHistory);
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 2);
|
|
|
| @@ -965,9 +956,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
|
| int64_t original2[] = {kOriginalLength * 2, kOriginalLength};
|
| int64_t received2[] = {kReceivedLength * 2, kReceivedLength};
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original2, 2, received2, 2,
|
| - original2, 2, received2, 2,
|
| - original2, 2, received2, 2);
|
| + original2, 2, received2, 2, original2, 2, received2, 2, original2, 2,
|
| + received2, 2, kNumDaysInHistory);
|
| histogram_tester.ExpectUniqueSample(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 3);
|
| }
|
| @@ -991,9 +981,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) {
|
| kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
|
| FakeNow());
|
| VerifyDailyDataSavingContentLengthPrefLists(
|
| - original, 1, received, 1,
|
| - original, 1, received, 1,
|
| - original, 1, received, 1);
|
| + original, 1, received, 1, original, 1, received, 1, original, 1, received,
|
| + 1, kNumDaysInHistory);
|
| histogram_tester.ExpectTotalCount(
|
| "DataReductionProxy.SavingsCleared.NegativeSystemClock", 2);
|
| histogram_tester.ExpectBucketCount(
|
| @@ -1339,4 +1328,45 @@ TEST_F(DataReductionProxyCompressionStatsTest, DeleteBrowsingHistory) {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| +TEST_F(DataReductionProxyCompressionStatsTest, ClearDataSavingStatistics) {
|
| + EnableDataUsageReporting();
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + base::Time now = base::Time::Now();
|
| + base::Time fifteen_mins_ago = now - TimeDelta::FromMinutes(15);
|
| + // Fake record to be from 15 minutes ago so that it is flushed to storage.
|
| + RecordDataUsage("https://www.bar.com", 900, 1100, fifteen_mins_ago);
|
| +
|
| + RecordDataUsage("https://www.foo.com", 1000, 1250, now);
|
| +
|
| + const int64_t kOriginalLength = 200;
|
| + const int64_t kReceivedLength = 100;
|
| + int64_t original[] = {kOriginalLength};
|
| + int64_t received[] = {kReceivedLength};
|
| +
|
| + RecordContentLengthPrefs(kReceivedLength, kOriginalLength, true,
|
| + VIA_DATA_REDUCTION_PROXY, FakeNow());
|
| +
|
| + VerifyDailyDataSavingContentLengthPrefLists(
|
| + original, 1, received, 1, original, 1, received, 1, original, 1, received,
|
| + 1, kNumDaysInHistory);
|
| +
|
| + ClearDataSavingStatistics();
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + auto expected_data_usage =
|
| + base::MakeUnique<std::vector<data_reduction_proxy::DataUsageBucket>>(
|
| + kNumExpectedBuckets);
|
| + DataUsageLoadVerifier verifier(std::move(expected_data_usage));
|
| +
|
| + GetHistoricalDataUsage(base::Bind(&DataUsageLoadVerifier::OnLoadDataUsage,
|
| + base::Unretained(&verifier)),
|
| + now);
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + VerifyDailyDataSavingContentLengthPrefLists(nullptr, 0, nullptr, 0, nullptr,
|
| + 0, nullptr, 0, nullptr, 0,
|
| + nullptr, 0, 0);
|
| +}
|
| +
|
| } // namespace data_reduction_proxy
|
|
|