| 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 #ifndef NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 5 #ifndef NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| 6 #define NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 6 #define NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include "net/base/network_change_notifier.h" | 8 #include "net/base/network_change_notifier.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 namespace test { | 11 namespace test { |
| 12 | 12 |
| 13 class MockNetworkChangeNotifier : public NetworkChangeNotifier { | 13 class MockNetworkChangeNotifier : public NetworkChangeNotifier { |
| 14 public: | 14 public: |
| 15 MockNetworkChangeNotifier(); | 15 MockNetworkChangeNotifier(); |
| 16 ~MockNetworkChangeNotifier() override; | 16 ~MockNetworkChangeNotifier() override; |
| 17 | 17 |
| 18 ConnectionType GetCurrentConnectionType() const override; | 18 ConnectionType GetCurrentConnectionType() const override; |
| 19 | 19 |
| 20 void ForceNetworkHandlesSupported(); | 20 void ForceNetworkHandlesSupported(); |
| 21 | 21 |
| 22 bool AreNetworkHandlesCurrentlySupported() const override; | 22 bool AreNetworkHandlesCurrentlySupported() const override; |
| 23 | 23 |
| 24 void SetConnectedNetworksList(const NetworkList& network_list); | 24 void SetConnectedNetworksList(const NetworkList& network_list); |
| 25 | 25 |
| 26 void GetCurrentConnectedNetworks(NetworkList* network_list) const override; | 26 void GetCurrentConnectedNetworks(NetworkList* network_list) const override; |
| 27 | 27 |
| 28 // Delivers a MADE_DEFAULT notification to observers. |
| 28 void NotifyNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); | 29 void NotifyNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); |
| 29 | 30 |
| 31 // Queues a MADE_DEFAULT notification to be delivered to observers |
| 32 // but does not spin the message loop to actually deliver it. |
| 33 void QueueNetworkMadeDefault(NetworkChangeNotifier::NetworkHandle network); |
| 34 |
| 35 // Delivers a DISCONNECTED notification to observers. |
| 30 void NotifyNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); | 36 void NotifyNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); |
| 31 | 37 |
| 38 // Queues a DISCONNECTED notification to be delivered to observers |
| 39 // but does not spin the message loop to actually deliver it. |
| 40 void QueueNetworkDisconnected(NetworkChangeNotifier::NetworkHandle network); |
| 41 |
| 32 private: | 42 private: |
| 33 bool force_network_handles_supported_; | 43 bool force_network_handles_supported_; |
| 34 NetworkChangeNotifier::NetworkList connected_networks_; | 44 NetworkChangeNotifier::NetworkList connected_networks_; |
| 35 }; | 45 }; |
| 36 | 46 |
| 37 // Class to replace existing NetworkChangeNotifier singleton with a | 47 // Class to replace existing NetworkChangeNotifier singleton with a |
| 38 // MockNetworkChangeNotifier for a test. To use, simply create a | 48 // MockNetworkChangeNotifier for a test. To use, simply create a |
| 39 // ScopedMockNetworkChangeNotifier object in the test. | 49 // ScopedMockNetworkChangeNotifier object in the test. |
| 40 class ScopedMockNetworkChangeNotifier { | 50 class ScopedMockNetworkChangeNotifier { |
| 41 public: | 51 public: |
| 42 ScopedMockNetworkChangeNotifier(); | 52 ScopedMockNetworkChangeNotifier(); |
| 43 ~ScopedMockNetworkChangeNotifier(); | 53 ~ScopedMockNetworkChangeNotifier(); |
| 44 | 54 |
| 45 MockNetworkChangeNotifier* mock_network_change_notifier(); | 55 MockNetworkChangeNotifier* mock_network_change_notifier(); |
| 46 | 56 |
| 47 private: | 57 private: |
| 48 std::unique_ptr<NetworkChangeNotifier::DisableForTest> | 58 std::unique_ptr<NetworkChangeNotifier::DisableForTest> |
| 49 disable_network_change_notifier_for_tests_; | 59 disable_network_change_notifier_for_tests_; |
| 50 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; | 60 std::unique_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_; |
| 51 }; | 61 }; |
| 52 | 62 |
| 53 } // namespace test | 63 } // namespace test |
| 54 } // namespace net | 64 } // namespace net |
| 55 | 65 |
| 56 #endif // NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ | 66 #endif // NET_QUIC_CHROMIUM_MOCK_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |