| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/quic/chromium/mock_network_change_notifier.h" | |
| 6 | |
| 7 #include "base/run_loop.h" | |
| 8 | |
| 9 namespace net { | |
| 10 namespace test { | |
| 11 | |
| 12 MockNetworkChangeNotifier::MockNetworkChangeNotifier() | |
| 13 : force_network_handles_supported_(false), | |
| 14 connection_type_(CONNECTION_UNKNOWN) {} | |
| 15 MockNetworkChangeNotifier::~MockNetworkChangeNotifier() {} | |
| 16 | |
| 17 MockNetworkChangeNotifier::ConnectionType | |
| 18 MockNetworkChangeNotifier::GetCurrentConnectionType() const { | |
| 19 return connection_type_; | |
| 20 } | |
| 21 | |
| 22 void MockNetworkChangeNotifier::ForceNetworkHandlesSupported() { | |
| 23 force_network_handles_supported_ = true; | |
| 24 } | |
| 25 | |
| 26 bool MockNetworkChangeNotifier::AreNetworkHandlesCurrentlySupported() const { | |
| 27 return force_network_handles_supported_; | |
| 28 } | |
| 29 | |
| 30 void MockNetworkChangeNotifier::SetConnectedNetworksList( | |
| 31 const NetworkList& network_list) { | |
| 32 connected_networks_ = network_list; | |
| 33 } | |
| 34 | |
| 35 void MockNetworkChangeNotifier::GetCurrentConnectedNetworks( | |
| 36 NetworkList* network_list) const { | |
| 37 network_list->clear(); | |
| 38 *network_list = connected_networks_; | |
| 39 } | |
| 40 | |
| 41 void MockNetworkChangeNotifier::NotifyNetworkMadeDefault( | |
| 42 NetworkChangeNotifier::NetworkHandle network) { | |
| 43 QueueNetworkMadeDefault(network); | |
| 44 // Spin the message loop so the notification is delivered. | |
| 45 base::RunLoop().RunUntilIdle(); | |
| 46 } | |
| 47 | |
| 48 void MockNetworkChangeNotifier::QueueNetworkMadeDefault( | |
| 49 NetworkChangeNotifier::NetworkHandle network) { | |
| 50 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( | |
| 51 NetworkChangeNotifier::MADE_DEFAULT, network); | |
| 52 } | |
| 53 | |
| 54 void MockNetworkChangeNotifier::NotifyNetworkDisconnected( | |
| 55 NetworkChangeNotifier::NetworkHandle network) { | |
| 56 QueueNetworkDisconnected(network); | |
| 57 // Spin the message loop so the notification is delivered. | |
| 58 base::RunLoop().RunUntilIdle(); | |
| 59 } | |
| 60 | |
| 61 void MockNetworkChangeNotifier::QueueNetworkDisconnected( | |
| 62 NetworkChangeNotifier::NetworkHandle network) { | |
| 63 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( | |
| 64 NetworkChangeNotifier::DISCONNECTED, network); | |
| 65 } | |
| 66 | |
| 67 void MockNetworkChangeNotifier::NotifyNetworkConnected( | |
| 68 NetworkChangeNotifier::NetworkHandle network) { | |
| 69 NetworkChangeNotifier::NotifyObserversOfSpecificNetworkChange( | |
| 70 NetworkChangeNotifier::CONNECTED, network); | |
| 71 // Spin the message loop so the notification is delivered. | |
| 72 base::RunLoop().RunUntilIdle(); | |
| 73 } | |
| 74 | |
| 75 ScopedMockNetworkChangeNotifier::ScopedMockNetworkChangeNotifier() | |
| 76 : disable_network_change_notifier_for_tests_( | |
| 77 new NetworkChangeNotifier::DisableForTest()), | |
| 78 mock_network_change_notifier_(new MockNetworkChangeNotifier()) {} | |
| 79 | |
| 80 ScopedMockNetworkChangeNotifier::~ScopedMockNetworkChangeNotifier() {} | |
| 81 | |
| 82 MockNetworkChangeNotifier* | |
| 83 ScopedMockNetworkChangeNotifier::mock_network_change_notifier() { | |
| 84 return mock_network_change_notifier_.get(); | |
| 85 } | |
| 86 | |
| 87 } // namespace test | |
| 88 } // namespace net | |
| OLD | NEW |