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

Side by Side Diff: components/cronet/url_request_context_config_unittest.cc

Issue 1817553002: Add host resolver rules experimental flag for Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: delete registerHostResolverProc and rebase Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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>(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); 100 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold);
99 101
100 // Check idle_connection_timeout_seconds. 102 // Check idle_connection_timeout_seconds.
101 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds); 103 EXPECT_EQ(300, params->quic_idle_connection_timeout_seconds);
102 104
103 EXPECT_TRUE(params->quic_close_sessions_on_ip_change); 105 EXPECT_TRUE(params->quic_close_sessions_on_ip_change);
104 EXPECT_FALSE(params->quic_migrate_sessions_on_network_change); 106 EXPECT_FALSE(params->quic_migrate_sessions_on_network_change);
105 107
106 // Check AsyncDNS resolver is enabled. 108 // Check AsyncDNS resolver is enabled.
107 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue()); 109 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue());
110
111 net::HostResolver::RequestInfo info(net::HostPortPair("abcde", 80));
112 net::AddressList addresses;
113 EXPECT_EQ(net::OK, context->host_resolver()->ResolveFromCache(
114 info, &addresses, net::BoundNetLog()));
108 } 115 }
109 116
110 TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationOptions) { 117 TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationOptions) {
111 URLRequestContextConfig config( 118 URLRequestContextConfig config(
112 // Enable QUIC. 119 // Enable QUIC.
113 true, 120 true,
114 // QUIC User Agent ID. 121 // QUIC User Agent ID.
115 "Default QUIC User Agent ID", 122 "Default QUIC User Agent ID",
116 // Enable SPDY. 123 // Enable SPDY.
117 true, 124 true,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 std::unique_ptr<net::URLRequestContext> context(builder.Build()); 164 std::unique_ptr<net::URLRequestContext> context(builder.Build());
158 const net::HttpNetworkSession::Params* params = 165 const net::HttpNetworkSession::Params* params =
159 context->GetNetworkSessionParams(); 166 context->GetNetworkSessionParams();
160 167
161 EXPECT_FALSE(params->quic_close_sessions_on_ip_change); 168 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
162 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); 169 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change);
163 EXPECT_TRUE(params->quic_migrate_sessions_early); 170 EXPECT_TRUE(params->quic_migrate_sessions_early);
164 } 171 }
165 172
166 } // namespace cronet 173 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698