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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 737 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
738 http_server_props_manager_.reset(); | 738 http_server_props_manager_.reset(); |
739 base::RunLoop().RunUntilIdle(); | 739 base::RunLoop().RunUntilIdle(); |
740 } | 740 } |
741 | 741 |
742 // | 742 // |
743 // Tests for shutdown when updating prefs. | 743 // Tests for shutdown when updating prefs. |
744 // | 744 // |
745 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { | 745 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs0) { |
746 // Post an update task to the IO thread. | 746 // Post an update task to the IO thread. |
747 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); | 747 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread( |
| 748 HttpServerPropertiesManager::UNIT_TESTS); |
748 // Shutdown comes before the task is executed. | 749 // Shutdown comes before the task is executed. |
749 http_server_props_manager_->ShutdownOnPrefThread(); | 750 http_server_props_manager_->ShutdownOnPrefThread(); |
750 http_server_props_manager_.reset(); | 751 http_server_props_manager_.reset(); |
751 // Run the task after shutdown and deletion. | 752 // Run the task after shutdown and deletion. |
752 base::RunLoop().RunUntilIdle(); | 753 base::RunLoop().RunUntilIdle(); |
753 } | 754 } |
754 | 755 |
755 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { | 756 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs1) { |
756 ExpectPrefsUpdate(); | 757 ExpectPrefsUpdate(); |
757 // Post an update task. | 758 // Post an update task. |
758 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread(); | 759 http_server_props_manager_->ScheduleUpdatePrefsOnNetworkThread( |
| 760 HttpServerPropertiesManager::UNIT_TESTS); |
759 // Shutdown comes before the task is executed. | 761 // Shutdown comes before the task is executed. |
760 http_server_props_manager_->ShutdownOnPrefThread(); | 762 http_server_props_manager_->ShutdownOnPrefThread(); |
761 // Run the task after shutdown, but before deletion. | 763 // Run the task after shutdown, but before deletion. |
762 base::RunLoop().RunUntilIdle(); | 764 base::RunLoop().RunUntilIdle(); |
763 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 765 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
764 http_server_props_manager_.reset(); | 766 http_server_props_manager_.reset(); |
765 base::RunLoop().RunUntilIdle(); | 767 base::RunLoop().RunUntilIdle(); |
766 } | 768 } |
767 | 769 |
768 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { | 770 TEST_F(HttpServerPropertiesManagerTest, ShutdownWithPendingUpdatePrefs2) { |
769 // This posts a task to the UI thread. | 771 // This posts a task to the UI thread. |
770 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( | 772 http_server_props_manager_->UpdatePrefsFromCacheOnNetworkThreadConcrete( |
771 base::Closure()); | 773 base::Closure()); |
772 // Shutdown comes before the task is executed. | 774 // Shutdown comes before the task is executed. |
773 http_server_props_manager_->ShutdownOnPrefThread(); | 775 http_server_props_manager_->ShutdownOnPrefThread(); |
774 // Run the task after shutdown, but before deletion. | 776 // Run the task after shutdown, but before deletion. |
775 base::RunLoop().RunUntilIdle(); | 777 base::RunLoop().RunUntilIdle(); |
776 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); | 778 Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); |
777 http_server_props_manager_.reset(); | 779 http_server_props_manager_.reset(); |
778 base::RunLoop().RunUntilIdle(); | 780 base::RunLoop().RunUntilIdle(); |
779 } | 781 } |
780 | 782 |
781 } // namespace | 783 } // namespace |
782 | 784 |
783 } // namespace net | 785 } // namespace net |
OLD | NEW |