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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 542 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
543 http_server_props_manager_->ClearAlternativeService(spdy_server_mail); | 543 http_server_props_manager_->ClearAlternativeService(spdy_server_mail); |
544 | 544 |
545 // Run the task. | 545 // Run the task. |
546 base::RunLoop().RunUntilIdle(); | 546 base::RunLoop().RunUntilIdle(); |
547 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 547 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
548 | 548 |
549 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 549 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
550 } | 550 } |
551 | 551 |
| 552 TEST_F(HttpServerPropertiesManagerTest, ConfirmAlternativeService) { |
| 553 ExpectPrefsUpdate(); |
| 554 |
| 555 HostPortPair spdy_server_mail("mail.google.com", 80); |
| 556 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 557 AlternativeService alternative_service(NPN_SPDY_4, "mail.google.com", 443); |
| 558 |
| 559 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 560 http_server_props_manager_->SetAlternativeService(spdy_server_mail, |
| 561 alternative_service, 1.0); |
| 562 |
| 563 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 564 alternative_service)); |
| 565 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 566 alternative_service)); |
| 567 |
| 568 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 569 http_server_props_manager_->MarkAlternativeServiceBroken(alternative_service); |
| 570 EXPECT_TRUE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 571 alternative_service)); |
| 572 EXPECT_TRUE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 573 alternative_service)); |
| 574 |
| 575 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 576 http_server_props_manager_->ConfirmAlternativeService(alternative_service); |
| 577 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 578 alternative_service)); |
| 579 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 580 alternative_service)); |
| 581 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. |
| 582 http_server_props_manager_->ConfirmAlternativeService(alternative_service); |
| 583 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 584 alternative_service)); |
| 585 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 586 alternative_service)); |
| 587 |
| 588 // Run the task. |
| 589 base::RunLoop().RunUntilIdle(); |
| 590 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 591 |
| 592 EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( |
| 593 alternative_service)); |
| 594 EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( |
| 595 alternative_service)); |
| 596 } |
| 597 |
552 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { | 598 TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { |
553 ExpectPrefsUpdate(); | 599 ExpectPrefsUpdate(); |
554 ExpectScheduleUpdatePrefsOnNetworkThread(); | 600 ExpectScheduleUpdatePrefsOnNetworkThread(); |
555 | 601 |
556 IPAddressNumber address; | 602 IPAddressNumber address; |
557 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); | 603 EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address)); |
558 | 604 |
559 IPAddressNumber actual_address; | 605 IPAddressNumber actual_address; |
560 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); | 606 CHECK(ParseIPLiteralToNumber("127.0.0.1", &actual_address)); |
561 http_server_props_manager_->SetSupportsQuic(true, actual_address); | 607 http_server_props_manager_->SetSupportsQuic(true, actual_address); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // Run the task after shutdown, but before deletion. | 885 // Run the task after shutdown, but before deletion. |
840 base::RunLoop().RunUntilIdle(); | 886 base::RunLoop().RunUntilIdle(); |
841 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 887 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
842 http_server_props_manager_.reset(); | 888 http_server_props_manager_.reset(); |
843 base::RunLoop().RunUntilIdle(); | 889 base::RunLoop().RunUntilIdle(); |
844 } | 890 } |
845 | 891 |
846 } // namespace | 892 } // namespace |
847 | 893 |
848 } // namespace net | 894 } // namespace net |
OLD | NEW |