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

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

Issue 1429863008: [Cronet] Remove JSON serialization of CronetEngine.Builder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix component_unittests Created 5 years 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/url_request_context_config_list.h ('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 "net/cert/cert_verifier.h"
7 #include "net/http/http_network_session.h" 8 #include "net/http/http_network_session.h"
8 #include "net/proxy/proxy_config.h" 9 #include "net/proxy/proxy_config.h"
9 #include "net/proxy/proxy_config_service_fixed.h" 10 #include "net/proxy/proxy_config_service_fixed.h"
10 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
11 #include "net/url_request/url_request_context_builder.h" 12 #include "net/url_request/url_request_context_builder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace cronet { 15 namespace cronet {
15 16
16 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { 17 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) {
17 URLRequestContextConfig config; 18 URLRequestContextConfig config(
19 // Enable QUIC.
20 true,
21 // Enable SPDY.
22 true,
23 // Enable SDCH.
24 false,
25 // Type of http cache.
26 URLRequestContextConfig::HttpCacheType::DISK,
27 // Max size of http cache in bytes.
28 1024000,
29 // Disable caching for HTTP responses. Other information may be stored in
30 // the cache.
31 false,
32 // Storage path for http cache and cookie storage.
33 "/data/data/org.chromium.net/app_cronet_test/test_storage",
34 // User-Agent request header field.
35 "fake agent",
36 // JSON encoded experimental options.
37 "{\"QUIC\":{\"store_server_configs_in_properties\":true,"
38 "\"delay_tcp_race\":true,"
39 "\"max_number_of_lossy_connections\":10,"
40 "\"packet_loss_threshold\":0.5,"
41 "\"connection_options\":\"TIME,TBBR,REJ\"}}",
42 // Data reduction proxy key.
43 "",
44 // Data reduction proxy.
45 "",
46 // Fallback data reduction proxy.
47 "",
48 // Data reduction proxy secure proxy check URL.
49 "",
50 // MockCertVerifier to use for testing purposes.
51 scoped_ptr<net::CertVerifier>());
18 52
19 std::string args =
20 "{\"QUIC_HINTS\":[{\"QUIC_HINT_ALT_PORT\":6121,\"QUIC_HINT_PORT\":6121,"
21 "\"QUIC_HINT_HOST\":\"test.example.com\"}],"
22 "\"HTTP_CACHE\":\"HTTP_CACHE_DISK\",\"ENABLE_SDCH\":false,"
23 "\"ENABLE_LEGACY_MODE\":false,\"HTTP_CACHE_MAX_SIZE\":1024000,"
24 "\"NATIVE_LIBRARY_NAME\":\"cronet_tests\",\"USER_AGENT\":\"fake agent\","
25 "\"STORAGE_PATH\":"
26 "\"\\/data\\/data\\/org.chromium.net\\/app_cronet_test\\/test_storage\","
27 "\"ENABLE_SPDY\":true,"
28 "\"ENABLE_QUIC\":true,\"LOAD_DISABLE_CACHE\":true,"
29 "\"EXPERIMENTAL_OPTIONS\":"
30 "\"{\\\"QUIC\\\":{\\\"store_server_configs_in_properties\\\":true,"
31 "\\\"delay_tcp_race\\\":true,"
32 "\\\"max_number_of_lossy_connections\\\":10,"
33 "\\\"packet_loss_threshold\\\":0.5,"
34 "\\\"connection_options\\\":\\\"TIME,TBBR,REJ\\\"}}\"}";
35 config.LoadFromJSON(args);
36 net::URLRequestContextBuilder builder; 53 net::URLRequestContextBuilder builder;
37 config.ConfigureURLRequestContextBuilder(&builder); 54 config.ConfigureURLRequestContextBuilder(&builder);
38 // Set a ProxyConfigService to avoid DCHECK failure when building. 55 // Set a ProxyConfigService to avoid DCHECK failure when building.
39 builder.set_proxy_config_service(make_scoped_ptr( 56 builder.set_proxy_config_service(make_scoped_ptr(
40 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); 57 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect())));
41 scoped_ptr<net::URLRequestContext> context(builder.Build()); 58 scoped_ptr<net::URLRequestContext> context(builder.Build());
42 const net::HttpNetworkSession::Params* params = 59 const net::HttpNetworkSession::Params* params =
43 context->GetNetworkSessionParams(); 60 context->GetNetworkSessionParams();
44 // Check Quic Connection options. 61 // Check Quic Connection options.
45 net::QuicTagVector quic_connection_options; 62 net::QuicTagVector quic_connection_options;
46 quic_connection_options.push_back(net::kTIME); 63 quic_connection_options.push_back(net::kTIME);
47 quic_connection_options.push_back(net::kTBBR); 64 quic_connection_options.push_back(net::kTBBR);
48 quic_connection_options.push_back(net::kREJ); 65 quic_connection_options.push_back(net::kREJ);
49 EXPECT_EQ(quic_connection_options, params->quic_connection_options); 66 EXPECT_EQ(quic_connection_options, params->quic_connection_options);
50 67
51 // Check store_server_configs_in_properties. 68 // Check store_server_configs_in_properties.
52 EXPECT_TRUE(params->quic_store_server_configs_in_properties); 69 EXPECT_TRUE(params->quic_store_server_configs_in_properties);
53 70
54 // Check delay_tcp_race. 71 // Check delay_tcp_race.
55 EXPECT_TRUE(params->quic_delay_tcp_race); 72 EXPECT_TRUE(params->quic_delay_tcp_race);
56 73
57 // Check max_number_of_lossy_connections and packet_loss_threshold. 74 // Check max_number_of_lossy_connections and packet_loss_threshold.
58 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); 75 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections);
59 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); 76 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold);
60 } 77 }
61 78
62 } // namespace cronet 79 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/url_request_context_config_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698