Chromium Code Reviews| Index: net/base/network_change_notifier_win_unittest.cc |
| diff --git a/net/base/network_change_notifier_win_unittest.cc b/net/base/network_change_notifier_win_unittest.cc |
| index 40dc42df66da65c94a2253e485e268753f0954bf..fa2e4ecce6efe548f9d654bd0550d8e0e4e6e671 100644 |
| --- a/net/base/network_change_notifier_win_unittest.cc |
| +++ b/net/base/network_change_notifier_win_unittest.cc |
| @@ -20,30 +20,9 @@ namespace net { |
| namespace { |
| -// Subclass of NetworkChangeNotifierWin that overrides functions so that no |
| -// Windows API networking functions are ever called. |
| -class TestNetworkChangeNotifierWin : public NetworkChangeNotifierWin { |
| - public: |
| - TestNetworkChangeNotifierWin() {} |
| - |
| - ~TestNetworkChangeNotifierWin() override { |
| - // This is needed so we don't try to stop watching for IP address changes, |
| - // as we never actually started. |
| - set_is_watching(false); |
| - } |
| - |
| - // From NetworkChangeNotifierWin. |
| - NetworkChangeNotifier::ConnectionType RecomputeCurrentConnectionType() |
| - const override { |
| - return NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| - } |
| - |
| - // From NetworkChangeNotifierWin. |
| - MOCK_METHOD0(WatchForAddressChangeInternal, bool()); |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifierWin); |
| -}; |
| +NetworkChangeNotifier::ConnectionType TestRecomputeCurrentConnectionType() { |
| + return NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| +} |
| class TestIPAddressObserver : public NetworkChangeNotifier::IPAddressObserver { |
| public: |
| @@ -68,6 +47,32 @@ bool ExitMessageLoopAndReturnFalse() { |
| } // namespace |
| +// Subclass of NetworkChangeNotifierWin that overrides functions so that no |
| +// Windows API networking functions are ever called. |
| +class TestNetworkChangeNotifierWin : public NetworkChangeNotifierWin { |
| + public: |
| + TestNetworkChangeNotifierWin() { |
| + // Use a mocked connection type callback. |
| + calculate_connection_type_ = |
| + base::BindRepeating(&TestRecomputeCurrentConnectionType); |
| + |
| + // Use this thread for dns tasks instead of a separate thread. |
| + dns_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
|
pauljensen
2017/05/23 17:57:40
why do we care what thread this is run on in tests
|
| + } |
| + |
| + ~TestNetworkChangeNotifierWin() override { |
| + // This is needed so we don't try to stop watching for IP address changes, |
| + // as we never actually started. |
| + set_is_watching(false); |
| + } |
| + |
| + // From NetworkChangeNotifierWin. |
| + MOCK_METHOD0(WatchForAddressChangeInternal, bool()); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifierWin); |
| +}; |
| + |
| class NetworkChangeNotifierWinTest : public testing::Test { |
| public: |
| // Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal |