OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // See network_change_notifier_android.h for design explanations. | 5 // See network_change_notifier_android.h for design explanations. |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "net/android/network_change_notifier_android.h" | 12 #include "net/android/network_change_notifier_android.h" |
13 #include "net/android/network_change_notifier_delegate_android.h" | 13 #include "net/android/network_change_notifier_delegate_android.h" |
14 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class NetworkChangeNotifierDelegateAndroidObserver | 21 class NetworkChangeNotifierDelegateAndroidObserver |
22 : public NetworkChangeNotifierDelegateAndroid::Observer { | 22 : public NetworkChangeNotifierDelegateAndroid::Observer { |
23 public: | 23 public: |
24 NetworkChangeNotifierDelegateAndroidObserver() : notifications_count_(0) {} | 24 NetworkChangeNotifierDelegateAndroidObserver() : notifications_count_(0) {} |
25 | 25 |
26 // NetworkChangeNotifierDelegateAndroid::Observer: | 26 // NetworkChangeNotifierDelegateAndroid::Observer: |
27 virtual void OnConnectionTypeChanged() OVERRIDE { | 27 virtual void OnConnectionTypeChanged() override { |
28 notifications_count_++; | 28 notifications_count_++; |
29 } | 29 } |
30 | 30 |
31 int notifications_count() const { | 31 int notifications_count() const { |
32 return notifications_count_; | 32 return notifications_count_; |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 int notifications_count_; | 36 int notifications_count_; |
37 }; | 37 }; |
38 | 38 |
39 class NetworkChangeNotifierObserver | 39 class NetworkChangeNotifierObserver |
40 : public NetworkChangeNotifier::ConnectionTypeObserver { | 40 : public NetworkChangeNotifier::ConnectionTypeObserver { |
41 public: | 41 public: |
42 NetworkChangeNotifierObserver() : notifications_count_(0) {} | 42 NetworkChangeNotifierObserver() : notifications_count_(0) {} |
43 | 43 |
44 // NetworkChangeNotifier::Observer: | 44 // NetworkChangeNotifier::Observer: |
45 virtual void OnConnectionTypeChanged( | 45 virtual void OnConnectionTypeChanged( |
46 NetworkChangeNotifier::ConnectionType connection_type) OVERRIDE { | 46 NetworkChangeNotifier::ConnectionType connection_type) override { |
47 notifications_count_++; | 47 notifications_count_++; |
48 } | 48 } |
49 | 49 |
50 int notifications_count() const { | 50 int notifications_count() const { |
51 return notifications_count_; | 51 return notifications_count_; |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 int notifications_count_; | 55 int notifications_count_; |
56 }; | 56 }; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 base::Bind( | 207 base::Bind( |
208 &NetworkChangeNotifierObserver::notifications_count, | 208 &NetworkChangeNotifierObserver::notifications_count, |
209 base::Unretained(&connection_type_observer_)), | 209 base::Unretained(&connection_type_observer_)), |
210 base::Bind(&NetworkChangeNotifier::GetConnectionType)); | 210 base::Bind(&NetworkChangeNotifier::GetConnectionType)); |
211 // Check that *all* the observers are notified. | 211 // Check that *all* the observers are notified. |
212 EXPECT_EQ(connection_type_observer_.notifications_count(), | 212 EXPECT_EQ(connection_type_observer_.notifications_count(), |
213 other_connection_type_observer_.notifications_count()); | 213 other_connection_type_observer_.notifications_count()); |
214 } | 214 } |
215 | 215 |
216 } // namespace net | 216 } // namespace net |
OLD | NEW |