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

Side by Side Diff: components/web_resource/resource_request_allowed_notifier_unittest.cc

Issue 2053913002: Remove MessageLoop::current()->RunUntilIdle() in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « components/translate/core/browser/translate_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/run_loop.h"
7 #include "components/prefs/testing_pref_service.h" 8 #include "components/prefs/testing_pref_service.h"
8 #include "components/web_resource/eula_accepted_notifier.h" 9 #include "components/web_resource/eula_accepted_notifier.h"
9 #include "components/web_resource/resource_request_allowed_notifier_test_util.h" 10 #include "components/web_resource/resource_request_allowed_notifier_test_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace web_resource { 13 namespace web_resource {
13 14
14 // Override NetworkChangeNotifier to simulate connection type changes for tests. 15 // Override NetworkChangeNotifier to simulate connection type changes for tests.
15 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { 16 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier {
16 public: 17 public:
17 TestNetworkChangeNotifier() 18 TestNetworkChangeNotifier()
18 : net::NetworkChangeNotifier(), 19 : net::NetworkChangeNotifier(),
19 connection_type_to_return_( 20 connection_type_to_return_(
20 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) { 21 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) {
21 } 22 }
22 23
23 // Simulates a change of the connection type to |type|. This will notify any 24 // Simulates a change of the connection type to |type|. This will notify any
24 // objects that are NetworkChangeNotifiers. 25 // objects that are NetworkChangeNotifiers.
25 void SimulateNetworkConnectionChange( 26 void SimulateNetworkConnectionChange(
26 net::NetworkChangeNotifier::ConnectionType type) { 27 net::NetworkChangeNotifier::ConnectionType type) {
27 connection_type_to_return_ = type; 28 connection_type_to_return_ = type;
28 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( 29 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests(
29 connection_type_to_return_); 30 connection_type_to_return_);
30 base::MessageLoop::current()->RunUntilIdle(); 31 base::RunLoop().RunUntilIdle();
31 } 32 }
32 33
33 private: 34 private:
34 ConnectionType GetCurrentConnectionType() const override { 35 ConnectionType GetCurrentConnectionType() const override {
35 return connection_type_to_return_; 36 return connection_type_to_return_;
36 } 37 }
37 38
38 // The currently simulated network connection type. If this is set to 39 // The currently simulated network connection type. If this is set to
39 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true. 40 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true.
40 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_; 41 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 DisableEulaAndNetwork(); 273 DisableEulaAndNetwork();
273 274
274 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI); 275 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI);
275 EXPECT_FALSE(was_notified()); 276 EXPECT_FALSE(was_notified());
276 277
277 SimulateEulaAccepted(); 278 SimulateEulaAccepted();
278 EXPECT_FALSE(was_notified()); 279 EXPECT_FALSE(was_notified());
279 } 280 }
280 281
281 } // namespace web_resource 282 } // namespace web_resource
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698