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

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

Issue 956223002: Rename DataReductionProxyUsageStats to DataReductionProxyBypassStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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_bypass_stats_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
similarity index 71%
rename from components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc
rename to components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
index ac75479e0eae97baa525817a0e715e9f7dd79ef5..d41e209bdf14f8c882e7152d8f60969662e4412f 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
#include <set>
#include <string>
@@ -57,10 +57,9 @@ const std::string kErrorBody = "bad";
} // namespace
-class DataReductionProxyUsageStatsTest : public testing::Test {
+class DataReductionProxyBypassStatsTest : public testing::Test {
public:
- DataReductionProxyUsageStatsTest()
- : context_(true) {
+ DataReductionProxyBypassStatsTest() : context_(true) {
context_.Init();
// The |test_job_factory_| takes ownership of the interceptor.
@@ -76,27 +75,26 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
DataReductionProxyParams::kFallbackAllowed |
DataReductionProxyParams::kPromoAllowed)
.WithParamsDefinitions(
- TestDataReductionProxyParams::HAS_EVERYTHING &
- ~TestDataReductionProxyParams::HAS_DEV_ORIGIN &
- ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)
+ TestDataReductionProxyParams::HAS_EVERYTHING &
+ ~TestDataReductionProxyParams::HAS_DEV_ORIGIN &
+ ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)
.WithMockConfig()
.Build();
- mock_url_request_ = context_.CreateRequest(GURL(), net::IDLE, &delegate_,
- NULL);
+ mock_url_request_ =
+ context_.CreateRequest(GURL(), net::IDLE, &delegate_, NULL);
}
scoped_ptr<net::URLRequest> CreateURLRequestWithResponseHeaders(
const GURL& url,
const std::string& raw_response_headers) {
- scoped_ptr<net::URLRequest> fake_request = context_.CreateRequest(
- url, net::IDLE, &delegate_, NULL);
+ scoped_ptr<net::URLRequest> fake_request =
+ context_.CreateRequest(url, net::IDLE, &delegate_, NULL);
// Create a test job that will fill in the given response headers for the
// |fake_request|.
- scoped_refptr<net::URLRequestTestJob> test_job(
- new net::URLRequestTestJob(fake_request.get(),
- context_.network_delegate(),
- raw_response_headers, std::string(), true));
+ scoped_refptr<net::URLRequestTestJob> test_job(new net::URLRequestTestJob(
+ fake_request.get(), context_.network_delegate(), raw_response_headers,
+ std::string(), true));
// Configure the interceptor to use the test job to handle the next request.
test_job_interceptor_->set_main_intercept_job(test_job.get());
@@ -112,25 +110,20 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
}
protected:
- scoped_ptr<DataReductionProxyUsageStats> BuildUsageStats() {
- return make_scoped_ptr(
- new DataReductionProxyUsageStats(
- test_context_->config(),
- test_context_->unreachable_callback(),
- test_context_->task_runner())).Pass();
+ scoped_ptr<DataReductionProxyBypassStats> BuildBypassStats() {
+ return make_scoped_ptr(new DataReductionProxyBypassStats(
+ test_context_->config(),
+ test_context_->unreachable_callback(),
+ test_context_->task_runner())).Pass();
}
- net::URLRequest* url_request() {
- return mock_url_request_.get();
- }
+ net::URLRequest* url_request() { return mock_url_request_.get(); }
MockDataReductionProxyConfig* config() const {
return test_context_->mock_config();
}
- void RunUntilIdle() {
- test_context_->RunUntilIdle();
- }
+ void RunUntilIdle() { test_context_->RunUntilIdle(); }
private:
net::TestURLRequestContext context_;
@@ -142,7 +135,7 @@ class DataReductionProxyUsageStatsTest : public testing::Test {
scoped_ptr<DataReductionProxyTestContext> test_context_;
};
-TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
+TEST_F(DataReductionProxyBypassStatsTest, IsDataReductionProxyUnreachable) {
net::ProxyServer fallback_proxy_server =
net::ProxyServer::FromURI("foo.com", net::ProxyServer::SCHEME_HTTP);
data_reduction_proxy::DataReductionProxyTypeInfo proxy_info;
@@ -151,100 +144,79 @@ TEST_F(DataReductionProxyUsageStatsTest, IsDataReductionProxyUnreachable) {
bool was_proxy_used;
bool is_unreachable;
};
- const TestCase test_cases[] = {
- {
- false,
- false,
- false
- },
- {
- false,
- true,
- false
- },
- {
- true,
- true,
- false
- },
- {
- true,
- false,
- true
- }
- };
+ const TestCase test_cases[] = {{false, false, false},
bengr 2015/03/24 15:47:27 Why did you change this? It has nothing to do with
zhuoyu.qian 2015/03/28 03:06:58 Done.
+ {false, true, false},
+ {true, true, false},
+ {true, false, true}};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
TestCase test_case = test_cases[i];
EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, testing::_))
.WillRepeatedly(testing::Return(
test_case.fallback_proxy_server_is_data_reduction_proxy));
- EXPECT_CALL(*config(),
- WasDataReductionProxyUsed(url_request(), testing::_))
+ EXPECT_CALL(*config(), WasDataReductionProxyUsed(url_request(), testing::_))
.WillRepeatedly(testing::Return(test_case.was_proxy_used));
- scoped_ptr<DataReductionProxyUsageStats> usage_stats = BuildUsageStats();
+ scoped_ptr<DataReductionProxyBypassStats> bypass_stats = BuildBypassStats();
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
- usage_stats->OnUrlRequestCompleted(url_request(), false);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnUrlRequestCompleted(url_request(), false);
RunUntilIdle();
EXPECT_EQ(test_case.is_unreachable, IsUnreachable());
}
}
-TEST_F(DataReductionProxyUsageStatsTest, ProxyUnreachableThenReachable) {
+TEST_F(DataReductionProxyBypassStatsTest, ProxyUnreachableThenReachable) {
net::ProxyServer fallback_proxy_server =
net::ProxyServer::FromURI("foo.com", net::ProxyServer::SCHEME_HTTP);
- scoped_ptr<DataReductionProxyUsageStats> usage_stats = BuildUsageStats();
+ scoped_ptr<DataReductionProxyBypassStats> bypass_stats = BuildBypassStats();
EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, testing::_))
.WillOnce(testing::Return(true));
- EXPECT_CALL(*config(),
- WasDataReductionProxyUsed(url_request(), testing::_))
+ EXPECT_CALL(*config(), WasDataReductionProxyUsed(url_request(), testing::_))
.WillOnce(testing::Return(true));
// proxy falls back
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
RunUntilIdle();
EXPECT_TRUE(IsUnreachable());
// proxy succeeds
- usage_stats->OnUrlRequestCompleted(url_request(), false);
+ bypass_stats->OnUrlRequestCompleted(url_request(), false);
RunUntilIdle();
EXPECT_FALSE(IsUnreachable());
}
-TEST_F(DataReductionProxyUsageStatsTest, ProxyReachableThenUnreachable) {
+TEST_F(DataReductionProxyBypassStatsTest, ProxyReachableThenUnreachable) {
net::ProxyServer fallback_proxy_server =
net::ProxyServer::FromURI("foo.com", net::ProxyServer::SCHEME_HTTP);
- scoped_ptr<DataReductionProxyUsageStats> usage_stats = BuildUsageStats();
- EXPECT_CALL(*config(),
- WasDataReductionProxyUsed(url_request(), testing::_))
+ scoped_ptr<DataReductionProxyBypassStats> bypass_stats = BuildBypassStats();
+ EXPECT_CALL(*config(), WasDataReductionProxyUsed(url_request(), testing::_))
.WillOnce(testing::Return(true));
EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, testing::_))
.WillRepeatedly(testing::Return(true));
// Proxy succeeds.
- usage_stats->OnUrlRequestCompleted(url_request(), false);
+ bypass_stats->OnUrlRequestCompleted(url_request(), false);
RunUntilIdle();
EXPECT_FALSE(IsUnreachable());
// Then proxy falls back indefinitely.
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
- usage_stats->OnProxyFallback(fallback_proxy_server,
- net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
+ bypass_stats->OnProxyFallback(fallback_proxy_server,
+ net::ERR_PROXY_CONNECTION_FAILED);
RunUntilIdle();
EXPECT_TRUE(IsUnreachable());
}
-TEST_F(DataReductionProxyUsageStatsTest,
+TEST_F(DataReductionProxyBypassStatsTest,
DetectAndRecordMissingViaHeaderResponseCode) {
const std::string kPrimaryHistogramName =
"DataReductionProxy.MissingViaHeader.ResponseCode.Primary";
@@ -258,57 +230,22 @@ TEST_F(DataReductionProxyUsageStatsTest,
int expected_fallback_sample; // -1 indicates no expected sample.
};
const TestCase test_cases[] = {
- {
- true,
- "HTTP/1.1 200 OK\n"
- "Via: 1.1 Chrome-Compression-Proxy\n",
- -1,
- -1
- },
- {
- false,
- "HTTP/1.1 200 OK\n"
- "Via: 1.1 Chrome-Compression-Proxy\n",
- -1,
- -1
- },
- {
- true,
- "HTTP/1.1 200 OK\n",
- 200,
- -1
- },
- {
- false,
- "HTTP/1.1 200 OK\n",
- -1,
- 200
- },
- {
- true,
- "HTTP/1.1 304 Not Modified\n",
- 304,
- -1
- },
- {
- false,
- "HTTP/1.1 304 Not Modified\n",
- -1,
- 304
- },
- {
- true,
- "HTTP/1.1 404 Not Found\n",
- 404,
- -1
- },
- {
- false,
- "HTTP/1.1 404 Not Found\n",
- -1,
- 404
- }
- };
+ {true,
bengr 2015/03/24 15:47:27 Same here. Please don't change the formatting.
zhuoyu.qian 2015/03/28 03:06:58 Done.
+ "HTTP/1.1 200 OK\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n",
+ -1,
+ -1},
+ {false,
+ "HTTP/1.1 200 OK\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n",
+ -1,
+ -1},
+ {true, "HTTP/1.1 200 OK\n", 200, -1},
+ {false, "HTTP/1.1 200 OK\n", -1, 200},
+ {true, "HTTP/1.1 304 Not Modified\n", 304, -1},
+ {false, "HTTP/1.1 304 Not Modified\n", -1, 304},
+ {true, "HTTP/1.1 404 Not Found\n", 404, -1},
+ {false, "HTTP/1.1 404 Not Found\n", -1, 404}};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
base::HistogramTester histogram_tester;
@@ -317,7 +254,7 @@ TEST_F(DataReductionProxyUsageStatsTest,
scoped_refptr<net::HttpResponseHeaders> headers(
new net::HttpResponseHeaders(raw_headers));
- DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode(
+ DataReductionProxyBypassStats::DetectAndRecordMissingViaHeaderResponseCode(
test_cases[i].is_primary, headers.get());
if (test_cases[i].expected_primary_sample == -1) {
@@ -336,7 +273,7 @@ TEST_F(DataReductionProxyUsageStatsTest,
}
}
-TEST_F(DataReductionProxyUsageStatsTest, RecordMissingViaHeaderBytes) {
+TEST_F(DataReductionProxyBypassStatsTest, RecordMissingViaHeaderBytes) {
const std::string k4xxHistogramName =
"DataReductionProxy.MissingViaHeader.Bytes.4xx";
const std::string kOtherHistogramName =
@@ -350,79 +287,35 @@ TEST_F(DataReductionProxyUsageStatsTest, RecordMissingViaHeaderBytes) {
bool is_other_sample_expected;
};
const TestCase test_cases[] = {
bengr 2015/03/24 15:47:27 And here.
zhuoyu.qian 2015/03/28 03:06:58 Done.
- // Nothing should be recorded for requests that don't use the proxy.
- {
- false,
- "HTTP/1.1 404 Not Found\n",
- false,
- false
- },
- {
- false,
- "HTTP/1.1 200 OK\n",
- false,
- false
- },
- // Nothing should be recorded for responses that have the via header.
- {
- true,
- "HTTP/1.1 404 Not Found\n"
- "Via: 1.1 Chrome-Compression-Proxy\n",
- false,
- false
- },
- {
- true,
- "HTTP/1.1 200 OK\n"
- "Via: 1.1 Chrome-Compression-Proxy\n",
- false,
- false
- },
- // 4xx responses that used the proxy and don't have the via header should be
- // recorded.
- {
- true,
- "HTTP/1.1 404 Not Found\n",
- true,
- false
- },
- {
- true,
- "HTTP/1.1 400 Bad Request\n",
- true,
- false
- },
- {
- true,
- "HTTP/1.1 499 Big Client Error Response Code\n",
- true,
- false
- },
- // Non-4xx responses that used the proxy and don't have the via header
- // should be recorded.
- {
- true,
- "HTTP/1.1 200 OK\n",
- false,
- true
- },
- {
- true,
- "HTTP/1.1 399 Big Redirection Response Code\n",
- false,
- true
- },
- {
- true,
- "HTTP/1.1 500 Internal Server Error\n",
- false,
- true
- }
- };
+ // Nothing should be recorded for requests that don't use the proxy.
+ {false, "HTTP/1.1 404 Not Found\n", false, false},
+ {false, "HTTP/1.1 200 OK\n", false, false},
+ // Nothing should be recorded for responses that have the via header.
+ {true,
+ "HTTP/1.1 404 Not Found\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n",
+ false,
+ false},
+ {true,
+ "HTTP/1.1 200 OK\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n",
+ false,
+ false},
+ // 4xx responses that used the proxy and don't have the via header should
+ // be
+ // recorded.
+ {true, "HTTP/1.1 404 Not Found\n", true, false},
+ {true, "HTTP/1.1 400 Bad Request\n", true, false},
+ {true, "HTTP/1.1 499 Big Client Error Response Code\n", true, false},
+ // Non-4xx responses that used the proxy and don't have the via header
+ // should be recorded.
+ {true, "HTTP/1.1 200 OK\n", false, true},
+ {true, "HTTP/1.1 399 Big Redirection Response Code\n", false, true},
+ {true, "HTTP/1.1 500 Internal Server Error\n", false, true}};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
base::HistogramTester histogram_tester;
- scoped_ptr<DataReductionProxyUsageStats> usage_stats = BuildUsageStats();
+ scoped_ptr<DataReductionProxyBypassStats> bypass_stats = BuildBypassStats();
std::string raw_headers(test_cases[i].headers);
HeadersToRaw(&raw_headers);
@@ -436,7 +329,7 @@ TEST_F(DataReductionProxyUsageStatsTest, RecordMissingViaHeaderBytes) {
WasDataReductionProxyUsed(fake_request.get(), testing::_))
.WillRepeatedly(Return(test_cases[i].was_proxy_used));
- usage_stats->RecordMissingViaHeaderBytes(*fake_request);
+ bypass_stats->RecordMissingViaHeaderBytes(*fake_request);
if (test_cases[i].is_4xx_sample_expected) {
histogram_tester.ExpectUniqueSample(k4xxHistogramName,
@@ -454,7 +347,7 @@ TEST_F(DataReductionProxyUsageStatsTest, RecordMissingViaHeaderBytes) {
}
}
-TEST_F(DataReductionProxyUsageStatsTest, RequestCompletionErrorCodes) {
+TEST_F(DataReductionProxyBypassStatsTest, RequestCompletionErrorCodes) {
const std::string kPrimaryHistogramName =
"DataReductionProxy.RequestCompletionErrorCodes.Primary";
const std::string kFallbackHistogramName =
@@ -473,26 +366,26 @@ TEST_F(DataReductionProxyUsageStatsTest, RequestCompletionErrorCodes) {
};
const TestCase test_cases[] = {
bengr 2015/03/24 15:47:27 And here. In this case the formatting is already a
zhuoyu.qian 2015/03/28 03:06:58 Done.
- {false, true, false, true, net::OK},
- {false, true, false, false, net::ERR_TOO_MANY_REDIRECTS},
- {false, false, false, true, net::OK},
- {false, false, false, false, net::ERR_TOO_MANY_REDIRECTS},
- {true, false, false, true, net::OK},
- {true, false, false, true, net::ERR_TOO_MANY_REDIRECTS},
- {true, false, false, false, net::OK},
- {true, false, false, false, net::ERR_TOO_MANY_REDIRECTS},
- {true, false, true, true, net::OK},
- {true, false, true, true, net::ERR_TOO_MANY_REDIRECTS},
- {true, false, true, false, net::OK},
- {true, false, true, false, net::ERR_TOO_MANY_REDIRECTS}
- };
+ {false, true, false, true, net::OK},
+ {false, true, false, false, net::ERR_TOO_MANY_REDIRECTS},
+ {false, false, false, true, net::OK},
+ {false, false, false, false, net::ERR_TOO_MANY_REDIRECTS},
+ {true, false, false, true, net::OK},
+ {true, false, false, true, net::ERR_TOO_MANY_REDIRECTS},
+ {true, false, false, false, net::OK},
+ {true, false, false, false, net::ERR_TOO_MANY_REDIRECTS},
+ {true, false, true, true, net::OK},
+ {true, false, true, true, net::ERR_TOO_MANY_REDIRECTS},
+ {true, false, true, false, net::OK},
+ {true, false, true, false, net::ERR_TOO_MANY_REDIRECTS}};
for (size_t i = 0; i < arraysize(test_cases); ++i) {
base::HistogramTester histogram_tester;
- scoped_ptr<DataReductionProxyUsageStats> usage_stats = BuildUsageStats();
+ scoped_ptr<DataReductionProxyBypassStats> bypass_stats = BuildBypassStats();
- std::string raw_headers("HTTP/1.1 200 OK\n"
- "Via: 1.1 Chrome-Compression-Proxy\n");
+ std::string raw_headers(
+ "HTTP/1.1 200 OK\n"
+ "Via: 1.1 Chrome-Compression-Proxy\n");
HeadersToRaw(&raw_headers);
scoped_ptr<net::URLRequest> fake_request(
CreateURLRequestWithResponseHeaders(GURL("http://www.google.com/"),
@@ -518,33 +411,33 @@ TEST_F(DataReductionProxyUsageStatsTest, RequestCompletionErrorCodes) {
.WillRepeatedly(testing::DoAll(testing::SetArgPointee<1>(proxy_info),
Return(test_cases[i].was_proxy_used)));
- usage_stats->OnUrlRequestCompleted(fake_request.get(), false);
+ bypass_stats->OnUrlRequestCompleted(fake_request.get(), false);
if (test_cases[i].was_proxy_used && !test_cases[i].is_load_bypass_proxy &&
!test_cases[i].is_fallback) {
- histogram_tester.ExpectUniqueSample(
- kPrimaryHistogramName, -net_error_int, 1);
+ histogram_tester.ExpectUniqueSample(kPrimaryHistogramName, -net_error_int,
+ 1);
} else {
histogram_tester.ExpectTotalCount(kPrimaryHistogramName, 0);
}
if (test_cases[i].was_proxy_used && !test_cases[i].is_load_bypass_proxy &&
test_cases[i].is_fallback) {
- histogram_tester.ExpectUniqueSample(
- kFallbackHistogramName, -net_error_int, 1);
+ histogram_tester.ExpectUniqueSample(kFallbackHistogramName,
+ -net_error_int, 1);
} else {
histogram_tester.ExpectTotalCount(kFallbackHistogramName, 0);
}
if (test_cases[i].was_proxy_used && !test_cases[i].is_load_bypass_proxy &&
!test_cases[i].is_fallback && test_cases[i].is_main_frame) {
- histogram_tester.ExpectUniqueSample(
- kPrimaryMainFrameHistogramName, -net_error_int, 1);
+ histogram_tester.ExpectUniqueSample(kPrimaryMainFrameHistogramName,
+ -net_error_int, 1);
} else {
histogram_tester.ExpectTotalCount(kPrimaryMainFrameHistogramName, 0);
}
if (test_cases[i].was_proxy_used && !test_cases[i].is_load_bypass_proxy &&
test_cases[i].is_fallback && test_cases[i].is_main_frame) {
- histogram_tester.ExpectUniqueSample(
- kFallbackMainFrameHistogramName, -net_error_int, 1);
+ histogram_tester.ExpectUniqueSample(kFallbackMainFrameHistogramName,
+ -net_error_int, 1);
} else {
histogram_tester.ExpectTotalCount(kFallbackMainFrameHistogramName, 0);
}
@@ -552,12 +445,12 @@ TEST_F(DataReductionProxyUsageStatsTest, RequestCompletionErrorCodes) {
}
// End-to-end tests for the DataReductionProxy.BypassedBytes histograms.
-class DataReductionProxyUsageStatsEndToEndTest : public testing::Test {
+class DataReductionProxyBypassStatsEndToEndTest : public testing::Test {
public:
- DataReductionProxyUsageStatsEndToEndTest()
+ DataReductionProxyBypassStatsEndToEndTest()
: context_(true), context_storage_(&context_) {}
- ~DataReductionProxyUsageStatsEndToEndTest() override {
+ ~DataReductionProxyBypassStatsEndToEndTest() override {
drp_test_context_->io_data()->ShutdownOnUIThread();
drp_test_context_->RunUntilIdle();
}
@@ -645,9 +538,7 @@ class DataReductionProxyUsageStatsEndToEndTest : public testing::Test {
return drp_test_context_->config();
}
- void ClearBadProxies() {
- context_.proxy_service()->ClearBadProxiesCache();
- }
+ void ClearBadProxies() { context_.proxy_service()->ClearBadProxiesCache(); }
void InitializeContext() {
context_.Init();
@@ -680,8 +571,7 @@ class DataReductionProxyUsageStatsEndToEndTest : public testing::Test {
};
for (const std::string& histogram : kHistograms) {
- if (excluded_histograms.find(histogram) ==
- excluded_histograms.end()) {
+ if (excluded_histograms.find(histogram) == excluded_histograms.end()) {
histogram_tester.ExpectTotalCount(histogram, 0);
}
}
@@ -715,26 +605,29 @@ class DataReductionProxyUsageStatsEndToEndTest : public testing::Test {
scoped_ptr<DataReductionProxyTestContext> drp_test_context_;
};
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesNoRetry) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesNoRetry) {
struct TestCase {
GURL url;
const char* histogram_name;
const char* initial_response_headers;
};
const TestCase test_cases[] = {
- { GURL("http://foo.com"),
- "DataReductionProxy.BypassedBytes.NotBypassed",
- "HTTP/1.1 200 OK\r\n"
- "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n",
- },
- { GURL("https://foo.com"),
- "DataReductionProxy.BypassedBytes.SSL",
- "HTTP/1.1 200 OK\r\n\r\n",
- },
- { GURL("http://localhost"),
- "DataReductionProxy.BypassedBytes.LocalBypassRules",
- "HTTP/1.1 200 OK\r\n\r\n",
- },
+ {
+ GURL("http://foo.com"),
bengr 2015/03/24 15:47:27 Again, please revert the formatting change.
zhuoyu.qian 2015/03/28 03:06:58 Done.
+ "DataReductionProxy.BypassedBytes.NotBypassed",
+ "HTTP/1.1 200 OK\r\n"
+ "Via: 1.1 Chrome-Compression-Proxy\r\n\r\n",
+ },
+ {
+ GURL("https://foo.com"),
+ "DataReductionProxy.BypassedBytes.SSL",
+ "HTTP/1.1 200 OK\r\n\r\n",
+ },
+ {
+ GURL("http://localhost"),
+ "DataReductionProxy.BypassedBytes.LocalBypassRules",
+ "HTTP/1.1 200 OK\r\n\r\n",
+ },
};
InitializeContext();
@@ -751,7 +644,8 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesNoRetry) {
}
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesProxyOverridden) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest,
+ BypassedBytesProxyOverridden) {
scoped_ptr<net::ProxyService> proxy_service(
net::ProxyService::CreateFixed("http://test.com:80"));
set_proxy_service(proxy_service.get());
@@ -767,7 +661,7 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesProxyOverridden) {
histogram_tester, "DataReductionProxy.BypassedBytes.ProxyOverridden");
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesCurrent) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesCurrent) {
InitializeContext();
base::HistogramTester histogram_tester;
CreateAndExecuteRequest(GURL("http://foo.com"),
@@ -783,7 +677,8 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesCurrent) {
histogram_tester, "DataReductionProxy.BypassedBytes.Current");
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesShortAudioVideo) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest,
+ BypassedBytesShortAudioVideo) {
InitializeContext();
base::HistogramTester histogram_tester;
CreateAndExecuteRequest(GURL("http://foo.com"),
@@ -801,31 +696,34 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesShortAudioVideo) {
histogram_tester, "DataReductionProxy.BypassedBytes.ShortAudioVideo");
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesExplicitBypass) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesExplicitBypass) {
struct TestCase {
const char* triggering_histogram_name;
const char* all_histogram_name;
const char* initial_response_headers;
};
const TestCase test_cases[] = {
- { "DataReductionProxy.BypassedBytes.ShortTriggeringRequest",
- "DataReductionProxy.BypassedBytes.ShortAll",
- "HTTP/1.1 502 Bad Gateway\r\n"
- "Via: 1.1 Chrome-Compression-Proxy\r\n"
- "Chrome-Proxy: block=1\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.MediumTriggeringRequest",
- "DataReductionProxy.BypassedBytes.MediumAll",
- "HTTP/1.1 502 Bad Gateway\r\n"
- "Via: 1.1 Chrome-Compression-Proxy\r\n"
- "Chrome-Proxy: block=0\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.LongTriggeringRequest",
- "DataReductionProxy.BypassedBytes.LongAll",
- "HTTP/1.1 502 Bad Gateway\r\n"
- "Via: 1.1 Chrome-Compression-Proxy\r\n"
- "Chrome-Proxy: block=3600\r\n\r\n",
- },
+ {
+ "DataReductionProxy.BypassedBytes.ShortTriggeringRequest",
bengr 2015/03/24 15:47:27 Here too.
zhuoyu.qian 2015/03/28 03:06:58 Done.
+ "DataReductionProxy.BypassedBytes.ShortAll",
+ "HTTP/1.1 502 Bad Gateway\r\n"
+ "Via: 1.1 Chrome-Compression-Proxy\r\n"
+ "Chrome-Proxy: block=1\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.MediumTriggeringRequest",
+ "DataReductionProxy.BypassedBytes.MediumAll",
+ "HTTP/1.1 502 Bad Gateway\r\n"
+ "Via: 1.1 Chrome-Compression-Proxy\r\n"
+ "Chrome-Proxy: block=0\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.LongTriggeringRequest",
+ "DataReductionProxy.BypassedBytes.LongAll",
+ "HTTP/1.1 502 Bad Gateway\r\n"
+ "Via: 1.1 Chrome-Compression-Proxy\r\n"
+ "Chrome-Proxy: block=3600\r\n\r\n",
+ },
};
InitializeContext();
@@ -851,31 +749,37 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesExplicitBypass) {
}
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest,
+TEST_F(DataReductionProxyBypassStatsEndToEndTest,
BypassedBytesClientSideFallback) {
struct TestCase {
const char* histogram_name;
const char* initial_response_headers;
};
const TestCase test_cases[] = {
- { "DataReductionProxy.BypassedBytes.MissingViaHeader4xx",
- "HTTP/1.1 414 Request-URI Too Long\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.MissingViaHeaderOther",
- "HTTP/1.1 200 OK\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.Malformed407",
- "HTTP/1.1 407 Proxy Authentication Required\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.Status500HttpInternalServerError",
- "HTTP/1.1 500 Internal Server Error\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.Status502HttpBadGateway",
- "HTTP/1.1 502 Bad Gateway\r\n\r\n",
- },
- { "DataReductionProxy.BypassedBytes.Status503HttpServiceUnavailable",
- "HTTP/1.1 503 Service Unavailable\r\n\r\n",
- },
+ {
+ "DataReductionProxy.BypassedBytes.MissingViaHeader4xx",
bengr 2015/03/24 15:47:27 And here.
zhuoyu.qian 2015/03/28 03:06:58 Done.
+ "HTTP/1.1 414 Request-URI Too Long\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.MissingViaHeaderOther",
+ "HTTP/1.1 200 OK\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.Malformed407",
+ "HTTP/1.1 407 Proxy Authentication Required\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.Status500HttpInternalServerError",
+ "HTTP/1.1 500 Internal Server Error\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.Status502HttpBadGateway",
+ "HTTP/1.1 502 Bad Gateway\r\n\r\n",
+ },
+ {
+ "DataReductionProxy.BypassedBytes.Status503HttpServiceUnavailable",
+ "HTTP/1.1 503 Service Unavailable\r\n\r\n",
+ },
};
InitializeContext();
@@ -901,7 +805,7 @@ TEST_F(DataReductionProxyUsageStatsEndToEndTest,
}
}
-TEST_F(DataReductionProxyUsageStatsEndToEndTest, BypassedBytesNetErrorOther) {
+TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesNetErrorOther) {
// Make the data reduction proxy host fail to resolve.
scoped_ptr<net::MockHostResolver> host_resolver(new net::MockHostResolver());
host_resolver->rules()->AddSimulatedFailure(

Powered by Google App Engine
This is Rietveld 408576698