| 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/values.h" | 7 #include "base/values.h" |
| 8 #include "net/cert/cert_verifier.h" | 8 #include "net/cert/cert_verifier.h" |
| 9 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 10 #include "net/proxy/proxy_config.h" | 10 #include "net/proxy/proxy_config.h" |
| 11 #include "net/proxy/proxy_config_service_fixed.h" | 11 #include "net/proxy/proxy_config_service_fixed.h" |
| 12 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
| 13 #include "net/url_request/url_request_context_builder.h" | 13 #include "net/url_request/url_request_context_builder.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace cronet { | 16 namespace cronet { |
| 17 | 17 |
| 18 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { | 18 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { |
| 19 URLRequestContextConfig config( | 19 URLRequestContextConfig config( |
| 20 // Enable QUIC. | 20 // Enable QUIC. |
| 21 true, | 21 true, |
| 22 // QUIC User Agent ID. |
| 23 "Default QUIC User Agent ID", |
| 22 // Enable SPDY. | 24 // Enable SPDY. |
| 23 true, | 25 true, |
| 24 // Enable SDCH. | 26 // Enable SDCH. |
| 25 false, | 27 false, |
| 26 // Type of http cache. | 28 // Type of http cache. |
| 27 URLRequestContextConfig::HttpCacheType::DISK, | 29 URLRequestContextConfig::HttpCacheType::DISK, |
| 28 // Max size of http cache in bytes. | 30 // Max size of http cache in bytes. |
| 29 1024000, | 31 1024000, |
| 30 // Disable caching for HTTP responses. Other information may be stored in | 32 // Disable caching for HTTP responses. Other information may be stored in |
| 31 // the cache. | 33 // the cache. |
| 32 false, | 34 false, |
| 33 // Storage path for http cache and cookie storage. | 35 // Storage path for http cache and cookie storage. |
| 34 "/data/data/org.chromium.net/app_cronet_test/test_storage", | 36 "/data/data/org.chromium.net/app_cronet_test/test_storage", |
| 35 // User-Agent request header field. | 37 // User-Agent request header field. |
| 36 "fake agent", | 38 "fake agent", |
| 37 // JSON encoded experimental options. | 39 // JSON encoded experimental options. |
| 38 "{\"QUIC\":{\"max_server_configs_stored_in_properties\":2," | 40 "{\"QUIC\":{\"max_server_configs_stored_in_properties\":2," |
| 39 "\"delay_tcp_race\":true," | 41 "\"delay_tcp_race\":true," |
| 40 "\"max_number_of_lossy_connections\":10," | 42 "\"max_number_of_lossy_connections\":10," |
| 43 "\"prefer_aes\":true," |
| 44 "\"user_agent_id\":\"Custom QUIC UAID\"," |
| 41 "\"packet_loss_threshold\":0.5," | 45 "\"packet_loss_threshold\":0.5," |
| 42 "\"idle_connection_timeout_seconds\":300," | 46 "\"idle_connection_timeout_seconds\":300," |
| 43 "\"close_sessions_on_ip_change\":true," | 47 "\"close_sessions_on_ip_change\":true," |
| 44 "\"migrate_sessions_on_network_change\":true," | 48 "\"migrate_sessions_on_network_change\":true," |
| 45 "\"connection_options\":\"TIME,TBBR,REJ\"}," | 49 "\"connection_options\":\"TIME,TBBR,REJ\"}," |
| 46 "\"AsyncDNS\":{\"enable\":true}}", | 50 "\"AsyncDNS\":{\"enable\":true}}", |
| 47 // Data reduction proxy key. | 51 // Data reduction proxy key. |
| 48 "", | 52 "", |
| 49 // Data reduction proxy. | 53 // Data reduction proxy. |
| 50 "", | 54 "", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 scoped_ptr<net::URLRequestContext> context(builder.Build()); | 68 scoped_ptr<net::URLRequestContext> context(builder.Build()); |
| 65 const net::HttpNetworkSession::Params* params = | 69 const net::HttpNetworkSession::Params* params = |
| 66 context->GetNetworkSessionParams(); | 70 context->GetNetworkSessionParams(); |
| 67 // Check Quic Connection options. | 71 // Check Quic Connection options. |
| 68 net::QuicTagVector quic_connection_options; | 72 net::QuicTagVector quic_connection_options; |
| 69 quic_connection_options.push_back(net::kTIME); | 73 quic_connection_options.push_back(net::kTIME); |
| 70 quic_connection_options.push_back(net::kTBBR); | 74 quic_connection_options.push_back(net::kTBBR); |
| 71 quic_connection_options.push_back(net::kREJ); | 75 quic_connection_options.push_back(net::kREJ); |
| 72 EXPECT_EQ(quic_connection_options, params->quic_connection_options); | 76 EXPECT_EQ(quic_connection_options, params->quic_connection_options); |
| 73 | 77 |
| 78 // Check Custom QUIC User Agent Id. |
| 79 EXPECT_EQ("Custom QUIC UAID", params->quic_user_agent_id); |
| 80 |
| 74 // Check max_server_configs_stored_in_properties. | 81 // Check max_server_configs_stored_in_properties. |
| 75 EXPECT_EQ(2u, params->quic_max_server_configs_stored_in_properties); | 82 EXPECT_EQ(2u, params->quic_max_server_configs_stored_in_properties); |
| 76 | 83 |
| 77 // Check delay_tcp_race. | 84 // Check delay_tcp_race. |
| 78 EXPECT_TRUE(params->quic_delay_tcp_race); | 85 EXPECT_TRUE(params->quic_delay_tcp_race); |
| 79 | 86 |
| 87 // Check prefer_aes. |
| 88 EXPECT_TRUE(params->quic_prefer_aes); |
| 89 |
| 80 // Check max_number_of_lossy_connections and packet_loss_threshold. | 90 // Check max_number_of_lossy_connections and packet_loss_threshold. |
| 81 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); | 91 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); |
| 82 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); | 92 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); |
| 83 | 93 |
| 84 // Check idle_connection_timeout_seconds. | 94 // Check idle_connection_timeout_seconds. |
| 85 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds); | 95 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds); |
| 86 | 96 |
| 87 EXPECT_TRUE(params->quic_close_sessions_on_ip_change); | 97 EXPECT_TRUE(params->quic_close_sessions_on_ip_change); |
| 88 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); | 98 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); |
| 89 | 99 |
| 90 // Check AsyncDNS resolver is enabled. | 100 // Check AsyncDNS resolver is enabled. |
| 91 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue()); | 101 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue()); |
| 92 } | 102 } |
| 93 | 103 |
| 94 } // namespace cronet | 104 } // namespace cronet |
| OLD | NEW |