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

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

Issue 2442633002: Add a QUIC proxy server to the list of QUIC servers supported at start up (Closed)
Patch Set: Rebased, Addressed ryansturm comments Created 4 years, 2 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_delegate_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
index 6d99189e360f59a2c832395d52c8b5a6cdaf2827..cdae9214e88c13ecbf425c6220dce50326cd2f2e 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate_unittest.cc
@@ -124,9 +124,46 @@ class TestDataReductionProxyDelegate : public DataReductionProxyDelegate {
}
}
+ void VerifyQuicProxyAtStartupHistogram(
+ const base::HistogramTester& histogram_tester,
+ bool is_in_quic_field_trial,
+ bool use_proxyzip_proxy_as_first_proxy,
+ bool alternative_proxy_broken) {
+ static const char kHistogram[] =
+ "DataReductionProxy.Quic.ProxyServerAtStartUpQueried";
+ if (is_in_quic_field_trial && use_proxyzip_proxy_as_first_proxy &&
+ !alternative_proxy_broken) {
+ histogram_tester.ExpectUniqueSample(
+ kHistogram, TestDataReductionProxyDelegate::QuicProxyAtStartup::
+ QUIC_PROXY_AT_STARTUP_AVAILABLE,
+ 1);
+ return;
+ }
+
+ if (is_in_quic_field_trial && alternative_proxy_broken) {
+ histogram_tester.ExpectUniqueSample(
+ kHistogram, TestDataReductionProxyDelegate::QuicProxyAtStartup::
+ QUIC_PROXY_AT_STARTUP_BROKEN,
+ 1);
+ return;
+ }
+
+ if (is_in_quic_field_trial && !use_proxyzip_proxy_as_first_proxy) {
+ histogram_tester.ExpectUniqueSample(
+ kHistogram, TestDataReductionProxyDelegate::QuicProxyAtStartup::
+ QUIC_PROXY_AT_STARTUP_UNAVAILABLE,
+ 1);
+ return;
+ }
+
+ histogram_tester.ExpectTotalCount(kHistogram, 0);
+ }
+
using DataReductionProxyDelegate::GetAlternativeProxy;
using DataReductionProxyDelegate::OnAlternativeProxyBroken;
+ using DataReductionProxyDelegate::GetQuicSupportedProxyServerAtStartUp;
using DataReductionProxyDelegate::QuicProxyStatus;
+ using DataReductionProxyDelegate::QuicProxyAtStartup;
private:
const bool proxy_supports_quic_;
@@ -422,6 +459,94 @@ TEST(DataReductionProxyDelegate, AlternativeProxy) {
}
}
+// Verifies that DataReductionProxyDelegate correctly returns the proxy server
+// that supports 0-RTT.
+TEST(DataReductionProxyDelegate, AlternativeProxyAtStartUp) {
+ base::MessageLoopForIO message_loop_;
+ std::unique_ptr<DataReductionProxyTestContext> test_context =
+ DataReductionProxyTestContext::Builder()
+ .WithConfigClient()
+ .WithMockDataReductionProxyService()
+ .Build();
+
+ const struct {
+ bool is_in_quic_field_trial;
+ bool use_proxyzip_proxy_as_first_proxy;
+ } tests[] = {{false, false}, {false, true}, {true, false}, {true, true}};
+ for (const auto test : tests) {
+ std::vector<net::ProxyServer> proxies_for_http;
+ net::ProxyServer first_proxy;
+ net::ProxyServer second_proxy =
+ GetProxyWithScheme(net::ProxyServer::SCHEME_HTTP);
+
+ if (test.use_proxyzip_proxy_as_first_proxy) {
+ first_proxy =
+ net::ProxyServer(net::ProxyServer::SCHEME_QUIC,
+ net::HostPortPair("proxy.googlezip.net", 443));
+ } else {
+ first_proxy = GetProxyWithScheme(net::ProxyServer::SCHEME_HTTPS);
+ }
+
+ proxies_for_http.push_back(first_proxy);
+ proxies_for_http.push_back(second_proxy);
+
+ std::unique_ptr<DataReductionProxyMutableConfigValues> config_values =
+ DataReductionProxyMutableConfigValues::CreateFromParams(
+ test_context->test_params());
+ config_values->UpdateValues(proxies_for_http);
+
+ std::unique_ptr<DataReductionProxyConfig> config(
+ new DataReductionProxyConfig(
+ message_loop_.task_runner(), test_context->net_log(),
+ std::move(config_values), test_context->configurator(),
+ test_context->event_creator()));
+
+ TestDataReductionProxyDelegate delegate(
+ config.get(), test_context->io_data()->configurator(),
+ test_context->io_data()->event_creator(),
+ test_context->io_data()->bypass_stats(), true,
+ test_context->io_data()->net_log());
+
+ base::FieldTrialList field_trial_list(nullptr);
+ base::FieldTrialList::CreateFieldTrial(
+ params::GetQuicFieldTrialName(),
+ test.is_in_quic_field_trial ? "Enabled" : "Control");
+
+ {
+ // Test if the QUIC supporting proxy is correctly set.
+ base::HistogramTester histogram_tester;
+ if (test.is_in_quic_field_trial &&
+ test.use_proxyzip_proxy_as_first_proxy) {
+ EXPECT_EQ(delegate.GetQuicSupportedProxyServerAtStartUp(), first_proxy);
+ EXPECT_TRUE(first_proxy.is_quic());
+
+ } else {
+ EXPECT_FALSE(
+ delegate.GetQuicSupportedProxyServerAtStartUp().is_valid());
+ }
+
+ delegate.VerifyQuicProxyAtStartupHistogram(
+ histogram_tester, test.is_in_quic_field_trial,
+ test.use_proxyzip_proxy_as_first_proxy, false);
+ }
+
+ {
+ // Test if the QUIC supporting proxy is correctly set if the proxy is
+ // marked as broken.
+ base::HistogramTester histogram_tester;
+
+ if (test.is_in_quic_field_trial &&
+ test.use_proxyzip_proxy_as_first_proxy) {
+ delegate.OnAlternativeProxyBroken(first_proxy);
+ EXPECT_FALSE(delegate.GetQuicSupportedProxyServerAtStartUp().is_quic());
+ delegate.VerifyQuicProxyAtStartupHistogram(
+ histogram_tester, test.is_in_quic_field_trial,
+ test.use_proxyzip_proxy_as_first_proxy, true);
+ }
+ }
+ }
+}
+
#if defined(OS_ANDROID)
const Client kClient = Client::CHROME_ANDROID;
#elif defined(OS_IOS)

Powered by Google App Engine
This is Rietveld 408576698