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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // and relying on the first network change notification to set it correctly can | 267 // and relying on the first network change notification to set it correctly can |
268 // be problematic in case there is a long delay between the delegate's | 268 // be problematic in case there is a long delay between the delegate's |
269 // construction and the notification. | 269 // construction and the notification. |
270 TEST_F(BaseNetworkChangeNotifierAndroidTest, | 270 TEST_F(BaseNetworkChangeNotifierAndroidTest, |
271 DelegateIsInitializedWithCurrentConnectionType) { | 271 DelegateIsInitializedWithCurrentConnectionType) { |
272 SetOffline(); | 272 SetOffline(); |
273 ASSERT_EQ(NetworkChangeNotifier::CONNECTION_NONE, | 273 ASSERT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
274 delegate_.GetCurrentConnectionType()); | 274 delegate_.GetCurrentConnectionType()); |
275 // Instantiate another delegate to validate that it uses the actual | 275 // Instantiate another delegate to validate that it uses the actual |
276 // connection type at construction. | 276 // connection type at construction. |
277 scoped_ptr<NetworkChangeNotifierDelegateAndroid> other_delegate( | 277 std::unique_ptr<NetworkChangeNotifierDelegateAndroid> other_delegate( |
278 new NetworkChangeNotifierDelegateAndroid()); | 278 new NetworkChangeNotifierDelegateAndroid()); |
279 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, | 279 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE, |
280 other_delegate->GetCurrentConnectionType()); | 280 other_delegate->GetCurrentConnectionType()); |
281 | 281 |
282 // Toggle the global connectivity state and instantiate another delegate | 282 // Toggle the global connectivity state and instantiate another delegate |
283 // again. | 283 // again. |
284 SetOnline(); | 284 SetOnline(); |
285 ASSERT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, | 285 ASSERT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, |
286 delegate_.GetCurrentConnectionType()); | 286 delegate_.GetCurrentConnectionType()); |
287 other_delegate.reset(new NetworkChangeNotifierDelegateAndroid()); | 287 other_delegate.reset(new NetworkChangeNotifierDelegateAndroid()); |
(...skipping 19 matching lines...) Expand all Loading... |
307 | 307 |
308 void ForceNetworkHandlesSupportedForTesting() { | 308 void ForceNetworkHandlesSupportedForTesting() { |
309 notifier_->ForceNetworkHandlesSupportedForTesting(); | 309 notifier_->ForceNetworkHandlesSupportedForTesting(); |
310 } | 310 } |
311 | 311 |
312 NetworkChangeNotifierObserver connection_type_observer_; | 312 NetworkChangeNotifierObserver connection_type_observer_; |
313 NetworkChangeNotifierMaxBandwidthObserver max_bandwidth_observer_; | 313 NetworkChangeNotifierMaxBandwidthObserver max_bandwidth_observer_; |
314 NetworkChangeNotifierObserver other_connection_type_observer_; | 314 NetworkChangeNotifierObserver other_connection_type_observer_; |
315 NetworkChangeNotifier::DisableForTest disable_for_test_; | 315 NetworkChangeNotifier::DisableForTest disable_for_test_; |
316 DnsConfig dns_config_; | 316 DnsConfig dns_config_; |
317 scoped_ptr<NetworkChangeNotifierAndroid> notifier_; | 317 std::unique_ptr<NetworkChangeNotifierAndroid> notifier_; |
318 }; | 318 }; |
319 | 319 |
320 class NetworkChangeNotifierDelegateAndroidTest | 320 class NetworkChangeNotifierDelegateAndroidTest |
321 : public NetworkChangeNotifierAndroidTest { | 321 : public NetworkChangeNotifierAndroidTest { |
322 protected: | 322 protected: |
323 NetworkChangeNotifierDelegateAndroidTest() { | 323 NetworkChangeNotifierDelegateAndroidTest() { |
324 delegate_.AddObserver(&delegate_observer_); | 324 delegate_.AddObserver(&delegate_observer_); |
325 delegate_.AddObserver(&other_delegate_observer_); | 325 delegate_.AddObserver(&other_delegate_observer_); |
326 } | 326 } |
327 | 327 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 NetworkChangeNotifier::GetConnectedNetworks(&network_list); | 521 NetworkChangeNotifier::GetConnectedNetworks(&network_list); |
522 EXPECT_EQ(1u, network_list.size()); | 522 EXPECT_EQ(1u, network_list.size()); |
523 EXPECT_EQ(100, network_list[0]); | 523 EXPECT_EQ(100, network_list[0]); |
524 EXPECT_EQ(NetworkChangeNotifier::kInvalidNetworkHandle, | 524 EXPECT_EQ(NetworkChangeNotifier::kInvalidNetworkHandle, |
525 NetworkChangeNotifier::GetDefaultNetwork()); | 525 NetworkChangeNotifier::GetDefaultNetwork()); |
526 | 526 |
527 NetworkChangeNotifier::RemoveNetworkObserver(&network_observer); | 527 NetworkChangeNotifier::RemoveNetworkObserver(&network_observer); |
528 } | 528 } |
529 | 529 |
530 } // namespace net | 530 } // namespace net |
OLD | NEW |