Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/cronet/url_request_context_config.h" | 5 #include "components/cronet/url_request_context_config.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "net/cert/cert_verifier.h" | 9 #include "net/cert/cert_verifier.h" |
| 10 #include "net/http/http_network_session.h" | 10 #include "net/http/http_network_session.h" |
| 11 #include "net/proxy/proxy_config.h" | 11 #include "net/proxy/proxy_config.h" |
| 12 #include "net/proxy/proxy_config_service_fixed.h" | 12 #include "net/proxy/proxy_config_service_fixed.h" |
| 13 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" |
| 14 #include "net/url_request/url_request_context_builder.h" | 14 #include "net/url_request/url_request_context_builder.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace cronet { | 17 namespace cronet { |
| 18 | 18 |
| 19 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { | 19 TEST(URLRequestContextConfigTest, TestExperimentalOptionPassing) { |
| 20 URLRequestContextConfig config( | 20 URLRequestContextConfig config( |
| 21 // Enable QUIC. | 21 // Enable QUIC. |
| 22 true, | 22 true, |
| 23 // QUIC User Agent ID. | 23 // QUIC User Agent ID. |
| 24 "Default QUIC User Agent ID", | 24 "Default QUIC User Agent ID", |
| 25 // Enable SPDY. | 25 // Enable SPDY. |
| 26 true, | 26 true, |
| 27 // Enable SDCH. | 27 // Enable SDCH. |
| 28 false, | 28 false, |
| 29 // Type of http cache. | 29 // Type of http cache. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 40 // JSON encoded experimental options. | 40 // JSON encoded experimental options. |
| 41 "{\"QUIC\":{\"max_server_configs_stored_in_properties\":2," | 41 "{\"QUIC\":{\"max_server_configs_stored_in_properties\":2," |
| 42 "\"delay_tcp_race\":true," | 42 "\"delay_tcp_race\":true," |
| 43 "\"max_number_of_lossy_connections\":10," | 43 "\"max_number_of_lossy_connections\":10," |
| 44 "\"prefer_aes\":true," | 44 "\"prefer_aes\":true," |
| 45 "\"user_agent_id\":\"Custom QUIC UAID\"," | 45 "\"user_agent_id\":\"Custom QUIC UAID\"," |
| 46 "\"packet_loss_threshold\":0.5," | 46 "\"packet_loss_threshold\":0.5," |
| 47 "\"idle_connection_timeout_seconds\":300," | 47 "\"idle_connection_timeout_seconds\":300," |
| 48 "\"close_sessions_on_ip_change\":true," | 48 "\"close_sessions_on_ip_change\":true," |
| 49 "\"connection_options\":\"TIME,TBBR,REJ\"}," | 49 "\"connection_options\":\"TIME,TBBR,REJ\"}," |
| 50 "\"AsyncDNS\":{\"enable\":true}}", | 50 "\"AsyncDNS\":{\"enable\":true}," |
| 51 "\"HostResolverRules\":{\"host_resolver_rules\":" | |
| 52 "\"MAP * 127.0.0.1\"}}", | |
| 51 // Data reduction proxy key. | 53 // Data reduction proxy key. |
| 52 "", | 54 "", |
| 53 // Data reduction proxy. | 55 // Data reduction proxy. |
| 54 "", | 56 "", |
| 55 // Fallback data reduction proxy. | 57 // Fallback data reduction proxy. |
| 56 "", | 58 "", |
| 57 // Data reduction proxy secure proxy check URL. | 59 // Data reduction proxy secure proxy check URL. |
| 58 "", | 60 "", |
| 59 // MockCertVerifier to use for testing purposes. | 61 // MockCertVerifier to use for testing purposes. |
| 60 std::unique_ptr<net::CertVerifier>()); | 62 std::unique_ptr<net::CertVerifier>()); |
| 61 | 63 |
| 62 net::URLRequestContextBuilder builder; | 64 net::URLRequestContextBuilder builder; |
| 63 net::NetLog net_log; | 65 config.ConfigureURLRequestContextBuilder(&builder, new net::NetLog(), |
|
pauljensen
2016/06/10 14:19:37
why the change to create NetLog on the heap? look
mgersh
2016/06/29 17:43:31
Done.
| |
| 64 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr); | 66 nullptr); |
| 65 // Set a ProxyConfigService to avoid DCHECK failure when building. | 67 // Set a ProxyConfigService to avoid DCHECK failure when building. |
| 66 builder.set_proxy_config_service(base::WrapUnique( | 68 builder.set_proxy_config_service(base::WrapUnique( |
| 67 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); | 69 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); |
| 68 std::unique_ptr<net::URLRequestContext> context(builder.Build()); | 70 std::unique_ptr<net::URLRequestContext> context(builder.Build()); |
| 69 const net::HttpNetworkSession::Params* params = | 71 const net::HttpNetworkSession::Params* params = |
| 70 context->GetNetworkSessionParams(); | 72 context->GetNetworkSessionParams(); |
| 71 // Check Quic Connection options. | 73 // Check Quic Connection options. |
| 72 net::QuicTagVector quic_connection_options; | 74 net::QuicTagVector quic_connection_options; |
| 73 quic_connection_options.push_back(net::kTIME); | 75 quic_connection_options.push_back(net::kTIME); |
| 74 quic_connection_options.push_back(net::kTBBR); | 76 quic_connection_options.push_back(net::kTBBR); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 91 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); | 93 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); |
| 92 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); | 94 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); |
| 93 | 95 |
| 94 // Check idle_connection_timeout_seconds. | 96 // Check idle_connection_timeout_seconds. |
| 95 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds); | 97 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds); |
| 96 | 98 |
| 97 EXPECT_TRUE(params->quic_close_sessions_on_ip_change); | 99 EXPECT_TRUE(params->quic_close_sessions_on_ip_change); |
| 98 EXPECT_FALSE(params->quic_migrate_sessions_on_network_change); | 100 EXPECT_FALSE(params->quic_migrate_sessions_on_network_change); |
| 99 | 101 |
| 100 // Check AsyncDNS resolver is enabled. | 102 // Check AsyncDNS resolver is enabled. |
| 101 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue()); | 103 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue()); |
|
pauljensen
2016/06/10 14:19:37
Please add a test that the rules were installed in
mgersh
2016/06/29 17:43:31
Done.
| |
| 102 } | 104 } |
| 103 | 105 |
| 104 TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationOptions) { | 106 TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationOptions) { |
| 105 URLRequestContextConfig config( | 107 URLRequestContextConfig config( |
| 106 // Enable QUIC. | 108 // Enable QUIC. |
| 107 true, | 109 true, |
| 108 // QUIC User Agent ID. | 110 // QUIC User Agent ID. |
| 109 "Default QUIC User Agent ID", | 111 "Default QUIC User Agent ID", |
| 110 // Enable SPDY. | 112 // Enable SPDY. |
| 111 true, | 113 true, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 130 // Data reduction proxy. | 132 // Data reduction proxy. |
| 131 "", | 133 "", |
| 132 // Fallback data reduction proxy. | 134 // Fallback data reduction proxy. |
| 133 "", | 135 "", |
| 134 // Data reduction proxy secure proxy check URL. | 136 // Data reduction proxy secure proxy check URL. |
| 135 "", | 137 "", |
| 136 // MockCertVerifier to use for testing purposes. | 138 // MockCertVerifier to use for testing purposes. |
| 137 std::unique_ptr<net::CertVerifier>()); | 139 std::unique_ptr<net::CertVerifier>()); |
| 138 | 140 |
| 139 net::URLRequestContextBuilder builder; | 141 net::URLRequestContextBuilder builder; |
| 140 net::NetLog net_log; | 142 config.ConfigureURLRequestContextBuilder(&builder, new net::NetLog(), |
| 141 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr); | 143 nullptr); |
| 142 // Set a ProxyConfigService to avoid DCHECK failure when building. | 144 // Set a ProxyConfigService to avoid DCHECK failure when building. |
| 143 builder.set_proxy_config_service(base::WrapUnique( | 145 builder.set_proxy_config_service(base::WrapUnique( |
| 144 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); | 146 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); |
| 145 std::unique_ptr<net::URLRequestContext> context(builder.Build()); | 147 std::unique_ptr<net::URLRequestContext> context(builder.Build()); |
| 146 const net::HttpNetworkSession::Params* params = | 148 const net::HttpNetworkSession::Params* params = |
| 147 context->GetNetworkSessionParams(); | 149 context->GetNetworkSessionParams(); |
| 148 | 150 |
| 149 EXPECT_FALSE(params->quic_close_sessions_on_ip_change); | 151 EXPECT_FALSE(params->quic_close_sessions_on_ip_change); |
| 150 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); | 152 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); |
| 151 EXPECT_TRUE(params->quic_migrate_sessions_early); | 153 EXPECT_TRUE(params->quic_migrate_sessions_early); |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace cronet | 156 } // namespace cronet |
| OLD | NEW |