| 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" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Going from offline to online should trigger a notification. | 117 // Going from offline to online should trigger a notification. |
| 118 SetOnline(); | 118 SetOnline(); |
| 119 EXPECT_EQ(2, notifications_count_getter.Run()); | 119 EXPECT_EQ(2, notifications_count_getter.Run()); |
| 120 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, | 120 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, |
| 121 connection_type_getter.Run()); | 121 connection_type_getter.Run()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void SetOnline() { | 124 void SetOnline() { |
| 125 delegate_.SetOnline(); | 125 delegate_.SetOnline(); |
| 126 // Note that this is needed because ObserverListThreadSafe uses PostTask(). | 126 // Note that this is needed because base::ObserverListThreadSafe uses |
| 127 // PostTask(). |
| 127 base::MessageLoop::current()->RunUntilIdle(); | 128 base::MessageLoop::current()->RunUntilIdle(); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void SetOffline() { | 131 void SetOffline() { |
| 131 delegate_.SetOffline(); | 132 delegate_.SetOffline(); |
| 132 // See comment above. | 133 // See comment above. |
| 133 base::MessageLoop::current()->RunUntilIdle(); | 134 base::MessageLoop::current()->RunUntilIdle(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 NetworkChangeNotifierDelegateAndroid delegate_; | 137 NetworkChangeNotifierDelegateAndroid delegate_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 TEST_F(NetworkChangeNotifierAndroidTest, InitialSignal) { | 273 TEST_F(NetworkChangeNotifierAndroidTest, InitialSignal) { |
| 273 DNSChangeObserver dns_change_observer; | 274 DNSChangeObserver dns_change_observer; |
| 274 NetworkChangeNotifier::AddDNSObserver(&dns_change_observer); | 275 NetworkChangeNotifier::AddDNSObserver(&dns_change_observer); |
| 275 base::MessageLoop::current()->Run(); | 276 base::MessageLoop::current()->Run(); |
| 276 EXPECT_EQ(1, dns_change_observer.initial_notifications_count()); | 277 EXPECT_EQ(1, dns_change_observer.initial_notifications_count()); |
| 277 EXPECT_EQ(0, dns_change_observer.change_notifications_count()); | 278 EXPECT_EQ(0, dns_change_observer.change_notifications_count()); |
| 278 NetworkChangeNotifier::RemoveDNSObserver(&dns_change_observer); | 279 NetworkChangeNotifier::RemoveDNSObserver(&dns_change_observer); |
| 279 } | 280 } |
| 280 | 281 |
| 281 } // namespace net | 282 } // namespace net |
| OLD | NEW |