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

Side by Side Diff: net/base/network_change_notifier_win_unittest.cc

Issue 1398973003: Don't use base::MessageLoop::{Quit,QuitClosure} in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/cookies/cookie_monster_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "net/base/network_change_notifier.h" 6 #include "net/base/network_change_notifier.h"
7 #include "net/base/network_change_notifier_factory.h" 7 #include "net/base/network_change_notifier_factory.h"
8 #include "net/base/network_change_notifier_win.h" 8 #include "net/base/network_change_notifier_win.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 NetworkChangeNotifier::RemoveIPAddressObserver(this); 53 NetworkChangeNotifier::RemoveIPAddressObserver(this);
54 } 54 }
55 55
56 MOCK_METHOD0(OnIPAddressChanged, void()); 56 MOCK_METHOD0(OnIPAddressChanged, void());
57 57
58 private: 58 private:
59 DISALLOW_COPY_AND_ASSIGN(TestIPAddressObserver); 59 DISALLOW_COPY_AND_ASSIGN(TestIPAddressObserver);
60 }; 60 };
61 61
62 bool ExitMessageLoopAndReturnFalse() { 62 bool ExitMessageLoopAndReturnFalse() {
63 base::MessageLoop::current()->Quit(); 63 base::MessageLoop::current()->QuitWhenIdle();
64 return false; 64 return false;
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 class NetworkChangeNotifierWinTest : public testing::Test { 69 class NetworkChangeNotifierWinTest : public testing::Test {
70 public: 70 public:
71 // Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal 71 // Calls WatchForAddressChange, and simulates a WatchForAddressChangeInternal
72 // success. Expects that |network_change_notifier_| has just been created, so 72 // success. Expects that |network_change_notifier_| has just been created, so
73 // it's not watching anything yet, and there have been no previous 73 // it's not watching anything yet, and there have been no previous
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 158
159 // Runs the message loop until WatchForAddressChange is called again, as a 159 // Runs the message loop until WatchForAddressChange is called again, as a
160 // result of the already posted task after a WatchForAddressChangeInternal 160 // result of the already posted task after a WatchForAddressChangeInternal
161 // failure. Simulates a success on the resulting call to 161 // failure. Simulates a success on the resulting call to
162 // WatchForAddressChangeInternal. 162 // WatchForAddressChangeInternal.
163 void RetryAndSucceed() { 163 void RetryAndSucceed() {
164 EXPECT_FALSE(network_change_notifier_.is_watching()); 164 EXPECT_FALSE(network_change_notifier_.is_watching());
165 EXPECT_LT(0, network_change_notifier_.sequential_failures()); 165 EXPECT_LT(0, network_change_notifier_.sequential_failures());
166 166
167 EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged()).Times(1) 167 EXPECT_CALL(test_ip_address_observer_, OnIPAddressChanged())
168 .WillOnce( 168 .Times(1)
169 Invoke(base::MessageLoop::current(), &base::MessageLoop::Quit)); 169 .WillOnce(Invoke(base::MessageLoop::current(),
170 &base::MessageLoop::QuitWhenIdle));
170 EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal()) 171 EXPECT_CALL(network_change_notifier_, WatchForAddressChangeInternal())
171 .Times(1).WillOnce(Return(true)); 172 .Times(1).WillOnce(Return(true));
172 173
173 base::MessageLoop::current()->Run(); 174 base::MessageLoop::current()->Run();
174 175
175 EXPECT_TRUE(network_change_notifier_.is_watching()); 176 EXPECT_TRUE(network_change_notifier_.is_watching());
176 EXPECT_EQ(0, network_change_notifier_.sequential_failures()); 177 EXPECT_EQ(0, network_change_notifier_.sequential_failures());
177 } 178 }
178 179
179 // Runs the message loop until WatchForAddressChange is called again, as a 180 // Runs the message loop until WatchForAddressChange is called again, as a
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 251 }
251 252
252 TEST_F(NetworkChangeNotifierWinTest, NetChangeWinFailSignalTwice) { 253 TEST_F(NetworkChangeNotifierWinTest, NetChangeWinFailSignalTwice) {
253 StartWatchingAndSucceed(); 254 StartWatchingAndSucceed();
254 SignalAndFail(); 255 SignalAndFail();
255 RetryAndFail(); 256 RetryAndFail();
256 RetryAndSucceed(); 257 RetryAndSucceed();
257 } 258 }
258 259
259 } // namespace net 260 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/cookies/cookie_monster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698