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

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 1904483004: Change SupportsSpdy dict, SpdySettingsMap, ServerNetworkStatsMap, AlternativeServiceMap and disk da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile after sync code, introduced by commit 388755 Created 4 years, 8 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 | « net/quic/quic_stream_factory_test.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool priority_to_dependency; 103 bool priority_to_dependency;
104 }; 104 };
105 105
106 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params, 106 void UpdateSpdySessionDependencies(SpdyNetworkTransactionTestParams test_params,
107 SpdySessionDependencies* session_deps) { 107 SpdySessionDependencies* session_deps) {
108 session_deps->parse_alternative_services = true; 108 session_deps->parse_alternative_services = true;
109 session_deps->enable_alternative_service_with_different_host = true; 109 session_deps->enable_alternative_service_with_different_host = true;
110 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) { 110 if (test_params.ssl_type == HTTP_SPDY_VIA_ALT_SVC) {
111 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 111 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
112 session_deps->http_server_properties.SetAlternativeService( 112 session_deps->http_server_properties.SetAlternativeService(
113 HostPortPair("www.example.org", 80), 113 url::SchemeHostPort("http", "www.example.org", 80),
114 AlternativeService(AlternateProtocolFromNextProto(test_params.protocol), 114 AlternativeService(AlternateProtocolFromNextProto(test_params.protocol),
115 "www.example.org", 443), 115 "www.example.org", 443),
116 expiration); 116 expiration);
117 } 117 }
118 session_deps->enable_priority_dependencies = 118 session_deps->enable_priority_dependencies =
119 test_params.priority_to_dependency; 119 test_params.priority_to_dependency;
120 } 120 }
121 121
122 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies( 122 std::unique_ptr<SpdySessionDependencies> CreateSpdySessionDependencies(
123 SpdyNetworkTransactionTestParams test_params) { 123 SpdyNetworkTransactionTestParams test_params) {
(...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4233 DATA_FLAG_NONE // Data Flags 4233 DATA_FLAG_NONE // Data Flags
4234 }; 4234 };
4235 4235
4236 BoundNetLog net_log; 4236 BoundNetLog net_log;
4237 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY, 4237 NormalSpdyTransactionHelper helper(CreateGetRequest(), DEFAULT_PRIORITY,
4238 net_log, GetParam(), NULL); 4238 net_log, GetParam(), NULL);
4239 helper.RunPreTestSetup(); 4239 helper.RunPreTestSetup();
4240 4240
4241 // Verify that no settings exist initially. 4241 // Verify that no settings exist initially.
4242 HostPortPair host_port_pair("www.example.org", helper.port()); 4242 HostPortPair host_port_pair("www.example.org", helper.port());
4243 url::SchemeHostPort spdy_server("https", host_port_pair.host(),
4244 host_port_pair.port());
4245
4243 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4246 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4244 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4247 EXPECT_TRUE(spdy_session_pool->http_server_properties()
4245 host_port_pair).empty()); 4248 ->GetSpdySettings(spdy_server)
4249 .empty());
4246 4250
4247 // Construct the request. 4251 // Construct the request.
4248 std::unique_ptr<SpdySerializedFrame> req( 4252 std::unique_ptr<SpdySerializedFrame> req(
4249 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); 4253 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
4250 MockWrite writes[] = {CreateMockWrite(*req, 0)}; 4254 MockWrite writes[] = {CreateMockWrite(*req, 0)};
4251 4255
4252 // Construct the reply. 4256 // Construct the reply.
4253 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock()); 4257 std::unique_ptr<SpdyHeaderBlock> reply_headers(new SpdyHeaderBlock());
4254 (*reply_headers)[spdy_util_.GetStatusKey()] = "200"; 4258 (*reply_headers)[spdy_util_.GetStatusKey()] = "200";
4255 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1"; 4259 (*reply_headers)[spdy_util_.GetVersionKey()] = "HTTP/1.1";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 helper.VerifyDataConsumed(); 4297 helper.VerifyDataConsumed();
4294 TransactionHelperResult out = helper.output(); 4298 TransactionHelperResult out = helper.output();
4295 EXPECT_EQ(OK, out.rv); 4299 EXPECT_EQ(OK, out.rv);
4296 EXPECT_EQ("HTTP/1.1 200", out.status_line); 4300 EXPECT_EQ("HTTP/1.1 200", out.status_line);
4297 EXPECT_EQ("hello!", out.response_data); 4301 EXPECT_EQ("hello!", out.response_data);
4298 4302
4299 { 4303 {
4300 // Verify we had two persisted settings. 4304 // Verify we had two persisted settings.
4301 const SettingsMap& settings_map = 4305 const SettingsMap& settings_map =
4302 spdy_session_pool->http_server_properties()->GetSpdySettings( 4306 spdy_session_pool->http_server_properties()->GetSpdySettings(
4303 host_port_pair); 4307 spdy_server);
4304 ASSERT_EQ(2u, settings_map.size()); 4308 ASSERT_EQ(2u, settings_map.size());
4305 4309
4306 // Verify the first persisted setting. 4310 // Verify the first persisted setting.
4307 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); 4311 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1);
4308 EXPECT_TRUE(it1 != settings_map.end()); 4312 EXPECT_TRUE(it1 != settings_map.end());
4309 SettingsFlagsAndValue flags_and_value1 = it1->second; 4313 SettingsFlagsAndValue flags_and_value1 = it1->second;
4310 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); 4314 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first);
4311 EXPECT_EQ(kSampleValue1, flags_and_value1.second); 4315 EXPECT_EQ(kSampleValue1, flags_and_value1.second);
4312 4316
4313 // Verify the second persisted setting. 4317 // Verify the second persisted setting.
(...skipping 30 matching lines...) Expand all
4344 net_log, GetParam(), NULL); 4348 net_log, GetParam(), NULL);
4345 helper.RunPreTestSetup(); 4349 helper.RunPreTestSetup();
4346 4350
4347 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); 4351 SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool();
4348 4352
4349 SpdySessionPoolPeer pool_peer(spdy_session_pool); 4353 SpdySessionPoolPeer pool_peer(spdy_session_pool);
4350 pool_peer.SetEnableSendingInitialData(true); 4354 pool_peer.SetEnableSendingInitialData(true);
4351 4355
4352 // Verify that no settings exist initially. 4356 // Verify that no settings exist initially.
4353 HostPortPair host_port_pair("www.example.org", helper.port()); 4357 HostPortPair host_port_pair("www.example.org", helper.port());
4354 EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( 4358 url::SchemeHostPort spdy_server("https", host_port_pair.host(),
4355 host_port_pair).empty()); 4359 host_port_pair.port());
4360 EXPECT_TRUE(spdy_session_pool->http_server_properties()
4361 ->GetSpdySettings(spdy_server)
4362 .empty());
4356 4363
4357 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS; 4364 const SpdySettingsIds kSampleId1 = SETTINGS_MAX_CONCURRENT_STREAMS;
4358 unsigned int kSampleValue1 = 0x0a0a0a0a; 4365 unsigned int kSampleValue1 = 0x0a0a0a0a;
4359 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE; 4366 const SpdySettingsIds kSampleId2 = SETTINGS_INITIAL_WINDOW_SIZE;
4360 unsigned int kSampleValue2 = 0x0c0c0c0c; 4367 unsigned int kSampleValue2 = 0x0c0c0c0c;
4361 4368
4362 // First add a persisted setting. 4369 // First add a persisted setting.
4363 spdy_session_pool->http_server_properties()->SetSpdySetting( 4370 spdy_session_pool->http_server_properties()->SetSpdySetting(
4364 host_port_pair, 4371 spdy_server, kSampleId1, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue1);
4365 kSampleId1,
4366 SETTINGS_FLAG_PLEASE_PERSIST,
4367 kSampleValue1);
4368 4372
4369 // Next add another persisted setting. 4373 // Next add another persisted setting.
4370 spdy_session_pool->http_server_properties()->SetSpdySetting( 4374 spdy_session_pool->http_server_properties()->SetSpdySetting(
4371 host_port_pair, 4375 spdy_server, kSampleId2, SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue2);
4372 kSampleId2,
4373 SETTINGS_FLAG_PLEASE_PERSIST,
4374 kSampleValue2);
4375 4376
4376 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( 4377 EXPECT_EQ(2u, spdy_session_pool->http_server_properties()
4377 host_port_pair).size()); 4378 ->GetSpdySettings(spdy_server)
4379 .size());
4378 4380
4379 // Construct the initial SETTINGS frame. 4381 // Construct the initial SETTINGS frame.
4380 SettingsMap initial_settings; 4382 SettingsMap initial_settings;
4381 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 4383 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
4382 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); 4384 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams);
4383 std::unique_ptr<SpdySerializedFrame> initial_settings_frame( 4385 std::unique_ptr<SpdySerializedFrame> initial_settings_frame(
4384 spdy_util_.ConstructSpdySettings(initial_settings)); 4386 spdy_util_.ConstructSpdySettings(initial_settings));
4385 4387
4386 // Construct the persisted SETTINGS frame. 4388 // Construct the persisted SETTINGS frame.
4387 const SettingsMap& settings = 4389 const SettingsMap& settings =
4388 spdy_session_pool->http_server_properties()->GetSpdySettings( 4390 spdy_session_pool->http_server_properties()->GetSpdySettings(spdy_server);
4389 host_port_pair);
4390 std::unique_ptr<SpdySerializedFrame> settings_frame( 4391 std::unique_ptr<SpdySerializedFrame> settings_frame(
4391 spdy_util_.ConstructSpdySettings(settings)); 4392 spdy_util_.ConstructSpdySettings(settings));
4392 4393
4393 // Construct the request. 4394 // Construct the request.
4394 std::unique_ptr<SpdySerializedFrame> req( 4395 std::unique_ptr<SpdySerializedFrame> req(
4395 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); 4396 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true));
4396 4397
4397 MockWrite writes[] = { 4398 MockWrite writes[] = {
4398 CreateMockWrite(*initial_settings_frame, 0), 4399 CreateMockWrite(*initial_settings_frame, 0),
4399 CreateMockWrite(*settings_frame, 1), 4400 CreateMockWrite(*settings_frame, 1),
(...skipping 21 matching lines...) Expand all
4421 helper.VerifyDataConsumed(); 4422 helper.VerifyDataConsumed();
4422 TransactionHelperResult out = helper.output(); 4423 TransactionHelperResult out = helper.output();
4423 EXPECT_EQ(OK, out.rv); 4424 EXPECT_EQ(OK, out.rv);
4424 EXPECT_EQ("HTTP/1.1 200", out.status_line); 4425 EXPECT_EQ("HTTP/1.1 200", out.status_line);
4425 EXPECT_EQ("hello!", out.response_data); 4426 EXPECT_EQ("hello!", out.response_data);
4426 4427
4427 { 4428 {
4428 // Verify we had two persisted settings. 4429 // Verify we had two persisted settings.
4429 const SettingsMap& settings_map = 4430 const SettingsMap& settings_map =
4430 spdy_session_pool->http_server_properties()->GetSpdySettings( 4431 spdy_session_pool->http_server_properties()->GetSpdySettings(
4431 host_port_pair); 4432 spdy_server);
4432 ASSERT_EQ(2u, settings_map.size()); 4433 ASSERT_EQ(2u, settings_map.size());
4433 4434
4434 // Verify the first persisted setting. 4435 // Verify the first persisted setting.
4435 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1); 4436 SettingsMap::const_iterator it1 = settings_map.find(kSampleId1);
4436 EXPECT_TRUE(it1 != settings_map.end()); 4437 EXPECT_TRUE(it1 != settings_map.end());
4437 SettingsFlagsAndValue flags_and_value1 = it1->second; 4438 SettingsFlagsAndValue flags_and_value1 = it1->second;
4438 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first); 4439 EXPECT_EQ(SETTINGS_FLAG_PERSISTED, flags_and_value1.first);
4439 EXPECT_EQ(kSampleValue1, flags_and_value1.second); 4440 EXPECT_EQ(kSampleValue1, flags_and_value1.second);
4440 4441
4441 // Verify the second persisted setting. 4442 // Verify the second persisted setting.
(...skipping 2693 matching lines...) Expand 10 before | Expand all | Expand 10 after
7135 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 7136 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
7136 std::unique_ptr<SSLSocketDataProvider> ssl_provider( 7137 std::unique_ptr<SSLSocketDataProvider> ssl_provider(
7137 new SSLSocketDataProvider(ASYNC, OK)); 7138 new SSLSocketDataProvider(ASYNC, OK));
7138 // Set to TLS_RSA_WITH_NULL_MD5 7139 // Set to TLS_RSA_WITH_NULL_MD5
7139 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 7140 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
7140 7141
7141 RunTLSUsageCheckTest(std::move(ssl_provider)); 7142 RunTLSUsageCheckTest(std::move(ssl_provider));
7142 } 7143 }
7143 7144
7144 } // namespace net 7145 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory_test.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698