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/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // Run the task. | 519 // Run the task. |
520 base::RunLoop().RunUntilIdle(); | 520 base::RunLoop().RunUntilIdle(); |
521 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 521 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
522 | 522 |
523 alternative_service = | 523 alternative_service = |
524 http_server_props_manager_->GetAlternativeService(spdy_server_mail); | 524 http_server_props_manager_->GetAlternativeService(spdy_server_mail); |
525 EXPECT_EQ(443, alternative_service.port); | 525 EXPECT_EQ(443, alternative_service.port); |
526 EXPECT_EQ(NPN_SPDY_4, alternative_service.protocol); | 526 EXPECT_EQ(NPN_SPDY_4, alternative_service.protocol); |
527 } | 527 } |
528 | 528 |
| 529 TEST_F(HttpServerPropertiesManagerTest, ClearAlternativeService) { |
| 530 ExpectPrefsUpdate(); |
| 531 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 532 |
| 533 HostPortPair spdy_server_mail("mail.google.com", 80); |
| 534 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 535 AlternativeService alternative_service(NPN_SPDY_4, "mail.google.com", 443); |
| 536 http_server_props_manager_->SetAlternativeService(spdy_server_mail, |
| 537 alternative_service, 1.0); |
| 538 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 539 http_server_props_manager_->ClearAlternativeService(spdy_server_mail); |
| 540 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 541 http_server_props_manager_->ClearAlternativeService(spdy_server_mail); |
| 542 |
| 543 // Run the task. |
| 544 base::RunLoop().RunUntilIdle(); |
| 545 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 546 |
| 547 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 548 } |
| 549 |
529 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { | 550 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { |
530 ExpectPrefsUpdate(); | 551 ExpectPrefsUpdate(); |
531 ExpectScheduleUpdatePrefsOnNetworkThread(); | 552 ExpectScheduleUpdatePrefsOnNetworkThread(); |
532 | 553 |
533 IPAddressNumber address; | 554 IPAddressNumber address; |
534 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); | 555 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); |
535 | 556 |
536 IPAddressNumber actual_address; | 557 IPAddressNumber actual_address; |
537 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); | 558 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
538 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 559 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // Run the task after shutdown, but before deletion. | 837 // Run the task after shutdown, but before deletion. |
817 base::RunLoop().RunUntilIdle(); | 838 base::RunLoop().RunUntilIdle(); |
818 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 839 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
819 http_server_props_manager_.reset(); | 840 http_server_props_manager_.reset(); |
820 base::RunLoop().RunUntilIdle(); | 841 base::RunLoop().RunUntilIdle(); |
821 } | 842 } |
822 | 843 |
823 } // namespace | 844 } // namespace |
824 | 845 |
825 } // namespace net | 846 } // namespace net |
OLD | NEW |