| Index: net/android/network_change_notifier_android_unittest.cc
|
| diff --git a/net/android/network_change_notifier_android_unittest.cc b/net/android/network_change_notifier_android_unittest.cc
|
| index 7fb8e6b57147207907c899bc7e325e6e8b16338b..8509d260734df4ec7f6f4b8d7a8642cf37d36609 100644
|
| --- a/net/android/network_change_notifier_android_unittest.cc
|
| +++ b/net/android/network_change_notifier_android_unittest.cc
|
| @@ -37,12 +37,12 @@ class NetworkChangeNotifierDelegateAndroidObserver
|
| };
|
|
|
| class NetworkChangeNotifierObserver
|
| - : public NetworkChangeNotifier::ConnectionTypeObserver {
|
| + : public NetworkChangeNotifier::NetworkChangeObserver {
|
| public:
|
| NetworkChangeNotifierObserver() : notifications_count_(0) {}
|
|
|
| - // NetworkChangeNotifier::Observer:
|
| - virtual void OnConnectionTypeChanged(
|
| + // NetworkChangeNotifier::NetworkChangeObserver:
|
| + virtual void OnNetworkChanged(
|
| NetworkChangeNotifier::ConnectionType connection_type) OVERRIDE {
|
| notifications_count_++;
|
| }
|
| @@ -63,9 +63,13 @@ class BaseNetworkChangeNotifierAndroidTest : public testing::Test {
|
|
|
| virtual ~BaseNetworkChangeNotifierAndroidTest() {}
|
|
|
| + // |extra_online_notification| indicates
|
| + // NetworkChangeNotifier::OnNetworkChanged() is being tested, which produces
|
| + // two notifications when transitioning to an online state.
|
| void RunTest(
|
| const base::Callback<int(void)>& notifications_count_getter,
|
| - const base::Callback<ConnectionType(void)>& connection_type_getter) {
|
| + const base::Callback<ConnectionType(void)>& connection_type_getter,
|
| + bool extra_online_notification) {
|
| EXPECT_EQ(0, notifications_count_getter.Run());
|
| EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN,
|
| connection_type_getter.Run());
|
| @@ -85,7 +89,8 @@ class BaseNetworkChangeNotifierAndroidTest : public testing::Test {
|
|
|
| // Going from offline to online should trigger a notification.
|
| SetOnline();
|
| - EXPECT_EQ(2, notifications_count_getter.Run());
|
| + EXPECT_EQ(extra_online_notification ? 3 : 2,
|
| + notifications_count_getter.Run());
|
| EXPECT_EQ(NetworkChangeNotifier::CONNECTION_UNKNOWN,
|
| connection_type_getter.Run());
|
| }
|
| @@ -161,7 +166,8 @@ TEST_F(NetworkChangeNotifierDelegateAndroidTest, DelegateObserverNotified) {
|
| base::Unretained(&delegate_observer_)),
|
| base::Bind(
|
| &NetworkChangeNotifierDelegateAndroid::GetCurrentConnectionType,
|
| - base::Unretained(&delegate_)));
|
| + base::Unretained(&delegate_)),
|
| + false);
|
| // Check that *all* the observers are notified. Both observers should have the
|
| // same state.
|
| EXPECT_EQ(delegate_observer_.notifications_count(),
|
| @@ -172,9 +178,8 @@ class NetworkChangeNotifierAndroidTest
|
| : public BaseNetworkChangeNotifierAndroidTest {
|
| protected:
|
| NetworkChangeNotifierAndroidTest() : notifier_(&delegate_) {
|
| - NetworkChangeNotifier::AddConnectionTypeObserver(
|
| - &connection_type_observer_);
|
| - NetworkChangeNotifier::AddConnectionTypeObserver(
|
| + NetworkChangeNotifier::AddNetworkChangeObserver(&connection_type_observer_);
|
| + NetworkChangeNotifier::AddNetworkChangeObserver(
|
| &other_connection_type_observer_);
|
| }
|
|
|
| @@ -196,7 +201,8 @@ TEST_F(NetworkChangeNotifierAndroidTest,
|
| base::Unretained(&connection_type_observer_)),
|
| base::Bind(
|
| &NetworkChangeNotifierAndroid::GetCurrentConnectionType,
|
| - base::Unretained(¬ifier_)));
|
| + base::Unretained(¬ifier_)),
|
| + true);
|
| }
|
|
|
| // When a NetworkChangeNotifierAndroid's connection state changes, it should
|
| @@ -207,7 +213,8 @@ TEST_F(NetworkChangeNotifierAndroidTest,
|
| base::Bind(
|
| &NetworkChangeNotifierObserver::notifications_count,
|
| base::Unretained(&connection_type_observer_)),
|
| - base::Bind(&NetworkChangeNotifier::GetConnectionType));
|
| + base::Bind(&NetworkChangeNotifier::GetConnectionType),
|
| + true);
|
| // Check that *all* the observers are notified.
|
| EXPECT_EQ(connection_type_observer_.notifications_count(),
|
| other_connection_type_observer_.notifications_count());
|
|
|