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 "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/web_resource/eula_accepted_notifier.h" | 7 #include "chrome/browser/web_resource/eula_accepted_notifier.h" |
8 #include "chrome/browser/web_resource/resource_request_allowed_notifier_test_uti
l.h" | 8 #include "chrome/browser/web_resource/resource_request_allowed_notifier_test_uti
l.h" |
9 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 : public testing::Test, | 74 : public testing::Test, |
75 public ResourceRequestAllowedNotifier::Observer { | 75 public ResourceRequestAllowedNotifier::Observer { |
76 public: | 76 public: |
77 ResourceRequestAllowedNotifierTest() | 77 ResourceRequestAllowedNotifierTest() |
78 : ui_thread(content::BrowserThread::UI, &message_loop), | 78 : ui_thread(content::BrowserThread::UI, &message_loop), |
79 eula_notifier_(new TestEulaAcceptedNotifier), | 79 eula_notifier_(new TestEulaAcceptedNotifier), |
80 was_notified_(false) { | 80 was_notified_(false) { |
81 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier( | 81 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier( |
82 this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_)); | 82 this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_)); |
83 } | 83 } |
84 virtual ~ResourceRequestAllowedNotifierTest() { } | 84 ~ResourceRequestAllowedNotifierTest() override {} |
85 | 85 |
86 bool was_notified() const { return was_notified_; } | 86 bool was_notified() const { return was_notified_; } |
87 | 87 |
88 // ResourceRequestAllowedNotifier::Observer override: | 88 // ResourceRequestAllowedNotifier::Observer override: |
89 void OnResourceRequestsAllowed() override { was_notified_ = true; } | 89 void OnResourceRequestsAllowed() override { was_notified_ = true; } |
90 | 90 |
91 // Network manipulation methods: | 91 // Network manipulation methods: |
92 void SetWaitingForNetwork(bool waiting) { | 92 void SetWaitingForNetwork(bool waiting) { |
93 resource_request_allowed_notifier_.SetWaitingForNetworkForTesting(waiting); | 93 resource_request_allowed_notifier_.SetWaitingForNetworkForTesting(waiting); |
94 } | 94 } |
(...skipping 26 matching lines...) Expand all Loading... |
121 // Used in tests involving the EULA. Disables both the EULA accepted state | 121 // Used in tests involving the EULA. Disables both the EULA accepted state |
122 // and the network. | 122 // and the network. |
123 void DisableEulaAndNetwork() { | 123 void DisableEulaAndNetwork() { |
124 SetWaitingForNetwork(true); | 124 SetWaitingForNetwork(true); |
125 SimulateNetworkConnectionChange( | 125 SimulateNetworkConnectionChange( |
126 net::NetworkChangeNotifier::CONNECTION_NONE); | 126 net::NetworkChangeNotifier::CONNECTION_NONE); |
127 SetWaitingForEula(true); | 127 SetWaitingForEula(true); |
128 SetNeedsEulaAcceptance(true); | 128 SetNeedsEulaAcceptance(true); |
129 } | 129 } |
130 | 130 |
131 virtual void SetUp() override { | 131 void SetUp() override { |
132 // Assume the test service has already requested permission, as all tests | 132 // Assume the test service has already requested permission, as all tests |
133 // just test that criteria changes notify the server. | 133 // just test that criteria changes notify the server. |
134 // Set default EULA state to done (not waiting and EULA accepted) to | 134 // Set default EULA state to done (not waiting and EULA accepted) to |
135 // simplify non-ChromeOS tests. | 135 // simplify non-ChromeOS tests. |
136 SetWaitingForEula(false); | 136 SetWaitingForEula(false); |
137 SetNeedsEulaAcceptance(false); | 137 SetNeedsEulaAcceptance(false); |
138 } | 138 } |
139 | 139 |
140 private: | 140 private: |
141 base::MessageLoopForUI message_loop; | 141 base::MessageLoopForUI message_loop; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // calling SimulateResourceRequest here. | 284 // calling SimulateResourceRequest here. |
285 DisableEulaAndNetwork(); | 285 DisableEulaAndNetwork(); |
286 | 286 |
287 SimulateNetworkConnectionChange( | 287 SimulateNetworkConnectionChange( |
288 net::NetworkChangeNotifier::CONNECTION_WIFI); | 288 net::NetworkChangeNotifier::CONNECTION_WIFI); |
289 EXPECT_FALSE(was_notified()); | 289 EXPECT_FALSE(was_notified()); |
290 | 290 |
291 SimulateEulaAccepted(); | 291 SimulateEulaAccepted(); |
292 EXPECT_FALSE(was_notified()); | 292 EXPECT_FALSE(was_notified()); |
293 } | 293 } |
OLD | NEW |