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

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

Issue 1310743003: Consistently use LoFi for an entire page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using UserData and adressing nasko comments Created 5 years, 3 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_request_options_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
index 511f8d993e53832865d5c97d8a1d40ca636dd02e..a2891f1254181c2720e5fec0548bd974d3f97814 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options_unittest.cc
@@ -154,11 +154,10 @@ class DataReductionProxyRequestOptionsTest : public testing::Test {
request_options_->Init();
}
- void CreateRequest(int load_flags) {
+ void CreateRequest() {
net::URLRequestContext* context =
test_context_->request_context_getter()->GetURLRequestContext();
request_ = context->CreateRequest(GURL(), net::DEFAULT_PRIORITY, nullptr);
- request_->SetLoadFlags(load_flags);
}
TestDataReductionProxyParams* params() {
@@ -170,7 +169,8 @@ class DataReductionProxyRequestOptionsTest : public testing::Test {
}
void VerifyExpectedHeader(const std::string& proxy_uri,
- const std::string& expected_header) {
+ const std::string& expected_header,
+ bool is_lofi_on) {
test_context_->RunUntilIdle();
net::HttpRequestHeaders headers;
request_options_->MaybeAddRequestHeader(
@@ -178,7 +178,7 @@ class DataReductionProxyRequestOptionsTest : public testing::Test {
proxy_uri.empty() ? net::ProxyServer()
: net::ProxyServer::FromURI(
proxy_uri, net::ProxyServer::SCHEME_HTTP),
- &headers);
+ &headers, is_lofi_on);
if (expected_header.empty()) {
EXPECT_FALSE(headers.HasHeader(kChromeProxyHeader));
return;
@@ -225,16 +225,16 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) {
request_options()->SetKeyOnIO(kTestKey2);
// Don't write headers if the proxy is invalid.
- VerifyExpectedHeader(std::string(), std::string());
+ VerifyExpectedHeader(std::string(), std::string(), false);
// Don't write headers with a valid proxy, that's not a data reduction proxy.
- VerifyExpectedHeader(kOtherProxy, std::string());
+ VerifyExpectedHeader(kOtherProxy, std::string(), false);
// Don't write headers with a valid data reduction ssl proxy.
- VerifyExpectedHeader(params()->DefaultSSLOrigin(), std::string());
+ VerifyExpectedHeader(params()->DefaultSSLOrigin(), std::string(), false);
// Write headers with a valid data reduction proxy.
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
// Write headers with a valid data reduction ssl proxy when one is expected.
net::HttpRequestHeaders ssl_headers;
@@ -250,11 +250,11 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) {
// Fast forward 24 hours. The header should be the same.
request_options()->set_offset(base::TimeDelta::FromSeconds(24 * 60 * 60));
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
// Fast forward one more second. The header should be new.
request_options()->set_offset(base::TimeDelta::FromSeconds(24 * 60 * 60 + 1));
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header2);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header2, false);
}
TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) {
@@ -264,12 +264,12 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) {
std::string(), std::vector<std::string>(),
&expected_header);
CreateRequestOptions(kVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
// Now set an empty key. The auth handler should ignore that, and the key
// remains |kTestKey|.
request_options()->SetKeyOnIO(std::string());
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
}
TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationBogusVersion) {
@@ -282,7 +282,7 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationBogusVersion) {
// Now set a key.
request_options()->SetKeyOnIO(kTestKey2);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
}
TEST_F(DataReductionProxyRequestOptionsTest, LoFiOnThroughCommandLineSwitch) {
@@ -291,10 +291,11 @@ TEST_F(DataReductionProxyRequestOptionsTest, LoFiOnThroughCommandLineSwitch) {
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(),
kClientStr, std::string(), std::string(), std::string(),
std::vector<std::string>(), &expected_header);
-
- test_context_->config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
+ CreateRequest();
CreateRequestOptions(kBogusVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(
+ params()->DefaultOrigin(), expected_header,
+ test_context_->config()->ShouldTurnOnLoFiOnMainFrameRequest(nullptr));
test_context_->config()->ResetLoFiStatusForTest();
// Add the LoFi command line switch.
@@ -306,9 +307,10 @@ TEST_F(DataReductionProxyRequestOptionsTest, LoFiOnThroughCommandLineSwitch) {
kClientStr, std::string(), std::string(), "low",
std::vector<std::string>(), &expected_header);
- test_context_->config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
CreateRequestOptions(kBogusVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(
+ params()->DefaultOrigin(), expected_header,
+ test_context_->config()->ShouldTurnOnLoFiOnMainFrameRequest(nullptr));
}
TEST_F(DataReductionProxyRequestOptionsTest, AutoLoFi) {
@@ -355,11 +357,12 @@ TEST_F(DataReductionProxyRequestOptionsTest, AutoLoFi) {
test_context_->config()->SetNetworkProhibitivelySlow(
tests[i].network_prohibitively_slow);
- // Force update Lo-Fi status.
- test_context_->config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
+ CreateRequest();
CreateRequestOptions(kBogusVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(
+ params()->DefaultOrigin(), expected_header,
+ test_context_->config()->ShouldTurnOnLoFiOnMainFrameRequest(nullptr));
}
}
@@ -433,11 +436,12 @@ TEST_F(DataReductionProxyRequestOptionsTest, SlowConnectionsFlag) {
test_context_->config()->SetNetworkProhibitivelySlow(
tests[i].network_prohibitively_slow);
- // Force update Lo-Fi status.
- test_context_->config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
+ CreateRequest();
CreateRequestOptions(kBogusVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(
+ params()->DefaultOrigin(), expected_header,
+ test_context_->config()->ShouldTurnOnLoFiOnMainFrameRequest(nullptr));
}
}
@@ -449,7 +453,7 @@ TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) {
CreateRequestOptions(kBogusVersion);
request_options()->SetSecureSession(kSecureSession);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
}
TEST_F(DataReductionProxyRequestOptionsTest, ParseExperiments) {
@@ -465,7 +469,7 @@ TEST_F(DataReductionProxyRequestOptionsTest, ParseExperiments) {
expected_experiments, &expected_header);
CreateRequestOptions(kBogusVersion);
- VerifyExpectedHeader(params()->DefaultOrigin(), expected_header);
+ VerifyExpectedHeader(params()->DefaultOrigin(), expected_header, false);
}
TEST_F(DataReductionProxyRequestOptionsTest, ParseLocalSessionKey) {

Powered by Google App Engine
This is Rietveld 408576698