| 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 "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> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/macros.h" |
| 8 #include "base/md5.h" | 12 #include "base/md5.h" |
| 9 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram_samples.h" | 14 #include "base/metrics/histogram_samples.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
| 13 #include "base/test/mock_entropy_provider.h" | 17 #include "base/test/mock_entropy_provider.h" |
| 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_test_utils.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator_test_utils.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator_test_utils.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 CheckOnPrefChange(true, true, false); | 86 CheckOnPrefChange(true, true, false); |
| 83 EXPECT_TRUE(settings_->CanUseDataReductionProxy(http_gurl)); | 87 EXPECT_TRUE(settings_->CanUseDataReductionProxy(http_gurl)); |
| 84 | 88 |
| 85 GURL https_gurl("https://url.com/"); | 89 GURL https_gurl("https://url.com/"); |
| 86 EXPECT_FALSE(settings_->CanUseDataReductionProxy(https_gurl)); | 90 EXPECT_FALSE(settings_->CanUseDataReductionProxy(https_gurl)); |
| 87 | 91 |
| 88 test_context_->RunUntilIdle(); | 92 test_context_->RunUntilIdle(); |
| 89 } | 93 } |
| 90 | 94 |
| 91 TEST_F(DataReductionProxySettingsTest, TestResetDataReductionStatistics) { | 95 TEST_F(DataReductionProxySettingsTest, TestResetDataReductionStatistics) { |
| 92 int64 original_content_length; | 96 int64_t original_content_length; |
| 93 int64 received_content_length; | 97 int64_t received_content_length; |
| 94 int64 last_update_time; | 98 int64_t last_update_time; |
| 95 settings_->ResetDataReductionStatistics(); | 99 settings_->ResetDataReductionStatistics(); |
| 96 settings_->GetContentLengths(kNumDaysInHistory, | 100 settings_->GetContentLengths(kNumDaysInHistory, |
| 97 &original_content_length, | 101 &original_content_length, |
| 98 &received_content_length, | 102 &received_content_length, |
| 99 &last_update_time); | 103 &last_update_time); |
| 100 EXPECT_EQ(0L, original_content_length); | 104 EXPECT_EQ(0L, original_content_length); |
| 101 EXPECT_EQ(0L, received_content_length); | 105 EXPECT_EQ(0L, received_content_length); |
| 102 EXPECT_EQ(last_update_time_.ToInternalValue(), last_update_time); | 106 EXPECT_EQ(last_update_time_.ToInternalValue(), last_update_time); |
| 103 } | 107 } |
| 104 | 108 |
| 105 TEST_F(DataReductionProxySettingsTest, TestContentLengths) { | 109 TEST_F(DataReductionProxySettingsTest, TestContentLengths) { |
| 106 int64 original_content_length; | 110 int64_t original_content_length; |
| 107 int64 received_content_length; | 111 int64_t received_content_length; |
| 108 int64 last_update_time; | 112 int64_t last_update_time; |
| 109 | 113 |
| 110 // Request |kNumDaysInHistory| days. | 114 // Request |kNumDaysInHistory| days. |
| 111 settings_->GetContentLengths(kNumDaysInHistory, | 115 settings_->GetContentLengths(kNumDaysInHistory, |
| 112 &original_content_length, | 116 &original_content_length, |
| 113 &received_content_length, | 117 &received_content_length, |
| 114 &last_update_time); | 118 &last_update_time); |
| 115 const unsigned int days = kNumDaysInHistory; | 119 const unsigned int days = kNumDaysInHistory; |
| 116 // Received content length history values are 0 to |kNumDaysInHistory - 1|. | 120 // Received content length history values are 0 to |kNumDaysInHistory - 1|. |
| 117 int64 expected_total_received_content_length = (days - 1L) * days / 2; | 121 int64_t expected_total_received_content_length = (days - 1L) * days / 2; |
| 118 // Original content length history values are 0 to | 122 // Original content length history values are 0 to |
| 119 // |2 * (kNumDaysInHistory - 1)|. | 123 // |2 * (kNumDaysInHistory - 1)|. |
| 120 long expected_total_original_content_length = (days - 1L) * days; | 124 long expected_total_original_content_length = (days - 1L) * days; |
| 121 EXPECT_EQ(expected_total_original_content_length, original_content_length); | 125 EXPECT_EQ(expected_total_original_content_length, original_content_length); |
| 122 EXPECT_EQ(expected_total_received_content_length, received_content_length); | 126 EXPECT_EQ(expected_total_received_content_length, received_content_length); |
| 123 EXPECT_EQ(last_update_time_.ToInternalValue(), last_update_time); | 127 EXPECT_EQ(last_update_time_.ToInternalValue(), last_update_time); |
| 124 | 128 |
| 125 // Request |kNumDaysInHistory - 1| days. | 129 // Request |kNumDaysInHistory - 1| days. |
| 126 settings_->GetContentLengths(kNumDaysInHistory - 1, | 130 settings_->GetContentLengths(kNumDaysInHistory - 1, |
| 127 &original_content_length, | 131 &original_content_length, |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 SyntheticFieldTrialRegistrationCallback, | 739 SyntheticFieldTrialRegistrationCallback, |
| 736 base::Unretained(this))); | 740 base::Unretained(this))); |
| 737 | 741 |
| 738 net::ProxyServer origin = | 742 net::ProxyServer origin = |
| 739 test_context_->config()->test_params()->proxies_for_http().front(); | 743 test_context_->config()->test_params()->proxies_for_http().front(); |
| 740 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; | 744 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; |
| 741 } | 745 } |
| 742 } | 746 } |
| 743 | 747 |
| 744 } // namespace data_reduction_proxy | 748 } // namespace data_reduction_proxy |
| OLD | NEW |