Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Unified Diff: net/base/network_change_notifier_win_unittest.cc

Issue 2893943002: [NetworkChangeNotifier] Run Windows connection type computation on other thread (Closed)
Patch Set: Nit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« net/base/network_change_notifier_win.cc ('K') | « net/base/network_change_notifier_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698