| 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 0818d5a73267a8028f1ef3eb7b4eef521cb64809..54e5583192fa9034b49731f2eeffc0d8f4f4d2e9 100644
|
| --- a/net/android/network_change_notifier_android_unittest.cc
|
| +++ b/net/android/network_change_notifier_android_unittest.cc
|
| @@ -21,19 +21,26 @@ namespace {
|
| class NetworkChangeNotifierDelegateAndroidObserver
|
| : public NetworkChangeNotifierDelegateAndroid::Observer {
|
| public:
|
| - NetworkChangeNotifierDelegateAndroidObserver() : notifications_count_(0) {}
|
| + NetworkChangeNotifierDelegateAndroidObserver()
|
| + : type_notifications_count_(0), max_bandwidth_notifications_count_(0) {}
|
|
|
| // NetworkChangeNotifierDelegateAndroid::Observer:
|
| virtual void OnConnectionTypeChanged() override {
|
| - notifications_count_++;
|
| + type_notifications_count_++;
|
| }
|
|
|
| - int notifications_count() const {
|
| - return notifications_count_;
|
| + virtual void OnMaxBandwidthChanged(double max_bandwidth_mbps) override {
|
| + max_bandwidth_notifications_count_++;
|
| + }
|
| +
|
| + int type_notifications_count() const { return type_notifications_count_; }
|
| + int bandwidth_notifications_count() const {
|
| + return max_bandwidth_notifications_count_;
|
| }
|
|
|
| private:
|
| - int notifications_count_;
|
| + int type_notifications_count_;
|
| + int max_bandwidth_notifications_count_;
|
| };
|
|
|
| class NetworkChangeNotifierObserver
|
| @@ -155,17 +162,16 @@ class NetworkChangeNotifierDelegateAndroidTest
|
| // delegate's observers are instances of NetworkChangeNotifierAndroid.
|
| TEST_F(NetworkChangeNotifierDelegateAndroidTest, DelegateObserverNotified) {
|
| // Test the logic with a single observer.
|
| - RunTest(
|
| - base::Bind(
|
| - &NetworkChangeNotifierDelegateAndroidObserver::notifications_count,
|
| - base::Unretained(&delegate_observer_)),
|
| - base::Bind(
|
| - &NetworkChangeNotifierDelegateAndroid::GetCurrentConnectionType,
|
| - base::Unretained(&delegate_)));
|
| + RunTest(base::Bind(&NetworkChangeNotifierDelegateAndroidObserver::
|
| + type_notifications_count,
|
| + base::Unretained(&delegate_observer_)),
|
| + base::Bind(
|
| + &NetworkChangeNotifierDelegateAndroid::GetCurrentConnectionType,
|
| + base::Unretained(&delegate_)));
|
| // Check that *all* the observers are notified. Both observers should have the
|
| // same state.
|
| - EXPECT_EQ(delegate_observer_.notifications_count(),
|
| - other_delegate_observer_.notifications_count());
|
| + EXPECT_EQ(delegate_observer_.type_notifications_count(),
|
| + other_delegate_observer_.type_notifications_count());
|
| }
|
|
|
| class NetworkChangeNotifierAndroidTest
|
| @@ -219,11 +225,21 @@ TEST_F(NetworkChangeNotifierAndroidTest, MaxBandwidth) {
|
| notifier_.GetConnectionType());
|
| EXPECT_EQ(std::numeric_limits<double>::infinity(),
|
| notifier_.GetMaxBandwidth());
|
| -
|
| SetOffline();
|
| EXPECT_EQ(NetworkChangeNotifier::CONNECTION_NONE,
|
| notifier_.GetConnectionType());
|
| EXPECT_EQ(0.0, notifier_.GetMaxBandwidth());
|
| }
|
|
|
| +TEST_F(NetworkChangeNotifierDelegateAndroidTest,
|
| + MaxBandwidthNotifiedOnConnectionChange) {
|
| + EXPECT_EQ(0, delegate_observer_.bandwidth_notifications_count());
|
| + SetOffline();
|
| + EXPECT_EQ(1, delegate_observer_.bandwidth_notifications_count());
|
| + SetOnline();
|
| + EXPECT_EQ(2, delegate_observer_.bandwidth_notifications_count());
|
| + SetOnline();
|
| + EXPECT_EQ(2, delegate_observer_.bandwidth_notifications_count());
|
| +}
|
| +
|
| } // namespace net
|
|
|