| 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_comp
ression_stats.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp
ression_stats.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 FakeNow()); | 992 FakeNow()); |
| 993 int64_t original2[] = {kOriginalLength * 2, kOriginalLength}; | 993 int64_t original2[] = {kOriginalLength * 2, kOriginalLength}; |
| 994 int64_t received2[] = {kReceivedLength * 2, kReceivedLength}; | 994 int64_t received2[] = {kReceivedLength * 2, kReceivedLength}; |
| 995 VerifyDailyDataSavingContentLengthPrefLists( | 995 VerifyDailyDataSavingContentLengthPrefLists( |
| 996 original2, 2, received2, 2, | 996 original2, 2, received2, 2, |
| 997 original2, 2, received2, 2, | 997 original2, 2, received2, 2, |
| 998 original2, 2, received2, 2); | 998 original2, 2, received2, 2); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) { | 1001 TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) { |
| 1002 base::HistogramTester histogram_tester; |
| 1002 const int64_t kOriginalLength = 200; | 1003 const int64_t kOriginalLength = 200; |
| 1003 const int64_t kReceivedLength = 100; | 1004 const int64_t kReceivedLength = 100; |
| 1004 int64_t original[] = {kOriginalLength}; | 1005 int64_t original[] = {kOriginalLength}; |
| 1005 int64_t received[] = {kReceivedLength}; | 1006 int64_t received[] = {kReceivedLength}; |
| 1006 | 1007 |
| 1007 RecordContentLengthPrefs( | 1008 RecordContentLengthPrefs( |
| 1008 kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, | 1009 kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
| 1009 FakeNow()); | 1010 FakeNow()); |
| 1010 // Backward two days. | 1011 // Backward two days. |
| 1011 SetFakeTimeDeltaInHours(-2 * 24); | 1012 SetFakeTimeDeltaInHours(-2 * 24); |
| 1012 RecordContentLengthPrefs( | 1013 RecordContentLengthPrefs( |
| 1013 kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, | 1014 kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY, |
| 1014 FakeNow()); | 1015 FakeNow()); |
| 1015 VerifyDailyDataSavingContentLengthPrefLists( | 1016 VerifyDailyDataSavingContentLengthPrefLists( |
| 1016 original, 1, received, 1, | 1017 original, 1, received, 1, |
| 1017 original, 1, received, 1, | 1018 original, 1, received, 1, |
| 1018 original, 1, received, 1); | 1019 original, 1, received, 1); |
| 1020 histogram_tester.ExpectUniqueSample( |
| 1021 "DataReductionProxy.CountSavingsCleared.NegativeSystemClock", 1, 1); |
| 1022 VerifyPrefInt64(prefs::kDataReductionProxySavingsClearedNegativeSystemClock, |
| 1023 FakeNow().ToInternalValue()); |
| 1019 } | 1024 } |
| 1020 | 1025 |
| 1021 TEST_F(DataReductionProxyCompressionStatsTest, NormalizeHostname) { | 1026 TEST_F(DataReductionProxyCompressionStatsTest, NormalizeHostname) { |
| 1022 EXPECT_EQ("www.foo.com", NormalizeHostname("http://www.foo.com")); | 1027 EXPECT_EQ("www.foo.com", NormalizeHostname("http://www.foo.com")); |
| 1023 EXPECT_EQ("foo.com", NormalizeHostname("https://foo.com")); | 1028 EXPECT_EQ("foo.com", NormalizeHostname("https://foo.com")); |
| 1024 EXPECT_EQ("bar.co.uk", NormalizeHostname("http://bar.co.uk")); | 1029 EXPECT_EQ("bar.co.uk", NormalizeHostname("http://bar.co.uk")); |
| 1025 EXPECT_EQ("http.www.co.in", NormalizeHostname("http://http.www.co.in")); | 1030 EXPECT_EQ("http.www.co.in", NormalizeHostname("http://http.www.co.in")); |
| 1026 } | 1031 } |
| 1027 | 1032 |
| 1028 TEST_F(DataReductionProxyCompressionStatsTest, RecordUma) { | 1033 TEST_F(DataReductionProxyCompressionStatsTest, RecordUma) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 expected_data_usage = | 1315 expected_data_usage = |
| 1311 base::MakeUnique<std::vector<data_reduction_proxy::DataUsageBucket>>( | 1316 base::MakeUnique<std::vector<data_reduction_proxy::DataUsageBucket>>( |
| 1312 kNumExpectedBuckets); | 1317 kNumExpectedBuckets); |
| 1313 DataUsageLoadVerifier verifier2(std::move(expected_data_usage)); | 1318 DataUsageLoadVerifier verifier2(std::move(expected_data_usage)); |
| 1314 LoadHistoricalDataUsage(base::Bind(&DataUsageLoadVerifier::OnLoadDataUsage, | 1319 LoadHistoricalDataUsage(base::Bind(&DataUsageLoadVerifier::OnLoadDataUsage, |
| 1315 base::Unretained(&verifier2))); | 1320 base::Unretained(&verifier2))); |
| 1316 base::RunLoop().RunUntilIdle(); | 1321 base::RunLoop().RunUntilIdle(); |
| 1317 } | 1322 } |
| 1318 | 1323 |
| 1319 } // namespace data_reduction_proxy | 1324 } // namespace data_reduction_proxy |
| OLD | NEW |