Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 // Verify that there are no entries in the settings map. | 706 // Verify that there are no entries in the settings map. |
| 707 const SpdySettingsMap& spdy_settings_map2_ret = | 707 const SpdySettingsMap& spdy_settings_map2_ret = |
| 708 http_server_props_manager_->spdy_settings_map(); | 708 http_server_props_manager_->spdy_settings_map(); |
| 709 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); | 709 ASSERT_EQ(0U, spdy_settings_map2_ret.size()); |
| 710 | 710 |
| 711 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 711 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 712 } | 712 } |
| 713 | 713 |
| 714 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { | 714 TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) { |
| 715 ExpectPrefsUpdate(); | 715 ExpectPrefsUpdate(); |
| 716 // ScheduleUpdatePrefsOnNetworkThread() should be called only once. | |
| 716 ExpectScheduleUpdatePrefsOnNetworkThread(); | 717 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 717 | 718 |
| 718 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | 719 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); |
| 719 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 720 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 720 const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", | 721 const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", |
| 721 443); | 722 443); |
| 723 | |
| 722 http_server_props_manager_->SetAlternativeService( | 724 http_server_props_manager_->SetAlternativeService( |
| 723 spdy_server_mail, alternative_service, one_day_from_now_); | 725 spdy_server_mail, alternative_service, one_day_from_now_); |
| 724 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 726 base::RunLoop().RunUntilIdle(); |
| 727 | |
| 725 http_server_props_manager_->SetAlternativeService( | 728 http_server_props_manager_->SetAlternativeService( |
| 726 spdy_server_mail, alternative_service, one_day_from_now_); | 729 spdy_server_mail, alternative_service, one_day_from_now_); |
| 730 base::RunLoop().RunUntilIdle(); | |
| 727 | 731 |
| 728 // Run the task. | |
| 729 base::RunLoop().RunUntilIdle(); | |
| 730 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 732 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 731 | 733 |
| 732 AlternativeServiceVector alternative_service_vector = | 734 AlternativeServiceVector alternative_service_vector = |
| 733 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 735 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 734 ASSERT_EQ(1u, alternative_service_vector.size()); | 736 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 735 EXPECT_EQ(alternative_service, alternative_service_vector[0]); | 737 EXPECT_EQ(alternative_service, alternative_service_vector[0]); |
| 736 } | 738 } |
| 737 | 739 |
| 738 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { | 740 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) { |
| 739 ExpectPrefsUpdate(); | 741 ExpectPrefsUpdate(); |
| 742 // ScheduleUpdatePrefsOnNetworkThread() should be called only once. | |
| 740 ExpectScheduleUpdatePrefsOnNetworkThread(); | 743 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 741 | 744 |
| 742 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | 745 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); |
| 743 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 746 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 744 AlternativeServiceInfoVector alternative_service_info_vector; | 747 AlternativeServiceInfoVector alternative_service_info_vector; |
| 745 const AlternativeService alternative_service1(NPN_HTTP_2, "mail.google.com", | 748 const AlternativeService alternative_service1(NPN_HTTP_2, "mail.google.com", |
| 746 443); | 749 443); |
| 747 alternative_service_info_vector.push_back( | 750 alternative_service_info_vector.push_back( |
| 748 AlternativeServiceInfo(alternative_service1, one_day_from_now_)); | 751 AlternativeServiceInfo(alternative_service1, one_day_from_now_)); |
| 749 const AlternativeService alternative_service2(QUIC, "mail.google.com", 1234); | 752 const AlternativeService alternative_service2(QUIC, "mail.google.com", 1234); |
| 750 alternative_service_info_vector.push_back( | 753 alternative_service_info_vector.push_back( |
| 751 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); | 754 AlternativeServiceInfo(alternative_service2, one_day_from_now_)); |
| 755 | |
| 752 http_server_props_manager_->SetAlternativeServices( | 756 http_server_props_manager_->SetAlternativeServices( |
| 753 spdy_server_mail, alternative_service_info_vector); | 757 spdy_server_mail, alternative_service_info_vector); |
| 754 // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. | 758 base::RunLoop().RunUntilIdle(); |
| 759 | |
| 755 http_server_props_manager_->SetAlternativeServices( | 760 http_server_props_manager_->SetAlternativeServices( |
| 756 spdy_server_mail, alternative_service_info_vector); | 761 spdy_server_mail, alternative_service_info_vector); |
| 762 base::RunLoop().RunUntilIdle(); | |
| 757 | 763 |
| 758 // Run the task. | |
| 759 base::RunLoop().RunUntilIdle(); | |
| 760 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 764 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 761 | 765 |
| 762 AlternativeServiceVector alternative_service_vector = | 766 AlternativeServiceVector alternative_service_vector = |
| 763 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); | 767 http_server_props_manager_->GetAlternativeServices(spdy_server_mail); |
| 764 ASSERT_EQ(2u, alternative_service_vector.size()); | 768 ASSERT_EQ(2u, alternative_service_vector.size()); |
| 765 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); | 769 EXPECT_EQ(alternative_service1, alternative_service_vector[0]); |
| 766 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); | 770 EXPECT_EQ(alternative_service2, alternative_service_vector[1]); |
| 767 } | 771 } |
| 768 | 772 |
| 769 TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) { | |
|
Bence
2016/07/22 16:28:54
I'm removing this test because now even empty => e
| |
| 770 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | |
| 771 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | |
| 772 const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", | |
| 773 443); | |
| 774 http_server_props_manager_->SetAlternativeServices( | |
| 775 spdy_server_mail, AlternativeServiceInfoVector()); | |
| 776 // ExpectScheduleUpdatePrefsOnNetworkThread() should not be called. | |
| 777 | |
| 778 // Run the task. | |
| 779 base::RunLoop().RunUntilIdle(); | |
| 780 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | |
| 781 | |
| 782 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | |
| 783 } | |
| 784 | |
| 785 TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) { | 773 TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) { |
| 786 ExpectPrefsUpdate(); | 774 ExpectPrefsUpdate(); |
| 787 | 775 |
| 788 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); | 776 url::SchemeHostPort spdy_server_mail("http", "mail.google.com", 80); |
| 789 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); | 777 EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); |
| 790 AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443); | 778 AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443); |
| 791 | 779 |
| 792 ExpectScheduleUpdatePrefsOnNetworkThread(); | 780 ExpectScheduleUpdatePrefsOnNetworkThread(); |
| 793 http_server_props_manager_->SetAlternativeService( | 781 http_server_props_manager_->SetAlternativeService( |
| 794 spdy_server_mail, alternative_service, one_day_from_now_); | 782 spdy_server_mail, alternative_service, one_day_from_now_); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1383 // Shutdown comes before the task is executed. | 1371 // Shutdown comes before the task is executed. |
| 1384 http_server_props_manager_->ShutdownOnPrefThread(); | 1372 http_server_props_manager_->ShutdownOnPrefThread(); |
| 1385 // Run the task after shutdown, but before deletion. | 1373 // Run the task after shutdown, but before deletion. |
| 1386 base::RunLoop().RunUntilIdle(); | 1374 base::RunLoop().RunUntilIdle(); |
| 1387 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 1375 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
| 1388 http_server_props_manager_.reset(); | 1376 http_server_props_manager_.reset(); |
| 1389 base::RunLoop().RunUntilIdle(); | 1377 base::RunLoop().RunUntilIdle(); |
| 1390 } | 1378 } |
| 1391 | 1379 |
| 1392 } // namespace net | 1380 } // namespace net |
| OLD | NEW |