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

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

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, Tests, Ready for Review Created 4 years, 8 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_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;
+ std::string data_reduction_proxy;
+ base::TrimString(params()->DefaultOrigin(), "/", &data_reduction_proxy);
+ if (tests[i].used_drp)
+ data_reduction_proxy_info.UseNamedProxy(data_reduction_proxy);
+ else
+ data_reduction_proxy_info.UseNamedProxy("port.of.other.proxy");
+ {
+ // 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));
+ 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) {
+ 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 =

Powered by Google App Engine
This is Rietveld 408576698