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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/ptr_util.h" |
6 #include "components/prefs/testing_pref_service.h" | 7 #include "components/prefs/testing_pref_service.h" |
7 #include "components/web_resource/eula_accepted_notifier.h" | 8 #include "components/web_resource/eula_accepted_notifier.h" |
8 #include "components/web_resource/resource_request_allowed_notifier_test_util.h" | 9 #include "components/web_resource/resource_request_allowed_notifier_test_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 namespace web_resource { | 12 namespace web_resource { |
12 | 13 |
13 // Override NetworkChangeNotifier to simulate connection type changes for tests. | 14 // Override NetworkChangeNotifier to simulate connection type changes for tests. |
14 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { | 15 class TestNetworkChangeNotifier : public net::NetworkChangeNotifier { |
15 public: | 16 public: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // ResourceRequestAllowedNotifier::Observer interface. | 73 // ResourceRequestAllowedNotifier::Observer interface. |
73 class ResourceRequestAllowedNotifierTest | 74 class ResourceRequestAllowedNotifierTest |
74 : public testing::Test, | 75 : public testing::Test, |
75 public ResourceRequestAllowedNotifier::Observer { | 76 public ResourceRequestAllowedNotifier::Observer { |
76 public: | 77 public: |
77 ResourceRequestAllowedNotifierTest() | 78 ResourceRequestAllowedNotifierTest() |
78 : resource_request_allowed_notifier_(&prefs_), | 79 : resource_request_allowed_notifier_(&prefs_), |
79 eula_notifier_(new TestEulaAcceptedNotifier), | 80 eula_notifier_(new TestEulaAcceptedNotifier), |
80 was_notified_(false) { | 81 was_notified_(false) { |
81 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier( | 82 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier( |
82 this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_)); | 83 this, base::WrapUnique(eula_notifier_)); |
83 } | 84 } |
84 ~ResourceRequestAllowedNotifierTest() override {} | 85 ~ResourceRequestAllowedNotifierTest() override {} |
85 | 86 |
86 bool was_notified() const { return was_notified_; } | 87 bool was_notified() const { return was_notified_; } |
87 | 88 |
88 // ResourceRequestAllowedNotifier::Observer override: | 89 // ResourceRequestAllowedNotifier::Observer override: |
89 void OnResourceRequestsAllowed() override { was_notified_ = true; } | 90 void OnResourceRequestsAllowed() override { was_notified_ = true; } |
90 | 91 |
91 // Network manipulation methods: | 92 // Network manipulation methods: |
92 void SetWaitingForNetwork(bool waiting) { | 93 void SetWaitingForNetwork(bool waiting) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 DisableEulaAndNetwork(); | 272 DisableEulaAndNetwork(); |
272 | 273 |
273 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI); | 274 SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_WIFI); |
274 EXPECT_FALSE(was_notified()); | 275 EXPECT_FALSE(was_notified()); |
275 | 276 |
276 SimulateEulaAccepted(); | 277 SimulateEulaAccepted(); |
277 EXPECT_FALSE(was_notified()); | 278 EXPECT_FALSE(was_notified()); |
278 } | 279 } |
279 | 280 |
280 } // namespace web_resource | 281 } // namespace web_resource |
OLD | NEW |