OLD | NEW |
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/prefs/testing_pref_service.h" | 5 #include "base/prefs/testing_pref_service.h" |
6 #include "components/web_resource/eula_accepted_notifier.h" | 6 #include "components/web_resource/eula_accepted_notifier.h" |
7 #include "components/web_resource/resource_request_allowed_notifier_test_util.h" | 7 #include "components/web_resource/resource_request_allowed_notifier_test_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace web_resource { | 10 namespace web_resource { |
11 | 11 |
12 // Override NetworkChangeNotifier to simulate connection type changes for tests. | 12 // Override NetworkChangeNotifier to simulate connection type changes for tests. |
13 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { | 13 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { |
14 public: | 14 public: |
15 TestNetworkChangeNotifier() | 15 TestNetworkChangeNotifier() |
16 : net::NetworkChangeNotifier(), | 16 : net::NetworkChangeNotifier(), |
17 connection_type_to_return_( | 17 connection_type_to_return_( |
18 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) { | 18 net::NetworkChangeNotifier::CONNECTION_UNKNOWN) { |
19 } | 19 } |
20 | 20 |
21 // Simulates a change of the connection type to |type|. This will notify any | 21 // Simulates a change of the connection type to |type|. This will notify any |
22 // objects that are NetworkChangeNotifiers. | 22 // objects that are NetworkChangeNotifiers. |
23 void SimulateNetworkConnectionChange( | 23 void SimulateNetworkConnectionChange( |
24 net::NetworkChangeNotifier::ConnectionType type) { | 24 net::NetworkChangeNotifier::ConnectionType type) { |
25 connection_type_to_return_ = type; | 25 connection_type_to_return_ = type; |
26 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); | 26 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChangeForTests( |
| 27 connection_type_to_return_); |
27 base::MessageLoop::current()->RunUntilIdle(); | 28 base::MessageLoop::current()->RunUntilIdle(); |
28 } | 29 } |
29 | 30 |
30 private: | 31 private: |
31 ConnectionType GetCurrentConnectionType() const override { | 32 ConnectionType GetCurrentConnectionType() const override { |
32 return connection_type_to_return_; | 33 return connection_type_to_return_; |
33 } | 34 } |
34 | 35 |
35 // The currently simulated network connection type. If this is set to | 36 // The currently simulated network connection type. If this is set to |
36 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true. | 37 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 DisableEulaAndNetwork(); | 270 DisableEulaAndNetwork(); |
270 | 271 |
271 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI); | 272 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI); |
272 EXPECT_FALSE(was_notified()); | 273 EXPECT_FALSE(was_notified()); |
273 | 274 |
274 SimulateEulaAccepted(); | 275 SimulateEulaAccepted(); |
275 EXPECT_FALSE(was_notified()); | 276 EXPECT_FALSE(was_notified()); |
276 } | 277 } |
277 | 278 |
278 } // namespace web_resource | 279 } // namespace web_resource |
OLD | NEW |