OLD | NEW |
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 "chrome/browser/net/http_server_properties_manager.h" | 5 #include "chrome/browser/net/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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( | 200 EXPECT_TRUE(http_server_props_manager_->SupportsSpdy( |
201 net::HostPortPair::FromString("mail.google.com:80"))); | 201 net::HostPortPair::FromString("mail.google.com:80"))); |
202 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( | 202 EXPECT_FALSE(http_server_props_manager_->SupportsSpdy( |
203 net::HostPortPair::FromString("foo.google.com:1337"))); | 203 net::HostPortPair::FromString("foo.google.com:1337"))); |
204 | 204 |
205 // Verify AlternateProtocol. | 205 // Verify AlternateProtocol. |
206 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 206 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
207 net::HostPortPair::FromString("www.google.com:80"))); | 207 net::HostPortPair::FromString("www.google.com:80"))); |
208 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( | 208 ASSERT_TRUE(http_server_props_manager_->HasAlternateProtocol( |
209 net::HostPortPair::FromString("mail.google.com:80"))); | 209 net::HostPortPair::FromString("mail.google.com:80"))); |
210 net::AlternateProtocolInfo port_alternate_protocol = | 210 net::PortAlternateProtocolPair port_alternate_protocol = |
211 http_server_props_manager_->GetAlternateProtocol( | 211 http_server_props_manager_->GetAlternateProtocol( |
212 net::HostPortPair::FromString("www.google.com:80")); | 212 net::HostPortPair::FromString("www.google.com:80")); |
213 EXPECT_EQ(443, port_alternate_protocol.port); | 213 EXPECT_EQ(443, port_alternate_protocol.port); |
214 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 214 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); |
215 port_alternate_protocol = | 215 port_alternate_protocol = |
216 http_server_props_manager_->GetAlternateProtocol( | 216 http_server_props_manager_->GetAlternateProtocol( |
217 net::HostPortPair::FromString("mail.google.com:80")); | 217 net::HostPortPair::FromString("mail.google.com:80")); |
218 EXPECT_EQ(444, port_alternate_protocol.port); | 218 EXPECT_EQ(444, port_alternate_protocol.port); |
219 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); | 219 EXPECT_EQ(net::NPN_SPDY_3_1, port_alternate_protocol.protocol); |
220 } | 220 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 338 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
339 } | 339 } |
340 | 340 |
341 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { | 341 TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) { |
342 ExpectPrefsUpdate(); | 342 ExpectPrefsUpdate(); |
343 | 343 |
344 net::HostPortPair spdy_server_mail("mail.google.com", 80); | 344 net::HostPortPair spdy_server_mail("mail.google.com", 80); |
345 EXPECT_FALSE( | 345 EXPECT_FALSE( |
346 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 346 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
347 http_server_props_manager_->SetAlternateProtocol( | 347 http_server_props_manager_->SetAlternateProtocol( |
348 spdy_server_mail, 443, net::NPN_SPDY_3, 1); | 348 spdy_server_mail, 443, net::NPN_SPDY_3); |
349 | 349 |
350 // Run the task. | 350 // Run the task. |
351 loop_.RunUntilIdle(); | 351 loop_.RunUntilIdle(); |
352 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 352 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
353 | 353 |
354 ASSERT_TRUE( | 354 ASSERT_TRUE( |
355 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); | 355 http_server_props_manager_->HasAlternateProtocol(spdy_server_mail)); |
356 net::AlternateProtocolInfo port_alternate_protocol = | 356 net::PortAlternateProtocolPair port_alternate_protocol = |
357 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); | 357 http_server_props_manager_->GetAlternateProtocol(spdy_server_mail); |
358 EXPECT_EQ(443, port_alternate_protocol.port); | 358 EXPECT_EQ(443, port_alternate_protocol.port); |
359 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); | 359 EXPECT_EQ(net::NPN_SPDY_3, port_alternate_protocol.protocol); |
360 } | 360 } |
361 | 361 |
362 TEST_F(HttpServerPropertiesManagerTest, Clear) { | 362 TEST_F(HttpServerPropertiesManagerTest, Clear) { |
363 ExpectPrefsUpdate(); | 363 ExpectPrefsUpdate(); |
364 | 364 |
365 net::HostPortPair spdy_server_mail("mail.google.com", 443); | 365 net::HostPortPair spdy_server_mail("mail.google.com", 443); |
366 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); | 366 http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true); |
367 http_server_props_manager_->SetAlternateProtocol( | 367 http_server_props_manager_->SetAlternateProtocol( |
368 spdy_server_mail, 443, net::NPN_SPDY_3, 1); | 368 spdy_server_mail, 443, net::NPN_SPDY_3); |
369 | 369 |
370 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; | 370 const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH; |
371 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; | 371 const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST; |
372 const uint32 value1 = 31337; | 372 const uint32 value1 = 31337; |
373 http_server_props_manager_->SetSpdySetting( | 373 http_server_props_manager_->SetSpdySetting( |
374 spdy_server_mail, id1, flags1, value1); | 374 spdy_server_mail, id1, flags1, value1); |
375 | 375 |
376 // Run the task. | 376 // Run the task. |
377 loop_.RunUntilIdle(); | 377 loop_.RunUntilIdle(); |
378 | 378 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // Run the task after shutdown, but before deletion. | 476 // Run the task after shutdown, but before deletion. |
477 loop_.RunUntilIdle(); | 477 loop_.RunUntilIdle(); |
478 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 478 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
479 http_server_props_manager_.reset(); | 479 http_server_props_manager_.reset(); |
480 loop_.RunUntilIdle(); | 480 loop_.RunUntilIdle(); |
481 } | 481 } |
482 | 482 |
483 } // namespace | 483 } // namespace |
484 | 484 |
485 } // namespace chrome_browser_net | 485 } // namespace chrome_browser_net |
OLD | NEW |