Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
| index 5bc90cc3fc3a48fb6accc768448696b7ab8274c1..81e6646e663b8f4bd480d8320c19af5c1377552a 100644 |
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
| @@ -17,20 +17,21 @@ |
| #include "base/metrics/field_trial.h" |
| #include "base/numerics/safe_conversions.h" |
| #include "base/run_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/test/histogram_tester.h" |
| #include "base/test/mock_entropy_provider.h" |
| #include "base/time/time.h" |
| #include "base/values.h" |
| #include "build/build_config.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" |
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" |
| #include "components/data_reduction_proxy/core/common/lofi_decider.h" |
| #include "net/base/host_port_pair.h" |
| #include "net/base/load_flags.h" |
| @@ -405,20 +406,74 @@ TEST_F(DataReductionProxyNetworkDelegateTest, LoFiTransitions) { |
| lofi_decider()->SetIsUsingLoFiMode( |
| config()->ShouldEnableLoFiMode(*fake_request.get())); |
| network_delegate()->NotifyBeforeSendProxyHeaders( |
| fake_request.get(), data_reduction_proxy_info, &headers); |
| VerifyLoFiHeader(true, headers); |
| VerifyWasLoFiModeActiveOnMainFrame(true); |
| } |
| } |
| } |
| +TEST_F(DataReductionProxyNetworkDelegateTest, RequestDataConfigurations) { |
| + const struct { |
| + bool lofi_on; |
| + bool used_drp; |
| + } tests[] = { |
| + { |
| + // Lo-Fi off |
| + false, true, |
| + }, |
| + { |
| + // DRP not used |
| + false, false, |
| + }, |
| + { |
| + // DRP not used, Lo-Fi should not be used |
| + true, false, |
| + }, |
| + { |
| + // Lo-Fi on |
| + true, true, |
| + }, |
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(tests); ++i) { |
| + net::ProxyInfo data_reduction_proxy_info; |
|
bengr
2016/04/29 21:14:22
#include "net/proxy/proxy_info.h"
RyanSturm
2016/05/02 19:52:21
Done.
|
| + std::string data_reduction_proxy; |
| + base::TrimString(params()->DefaultOrigin(), "/", &data_reduction_proxy); |
|
bengr
2016/04/29 21:14:22
#include "base/string/string_util.h"
RyanSturm
2016/05/02 19:52:21
Done.
|
| + if (tests[i].used_drp) |
| + data_reduction_proxy_info.UseNamedProxy(data_reduction_proxy); |
| + else |
| + data_reduction_proxy_info.UseNamedProxy("port.of.other.proxy"); |
| + { |
|
bengr
2016/04/29 21:14:22
Add a blank line above.
RyanSturm
2016/05/02 19:52:21
Done.
|
| + // Main frame loaded. Lo-Fi should be used. |
| + net::HttpRequestHeaders headers; |
| + |
| + std::unique_ptr<net::URLRequest> fake_request(FetchURLRequest( |
| + GURL("http://www.google.com/"), nullptr, std::string(), 0)); |
|
bengr
2016/04/29 21:14:22
#include gurl.h
RyanSturm
2016/05/02 19:52:21
Done.
|
| + fake_request->SetLoadFlags(net::LOAD_MAIN_FRAME); |
| + lofi_decider()->SetIsUsingLoFiMode(tests[i].lofi_on); |
| + network_delegate()->NotifyBeforeSendProxyHeaders( |
| + fake_request.get(), data_reduction_proxy_info, &headers); |
| + DataReductionProxyData* data = |
| + DataReductionProxyData::DataForRequest(fake_request.get(), false); |
| + if (!tests[i].used_drp) { |
|
bengr
2016/04/29 21:14:22
Why is this all negated?
if (tests[i].used_drp) {
RyanSturm
2016/05/02 19:52:21
Done.
|
| + EXPECT_TRUE(!data); |
| + } else { |
| + EXPECT_FALSE(!data); |
| + EXPECT_TRUE(data->get_used_data_reduction_proxy()); |
| + EXPECT_EQ(tests[i].lofi_on, data->get_is_using_lofi()); |
| + } |
| + } |
| + } |
| +} |
| + |
| TEST_F(DataReductionProxyNetworkDelegateTest, NetHistograms) { |
| const std::string kReceivedValidOCLHistogramName = |
| "Net.HttpContentLengthWithValidOCL"; |
| const std::string kOriginalValidOCLHistogramName = |
| "Net.HttpOriginalContentLengthWithValidOCL"; |
| const std::string kDifferenceValidOCLHistogramName = |
| "Net.HttpContentLengthDifferenceWithValidOCL"; |
| // Lo-Fi histograms. |
| const std::string kReceivedValidOCLLoFiOnHistogramName = |