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

Side by Side Diff: chrome/browser/web_resource/resource_request_allowed_notifier_unittest.cc

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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/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 12 matching lines...) Expand all
23 // Simulates a change of the connection type to |type|. This will notify any 23 // Simulates a change of the connection type to |type|. This will notify any
24 // objects that are NetworkChangeNotifiers. 24 // objects that are NetworkChangeNotifiers.
25 void SimulateNetworkConnectionChange( 25 void SimulateNetworkConnectionChange(
26 net::NetworkChangeNotifier::ConnectionType type) { 26 net::NetworkChangeNotifier::ConnectionType type) {
27 connection_type_to_return_ = type; 27 connection_type_to_return_ = type;
28 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); 28 net::NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
29 base::MessageLoop::current()->RunUntilIdle(); 29 base::MessageLoop::current()->RunUntilIdle();
30 } 30 }
31 31
32 private: 32 private:
33 virtual ConnectionType GetCurrentConnectionType() const override { 33 ConnectionType GetCurrentConnectionType() const override {
34 return connection_type_to_return_; 34 return connection_type_to_return_;
35 } 35 }
36 36
37 // The currently simulated network connection type. If this is set to 37 // The currently simulated network connection type. If this is set to
38 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true. 38 // CONNECTION_NONE, then NetworkChangeNotifier::IsOffline will return true.
39 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_; 39 net::NetworkChangeNotifier::ConnectionType connection_type_to_return_;
40 40
41 DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifier); 41 DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifier);
42 }; 42 };
43 43
44 // EulaAcceptedNotifier test class that allows mocking the EULA accepted state 44 // EulaAcceptedNotifier test class that allows mocking the EULA accepted state
45 // and issuing simulated notifications. 45 // and issuing simulated notifications.
46 class TestEulaAcceptedNotifier : public EulaAcceptedNotifier { 46 class TestEulaAcceptedNotifier : public EulaAcceptedNotifier {
47 public: 47 public:
48 TestEulaAcceptedNotifier() 48 TestEulaAcceptedNotifier()
49 : EulaAcceptedNotifier(NULL), 49 : EulaAcceptedNotifier(NULL),
50 eula_accepted_(false) { 50 eula_accepted_(false) {
51 } 51 }
52 virtual ~TestEulaAcceptedNotifier() { 52 ~TestEulaAcceptedNotifier() override {}
53 }
54 53
55 virtual bool IsEulaAccepted() override { 54 bool IsEulaAccepted() override { return eula_accepted_; }
56 return eula_accepted_;
57 }
58 55
59 void SetEulaAcceptedForTesting(bool eula_accepted) { 56 void SetEulaAcceptedForTesting(bool eula_accepted) {
60 eula_accepted_ = eula_accepted; 57 eula_accepted_ = eula_accepted;
61 } 58 }
62 59
63 void SimulateEulaAccepted() { 60 void SimulateEulaAccepted() {
64 NotifyObserver(); 61 NotifyObserver();
65 } 62 }
66 63
67 private: 64 private:
(...skipping 14 matching lines...) Expand all
82 eula_notifier_(new TestEulaAcceptedNotifier), 79 eula_notifier_(new TestEulaAcceptedNotifier),
83 was_notified_(false) { 80 was_notified_(false) {
84 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier( 81 resource_request_allowed_notifier_.InitWithEulaAcceptNotifier(
85 this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_)); 82 this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_));
86 } 83 }
87 virtual ~ResourceRequestAllowedNotifierTest() { } 84 virtual ~ResourceRequestAllowedNotifierTest() { }
88 85
89 bool was_notified() const { return was_notified_; } 86 bool was_notified() const { return was_notified_; }
90 87
91 // ResourceRequestAllowedNotifier::Observer override: 88 // ResourceRequestAllowedNotifier::Observer override:
92 virtual void OnResourceRequestsAllowed() override { 89 void OnResourceRequestsAllowed() override { was_notified_ = true; }
93 was_notified_ = true;
94 }
95 90
96 // Network manipulation methods: 91 // Network manipulation methods:
97 void SetWaitingForNetwork(bool waiting) { 92 void SetWaitingForNetwork(bool waiting) {
98 resource_request_allowed_notifier_.SetWaitingForNetworkForTesting(waiting); 93 resource_request_allowed_notifier_.SetWaitingForNetworkForTesting(waiting);
99 } 94 }
100 95
101 void SimulateNetworkConnectionChange( 96 void SimulateNetworkConnectionChange(
102 net::NetworkChangeNotifier::ConnectionType type) { 97 net::NetworkChangeNotifier::ConnectionType type) {
103 network_notifier.SimulateNetworkConnectionChange(type); 98 network_notifier.SimulateNetworkConnectionChange(type);
104 } 99 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // calling SimulateResourceRequest here. 284 // calling SimulateResourceRequest here.
290 DisableEulaAndNetwork(); 285 DisableEulaAndNetwork();
291 286
292 SimulateNetworkConnectionChange( 287 SimulateNetworkConnectionChange(
293 net::NetworkChangeNotifier::CONNECTION_WIFI); 288 net::NetworkChangeNotifier::CONNECTION_WIFI);
294 EXPECT_FALSE(was_notified()); 289 EXPECT_FALSE(was_notified());
295 290
296 SimulateEulaAccepted(); 291 SimulateEulaAccepted();
297 EXPECT_FALSE(was_notified()); 292 EXPECT_FALSE(was_notified());
298 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698