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

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

Issue 2963643002: Fix Cronet tests. (Closed)
Patch Set: Merge, fix formatting Created 3 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
« no previous file with comments | « components/cronet/stale_host_resolver_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop/message_loop.h" 8 #include "base/test/scoped_task_environment.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "net/cert/cert_verifier.h" 10 #include "net/cert/cert_verifier.h"
11 #include "net/http/http_network_session.h" 11 #include "net/http/http_network_session.h"
12 #include "net/log/net_log.h" 12 #include "net/log/net_log.h"
13 #include "net/log/net_log_with_source.h" 13 #include "net/log/net_log_with_source.h"
14 #include "net/proxy/proxy_config.h" 14 #include "net/proxy/proxy_config.h"
15 #include "net/proxy/proxy_config_service_fixed.h" 15 #include "net/proxy/proxy_config_service_fixed.h"
16 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
17 #include "net/url_request/url_request_context_builder.h" 17 #include "net/url_request/url_request_context_builder.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace cronet { 20 namespace cronet {
21 21
22 // Test is flaky. See https://crbug.com/737326. 22 TEST(URLRequestContextConfigTest, TestExperimentalOptionParsing) {
23 TEST(URLRequestContextConfigTest, DISABLED_TestExperimentalOptionParsing) { 23 base::test::ScopedTaskEnvironment scoped_task_environment_(
24 base::test::ScopedTaskEnvironment::MainThreadType::IO);
25
24 URLRequestContextConfig config( 26 URLRequestContextConfig config(
25 // Enable QUIC. 27 // Enable QUIC.
26 true, 28 true,
27 // QUIC User Agent ID. 29 // QUIC User Agent ID.
28 "Default QUIC User Agent ID", 30 "Default QUIC User Agent ID",
29 // Enable SPDY. 31 // Enable SPDY.
30 true, 32 true,
31 // Enable SDCH. 33 // Enable SDCH.
32 false, 34 false,
33 // Enable Brotli. 35 // Enable Brotli.
(...skipping 24 matching lines...) Expand all
58 "\"disable_ipv6_on_wifi\":true}", 60 "\"disable_ipv6_on_wifi\":true}",
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 // Enable network quality estimator. 63 // Enable network quality estimator.
62 false, 64 false,
63 // Enable Public Key Pinning bypass for local trust anchors. 65 // Enable Public Key Pinning bypass for local trust anchors.
64 true, 66 true,
65 // Certificate verifier cache data. 67 // Certificate verifier cache data.
66 ""); 68 "");
67 69
68 base::MessageLoop message_loop;
69 net::URLRequestContextBuilder builder; 70 net::URLRequestContextBuilder builder;
70 net::NetLog net_log; 71 net::NetLog net_log;
71 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr); 72 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr);
72 EXPECT_FALSE(config.effective_experimental_options->HasKey("UnknownOption")); 73 EXPECT_FALSE(config.effective_experimental_options->HasKey("UnknownOption"));
73 // Set a ProxyConfigService to avoid DCHECK failure when building. 74 // Set a ProxyConfigService to avoid DCHECK failure when building.
74 builder.set_proxy_config_service( 75 builder.set_proxy_config_service(
75 base::MakeUnique<net::ProxyConfigServiceFixed>( 76 base::MakeUnique<net::ProxyConfigServiceFixed>(
76 net::ProxyConfig::CreateDirect())); 77 net::ProxyConfig::CreateDirect()));
77 std::unique_ptr<net::URLRequestContext> context(builder.Build()); 78 std::unique_ptr<net::URLRequestContext> context(builder.Build());
78 const net::HttpNetworkSession::Params* params = 79 const net::HttpNetworkSession::Params* params =
(...skipping 25 matching lines...) Expand all
104 105
105 // Check IPv6 is disabled when on wifi. 106 // Check IPv6 is disabled when on wifi.
106 EXPECT_TRUE(context->host_resolver()->GetNoIPv6OnWifi()); 107 EXPECT_TRUE(context->host_resolver()->GetNoIPv6OnWifi());
107 108
108 net::HostResolver::RequestInfo info(net::HostPortPair("abcde", 80)); 109 net::HostResolver::RequestInfo info(net::HostPortPair("abcde", 80));
109 net::AddressList addresses; 110 net::AddressList addresses;
110 EXPECT_EQ(net::OK, context->host_resolver()->ResolveFromCache( 111 EXPECT_EQ(net::OK, context->host_resolver()->ResolveFromCache(
111 info, &addresses, net::NetLogWithSource())); 112 info, &addresses, net::NetLogWithSource()));
112 } 113 }
113 114
114 // Test is flaky. See https://crbug.com/737326. 115 TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationOptions) {
115 TEST(URLRequestContextConfigTest, DISABLED_SetQuicConnectionMigrationOptions) { 116 base::test::ScopedTaskEnvironment scoped_task_environment_(
117 base::test::ScopedTaskEnvironment::MainThreadType::IO);
118
116 URLRequestContextConfig config( 119 URLRequestContextConfig config(
117 // Enable QUIC. 120 // Enable QUIC.
118 true, 121 true,
119 // QUIC User Agent ID. 122 // QUIC User Agent ID.
120 "Default QUIC User Agent ID", 123 "Default QUIC User Agent ID",
121 // Enable SPDY. 124 // Enable SPDY.
122 true, 125 true,
123 // Enable SDCH. 126 // Enable SDCH.
124 false, 127 false,
125 // Enable Brotli. 128 // Enable Brotli.
(...skipping 14 matching lines...) Expand all
140 "\"migrate_sessions_early\":true}}", 143 "\"migrate_sessions_early\":true}}",
141 // MockCertVerifier to use for testing purposes. 144 // MockCertVerifier to use for testing purposes.
142 std::unique_ptr<net::CertVerifier>(), 145 std::unique_ptr<net::CertVerifier>(),
143 // Enable network quality estimator. 146 // Enable network quality estimator.
144 false, 147 false,
145 // Enable Public Key Pinning bypass for local trust anchors. 148 // Enable Public Key Pinning bypass for local trust anchors.
146 true, 149 true,
147 // Certificate verifier cache data. 150 // Certificate verifier cache data.
148 ""); 151 "");
149 152
150 base::MessageLoop message_loop;
151 net::URLRequestContextBuilder builder; 153 net::URLRequestContextBuilder builder;
152 net::NetLog net_log; 154 net::NetLog net_log;
153 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr); 155 config.ConfigureURLRequestContextBuilder(&builder, &net_log, nullptr);
154 // Set a ProxyConfigService to avoid DCHECK failure when building. 156 // Set a ProxyConfigService to avoid DCHECK failure when building.
155 builder.set_proxy_config_service( 157 builder.set_proxy_config_service(
156 base::MakeUnique<net::ProxyConfigServiceFixed>( 158 base::MakeUnique<net::ProxyConfigServiceFixed>(
157 net::ProxyConfig::CreateDirect())); 159 net::ProxyConfig::CreateDirect()));
158 std::unique_ptr<net::URLRequestContext> context(builder.Build()); 160 std::unique_ptr<net::URLRequestContext> context(builder.Build());
159 const net::HttpNetworkSession::Params* params = 161 const net::HttpNetworkSession::Params* params =
160 context->GetNetworkSessionParams(); 162 context->GetNetworkSessionParams();
161 163
162 EXPECT_FALSE(params->quic_close_sessions_on_ip_change); 164 EXPECT_FALSE(params->quic_close_sessions_on_ip_change);
163 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change); 165 EXPECT_TRUE(params->quic_migrate_sessions_on_network_change);
164 EXPECT_TRUE(params->quic_migrate_sessions_early); 166 EXPECT_TRUE(params->quic_migrate_sessions_early);
165 } 167 }
166 168
167 // See stale_host_resolver_unittest.cc for test of StaleDNS options. 169 // See stale_host_resolver_unittest.cc for test of StaleDNS options.
168 170
169 } // namespace cronet 171 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/stale_host_resolver_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698