| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/cronet/url_request_context_config.h" | |
| 6 | |
| 7 #include "net/http/http_network_session.h" | |
| 8 #include "net/proxy/proxy_config.h" | |
| 9 #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_builder.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace cronet { | |
| 15 | |
| 16 TEST(URLRequestContextConfigTest, SetQuicExperimentalOptions) { | |
| 17 URLRequestContextConfig config; | |
| 18 | |
| 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; | |
| 37 config.ConfigureURLRequestContextBuilder(&builder); | |
| 38 // Set a ProxyConfigService to avoid DCHECK failure when building. | |
| 39 builder.set_proxy_config_service(make_scoped_ptr( | |
| 40 new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()))); | |
| 41 scoped_ptr<net::URLRequestContext> context(builder.Build()); | |
| 42 const net::HttpNetworkSession::Params* params = | |
| 43 context->GetNetworkSessionParams(); | |
| 44 // Check Quic Connection options. | |
| 45 net::QuicTagVector quic_connection_options; | |
| 46 quic_connection_options.push_back(net::kTIME); | |
| 47 quic_connection_options.push_back(net::kTBBR); | |
| 48 quic_connection_options.push_back(net::kREJ); | |
| 49 EXPECT_EQ(quic_connection_options, params->quic_connection_options); | |
| 50 | |
| 51 // Check store_server_configs_in_properties. | |
| 52 EXPECT_TRUE(params->quic_store_server_configs_in_properties); | |
| 53 | |
| 54 // Check delay_tcp_race. | |
| 55 EXPECT_TRUE(params->quic_delay_tcp_race); | |
| 56 | |
| 57 // Check max_number_of_lossy_connections and packet_loss_threshold. | |
| 58 EXPECT_EQ(10, params->quic_max_number_of_lossy_connections); | |
| 59 EXPECT_FLOAT_EQ(0.5f, params->quic_packet_loss_threshold); | |
| 60 } | |
| 61 | |
| 62 } // namespace cronet | |
| OLD | NEW |