OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/http/http_server_properties_manager.h" | 5 #include "net/http/http_server_properties_manager.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 212 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
213 net::HostPortPair::FromString("mail.google.com:80"))); | 213 net::HostPortPair::FromString("mail.google.com:80"))); |
214 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( | 214 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( |
215 net::HostPortPair::FromString("foo.google.com:1337"))); | 215 net::HostPortPair::FromString("foo.google.com:1337"))); |
216 | 216 |
217 // Verify AlternateProtocol. | 217 // Verify AlternateProtocol. |
218 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 218 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
219 net::HostPortPair::FromString("www.google.com:80"))); | 219 net::HostPortPair::FromString("www.google.com:80"))); |
220 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 220 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
221 net::HostPortPair::FromString("mail.google.com:80"))); | 221 net::HostPortPair::FromString("mail.google.com:80"))); |
222 net::AlternateProtocolInfo port_alternate_protocol = | 222 net::AlternateProtocols port_alternate_protocols = |
223 http_server_props_manager_->GetAlternateProtocol( | 223 http_server_props_manager_->GetAlternateProtocol( |
224 net::HostPortPair::FromString("www.google.com:80")); | 224 net::HostPortPair::FromString("www.google.com:80")); |
225 EXPECT_EQ(443, port_alternate_protocol.port); | 225 ASSERT_EQ(1u, port_alternate_protocols.size()); |
226 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 226 EXPECT_EQ(443, port_alternate_protocols[0].port); |
227 port_alternate_protocol = http_server_props_manager_->GetAlternateProtocol( | 227 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocols[0].protocol); |
| 228 port_alternate_protocols = http_server_props_manager_->GetAlternateProtocol( |
228 net::HostPortPair::FromString("mail.google.com:80")); | 229 net::HostPortPair::FromString("mail.google.com:80")); |
229 EXPECT_EQ(444, port_alternate_protocol.port); | 230 ASSERT_EQ(1u, port_alternate_protocols.size()); |
230 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); | 231 EXPECT_EQ(444, port_alternate_protocols[0].port); |
| 232 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocols[0].protocol); |
231 | 233 |
232 // Verify SupportsQuic. | 234 // Verify SupportsQuic. |
233 net::SupportsQuic supports_quic2 = | 235 net::SupportsQuic supports_quic2 = |
234 http_server_props_manager_->GetSupportsQuic( | 236 http_server_props_manager_->GetSupportsQuic( |
235 net::HostPortPair::FromString("www.google.com:80")); | 237 net::HostPortPair::FromString("www.google.com:80")); |
236 EXPECT_TRUE(supports_quic2.used_quic); | 238 EXPECT_TRUE(supports_quic2.used_quic); |
237 EXPECT_EQ("foo", supports_quic2.address); | 239 EXPECT_EQ("foo", supports_quic2.address); |
238 supports_quic2 = http_server_props_manager_->GetSupportsQuic( | 240 supports_quic2 = http_server_props_manager_->GetSupportsQuic( |
239 net::HostPortPair::FromString("mail.google.com:80")); | 241 net::HostPortPair::FromString("mail.google.com:80")); |
240 EXPECT_FALSE(supports_quic2.used_quic); | 242 EXPECT_FALSE(supports_quic2.used_quic); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 361 |
360 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 362 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
361 } | 363 } |
362 | 364 |
363 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { | 365 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { |
364 ExpectPrefsUpdate(); | 366 ExpectPrefsUpdate(); |
365 | 367 |
366 net::HostPortPair spdy_server_mail("mail.google.com", 80); | 368 net::HostPortPair spdy_server_mail("mail.google.com", 80); |
367 EXPECT_FALSE( | 369 EXPECT_FALSE( |
368 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 370 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
369 http_server_props_manager_->SetAlternateProtocol( | 371 http_server_props_manager_->AddAlternateProtocol( |
370 spdy_server_mail, 443, net::NPN_SPDY_3, 1); | 372 spdy_server_mail, 443, net::NPN_SPDY_3, 1); |
371 | 373 |
372 // Run the task. | 374 // Run the task. |
373 base::RunLoop().RunUntilIdle(); | 375 base::RunLoop().RunUntilIdle(); |
374 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 376 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
375 | 377 |
376 ASSERT_TRUE( | 378 ASSERT_TRUE( |
377 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 379 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
378 net::AlternateProtocolInfo port_alternate_protocol = | 380 net::AlternateProtocols port_alternate_protocols = |
379 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); | 381 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); |
380 EXPECT_EQ(443, port_alternate_protocol.port); | 382 ASSERT_EQ(1u, port_alternate_protocols.size()); |
381 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 383 EXPECT_EQ(443, port_alternate_protocols[0].port); |
| 384 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocols[0].protocol); |
382 } | 385 } |
383 | 386 |
384 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { | 387 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { |
385 ExpectPrefsUpdate(); | 388 ExpectPrefsUpdate(); |
386 | 389 |
387 net::HostPortPair quic_server_mail("mail.google.com", 80); | 390 net::HostPortPair quic_server_mail("mail.google.com", 80); |
388 net::SupportsQuic supports_quic = http_server_props_manager_->GetSupportsQuic( | 391 net::SupportsQuic supports_quic = http_server_props_manager_->GetSupportsQuic( |
389 quic_server_mail); | 392 quic_server_mail); |
390 EXPECT_FALSE(supports_quic.used_quic); | 393 EXPECT_FALSE(supports_quic.used_quic); |
391 EXPECT_EQ("", supports_quic.address); | 394 EXPECT_EQ("", supports_quic.address); |
392 http_server_props_manager_->SetSupportsQuic(quic_server_mail, true, "foo"); | 395 http_server_props_manager_->SetSupportsQuic(quic_server_mail, true, "foo"); |
393 | 396 |
394 // Run the task. | 397 // Run the task. |
395 base::RunLoop().RunUntilIdle(); | 398 base::RunLoop().RunUntilIdle(); |
396 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 399 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
397 | 400 |
398 net::SupportsQuic supports_quic1 = | 401 net::SupportsQuic supports_quic1 = |
399 http_server_props_manager_->GetSupportsQuic(quic_server_mail); | 402 http_server_props_manager_->GetSupportsQuic(quic_server_mail); |
400 EXPECT_TRUE(supports_quic1.used_quic); | 403 EXPECT_TRUE(supports_quic1.used_quic); |
401 EXPECT_EQ("foo", supports_quic1.address); | 404 EXPECT_EQ("foo", supports_quic1.address); |
402 } | 405 } |
403 | 406 |
404 TEST_F(HttpServerPropertiesManagerTest, Clear) { | 407 TEST_F(HttpServerPropertiesManagerTest, Clear) { |
405 ExpectPrefsUpdate(); | 408 ExpectPrefsUpdate(); |
406 | 409 |
407 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 410 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
408 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 411 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
409 http_server_props_manager_->SetAlternateProtocol( | 412 http_server_props_manager_->AddAlternateProtocol( |
410 spdy_server_mail, 443, net::NPN_SPDY_3, 1); | 413 spdy_server_mail, 443, net::NPN_SPDY_3, 1); |
411 http_server_props_manager_->SetSupportsQuic(spdy_server_mail, true, "foo"); | 414 http_server_props_manager_->SetSupportsQuic(spdy_server_mail, true, "foo"); |
412 | 415 |
413 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 416 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
414 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 417 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
415 const uint32 value1 = 31337; | 418 const uint32 value1 = 31337; |
416 http_server_props_manager_->SetSpdySetting( | 419 http_server_props_manager_->SetSpdySetting( |
417 spdy_server_mail, id1, flags1, value1); | 420 spdy_server_mail, id1, flags1, value1); |
418 | 421 |
419 // Run the task. | 422 // Run the task. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // Run the task after shutdown, but before deletion. | 531 // Run the task after shutdown, but before deletion. |
529 base::RunLoop().RunUntilIdle(); | 532 base::RunLoop().RunUntilIdle(); |
530 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 533 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
531 http_server_props_manager_.reset(); | 534 http_server_props_manager_.reset(); |
532 base::RunLoop().RunUntilIdle(); | 535 base::RunLoop().RunUntilIdle(); |
533 } | 536 } |
534 | 537 |
535 } // namespace | 538 } // namespace |
536 | 539 |
537 } // namespace net | 540 } // namespace net |
OLD | NEW |