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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats_unittest.cc

Issue 2249903004: Adding a DataSavingsRecorder interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bengr comments Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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 071dc4ff90eb5facb1f158bad585a37e292c8289..4c97d2f6c3dfa03f7886a6fb5a5ba1108a976a87 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
@@ -595,20 +595,42 @@ TEST_F(DataReductionProxyCompressionStatsTest, TotalLengths) {
kReceivedLength, kOriginalLength, IsDataReductionProxyEnabled(),
UNKNOWN_TYPE, nullptr, std::string());
EXPECT_EQ(kReceivedLength * 2,
GetInt64(data_reduction_proxy::prefs::kHttpReceivedContentLength));
EXPECT_FALSE(IsDataReductionProxyEnabled());
EXPECT_EQ(kOriginalLength * 2,
GetInt64(data_reduction_proxy::prefs::kHttpOriginalContentLength));
}
+TEST_F(DataReductionProxyCompressionStatsTest, TotalLengthsUpdate) {
+ const int64_t kOriginalLength = 200;
+ const int64_t kReceivedLength = 100;
+
+ compression_stats()->UpdateDataSavings(std::string(), kReceivedLength,
+ kOriginalLength);
+
+ EXPECT_EQ(0,
+ GetInt64(data_reduction_proxy::prefs::kHttpReceivedContentLength));
+ EXPECT_EQ(kOriginalLength - kReceivedLength,
+ GetInt64(data_reduction_proxy::prefs::kHttpOriginalContentLength));
+
+ // Record the same numbers again, and total lengths should be doubled.
+ compression_stats()->UpdateDataSavings(std::string(), kReceivedLength,
+ kOriginalLength);
+
+ EXPECT_EQ(0,
+ GetInt64(data_reduction_proxy::prefs::kHttpReceivedContentLength));
+ EXPECT_EQ(kOriginalLength * 2 - kReceivedLength * 2,
+ GetInt64(data_reduction_proxy::prefs::kHttpOriginalContentLength));
+}
+
TEST_F(DataReductionProxyCompressionStatsTest, OneResponse) {
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());

Powered by Google App Engine
This is Rietveld 408576698