Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java

Issue 780293003: [NetInfo] Add MaxBandwidthChanged notification and implement on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maxbandwidth_android
Patch Set: Don't monitor RSSI if there is no permission to act on it Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
diff --git a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
index f4eafd9b4d40bcc6653e0a17f79bf1ae1be6e887..b9a6e057b09d1cae710e252305a0da98330c9694 100644
--- a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
+++ b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
@@ -7,6 +7,7 @@ package org.chromium.net;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
+import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
import android.test.UiThreadTest;
@@ -126,6 +127,36 @@ public class NetworkChangeNotifierTest extends InstrumentationTestCase {
}
/**
+ * Tests that changing the RSSI_CHANGED_ACTION intent updates MaxBandwidth.
+ */
+ @UiThreadTest
+ @MediumTest
+ @Feature({"Android-AppBase"})
+ public void testNetworkChangeNotifierRSSIEventUpdatesMaxBandwidthForWiFi()
+ throws InterruptedException {
+ NetworkChangeNotifier notifier = NetworkChangeNotifier.getInstance();
+ mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIFI);
+ mWifiDelegate.setLinkSpeedInMbps(42);
+ Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
+ mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
+ assertEquals(42.0, notifier.getCurrentMaxBandwidth());
+
+ // Changing the link speed has no effect until the intent fires.
+ mWifiDelegate.setLinkSpeedInMbps(80);
+ assertEquals(42.0, notifier.getCurrentMaxBandwidth());
+
+ // Fire the intent.
+ mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
+ assertEquals(80.0, notifier.getCurrentMaxBandwidth());
+
+ // Firing a network type change intent also causes max bandwidth to update.
+ mWifiDelegate.setLinkSpeedInMbps(20);
+ intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
+ mReceiver.onReceive(getInstrumentation().getTargetContext(), intent);
+ assertEquals(20.0, notifier.getCurrentMaxBandwidth());
+ }
+
+ /**
* Tests that changing the network type changes the maxBandwidth.
*/
@UiThreadTest

Powered by Google App Engine
This is Rietveld 408576698