| 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 #include "net/android/network_change_notifier_android.h" | 5 #include "net/android/network_change_notifier_android.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "net/android/network_change_notifier_factory_android.h" | 8 #include "net/android/network_change_notifier_factory_android.h" |
| 9 #include "net/base/network_change_notifier.h" | 9 #include "net/base/network_change_notifier.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void ForceConnectivityState(bool state) { | 52 void ForceConnectivityState(bool state) { |
| 53 notifier_->ForceConnectivityState(state); | 53 notifier_->ForceConnectivityState(state); |
| 54 } | 54 } |
| 55 | 55 |
| 56 const TestConnectionTypeObserver* observer() const { | 56 const TestConnectionTypeObserver* observer() const { |
| 57 return connection_type_observer_.get(); | 57 return connection_type_observer_.get(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 virtual void SetUp() { | 61 virtual void SetUp() { |
| 62 notifier_.reset(new NetworkChangeNotifierAndroid()); | 62 notifier_.reset( |
| 63 new NetworkChangeNotifierAndroid( |
| 64 MessageLoop::current()->message_loop_proxy())); |
| 63 connection_type_observer_.reset(new TestConnectionTypeObserver()); | 65 connection_type_observer_.reset(new TestConnectionTypeObserver()); |
| 64 NetworkChangeNotifier::AddConnectionTypeObserver( | 66 NetworkChangeNotifier::AddConnectionTypeObserver( |
| 65 connection_type_observer_.get()); | 67 connection_type_observer_.get()); |
| 66 } | 68 } |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 NetworkChangeNotifier::DisableForTest disable_for_test_; | 71 NetworkChangeNotifier::DisableForTest disable_for_test_; |
| 70 scoped_ptr<NetworkChangeNotifierAndroid> notifier_; | 72 scoped_ptr<NetworkChangeNotifierAndroid> notifier_; |
| 71 scoped_ptr<TestConnectionTypeObserver> connection_type_observer_; | 73 scoped_ptr<TestConnectionTypeObserver> connection_type_observer_; |
| 72 }; | 74 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 95 | 97 |
| 96 ForceConnectivityState(true); | 98 ForceConnectivityState(true); |
| 97 MessageLoop::current()->RunAllPending(); | 99 MessageLoop::current()->RunAllPending(); |
| 98 | 100 |
| 99 EXPECT_EQ(2, observer()->times_connection_type_has_been_changed()); | 101 EXPECT_EQ(2, observer()->times_connection_type_has_been_changed()); |
| 100 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, | 102 EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN, |
| 101 observer()->current_connection()); | 103 observer()->current_connection()); |
| 102 } | 104 } |
| 103 | 105 |
| 104 } // namespace net | 106 } // namespace net |
| OLD | NEW |