| 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 caa9ec86ec24d45303f920095163d1e8f4109916..197c5cf600eb9be920f602218d4f8971cb4f4f22 100644
|
| --- a/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
|
| +++ b/net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java
|
| @@ -86,19 +86,19 @@ public class NetworkChangeNotifierTest {
|
| */
|
| private static class TestNetworkChangeNotifier extends NetworkChangeNotifier {
|
| @Override
|
| - void notifyObserversOfMaxBandwidthChange(double maxBandwidthMbps) {
|
| - mReceivedMaxBandwidthNotification = true;
|
| + void notifyObserversOfConnectionSubtypeChange(int newConnectionSubtype) {
|
| + mReceivedConnectionSubtypeNotification = true;
|
| }
|
|
|
| - public boolean hasReceivedMaxBandwidthNotification() {
|
| - return mReceivedMaxBandwidthNotification;
|
| + public boolean hasReceivedConnectionSubtypeNotification() {
|
| + return mReceivedConnectionSubtypeNotification;
|
| }
|
|
|
| - public void resetHasReceivedMaxBandwidthNotification() {
|
| - mReceivedMaxBandwidthNotification = false;
|
| + public void resetHasReceivedConnectionSubtypeNotification() {
|
| + mReceivedConnectionSubtypeNotification = false;
|
| }
|
|
|
| - private boolean mReceivedMaxBandwidthNotification = false;
|
| + private boolean mReceivedConnectionSubtypeNotification = false;
|
| }
|
|
|
| private static class Helper {
|
| @@ -347,7 +347,7 @@ public class NetworkChangeNotifierTest {
|
| @Override
|
| public void onConnectionTypeChanged(int newConnectionType) {}
|
| @Override
|
| - public void onMaxBandwidthChanged(double maxBandwidthMbps) {}
|
| + public void onConnectionSubtypeChanged(int newConnectionSubtype) {}
|
|
|
| @Override
|
| public void onNetworkConnect(long netId, int connectionType) {
|
| @@ -444,16 +444,12 @@ public class NetworkChangeNotifierTest {
|
| mWifiDelegate.setWifiSSID("foo");
|
| }
|
|
|
| - private double getCurrentMaxBandwidthInMbps() {
|
| - final NetworkChangeNotifierAutoDetect.NetworkState networkState =
|
| - mReceiver.getCurrentNetworkState();
|
| - return mReceiver.getCurrentMaxBandwidthInMbps(networkState);
|
| + private int getCurrentConnectionSubtype() {
|
| + return mReceiver.getCurrentNetworkState().getConnectionSubtype();
|
| }
|
|
|
| private int getCurrentConnectionType() {
|
| - final NetworkChangeNotifierAutoDetect.NetworkState networkState =
|
| - mReceiver.getCurrentNetworkState();
|
| - return NetworkChangeNotifierAutoDetect.convertToConnectionType(networkState);
|
| + return mReceiver.getCurrentNetworkState().getConnectionType();
|
| }
|
|
|
| @Before
|
| @@ -523,64 +519,64 @@ public class NetworkChangeNotifierTest {
|
| }
|
|
|
| /**
|
| - * Tests that changing the network type changes the maxBandwidth.
|
| + * Tests that changing the network type changes the connection subtype.
|
| */
|
| @Test
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthEthernet() {
|
| + public void testNetworkChangeNotifierConnectionSubtypeEthernet() {
|
| // Show that for Ethernet the link speed is unknown (+Infinity).
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_ETHERNET);
|
| Assert.assertEquals(ConnectionType.CONNECTION_ETHERNET, getCurrentConnectionType());
|
| - Assert.assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps(), 0);
|
| + Assert.assertEquals(ConnectionSubtype.SUBTYPE_UNKNOWN, getCurrentConnectionSubtype());
|
| }
|
|
|
| @Test
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthWifi() {
|
| + public void testNetworkChangeNotifierConnectionSubtypeWifi() {
|
| // Show that for WiFi the link speed is unknown (+Infinity).
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIFI);
|
| Assert.assertEquals(ConnectionType.CONNECTION_WIFI, getCurrentConnectionType());
|
| - Assert.assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps(), 0);
|
| + Assert.assertEquals(ConnectionSubtype.SUBTYPE_UNKNOWN, getCurrentConnectionSubtype());
|
| }
|
|
|
| @Test
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthWiMax() {
|
| + public void testNetworkChangeNotifierConnectionSubtypeWiMax() {
|
| // Show that for WiMax the link speed is unknown (+Infinity), although the type is 4g.
|
| // TODO(jkarlin): Add support for CONNECTION_WIMAX as specified in
|
| // http://w3c.github.io/netinfo/.
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_WIMAX);
|
| Assert.assertEquals(ConnectionType.CONNECTION_4G, getCurrentConnectionType());
|
| - Assert.assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps(), 0);
|
| + Assert.assertEquals(ConnectionSubtype.SUBTYPE_UNKNOWN, getCurrentConnectionSubtype());
|
| }
|
|
|
| @Test
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthBluetooth() {
|
| + public void testNetworkChangeNotifierConnectionSubtypeBluetooth() {
|
| // Show that for bluetooth the link speed is unknown (+Infinity).
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_BLUETOOTH);
|
| Assert.assertEquals(ConnectionType.CONNECTION_BLUETOOTH, getCurrentConnectionType());
|
| - Assert.assertEquals(Double.POSITIVE_INFINITY, getCurrentMaxBandwidthInMbps(), 0);
|
| + Assert.assertEquals(ConnectionSubtype.SUBTYPE_UNKNOWN, getCurrentConnectionSubtype());
|
| }
|
|
|
| @Test
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthMobile() {
|
| - // Test that for mobile types the subtype is used to determine the maxBandwidth.
|
| + public void testNetworkChangeNotifierConnectionSubtypeMobile() {
|
| + // Test that for mobile types the subtype is used to determine the connection subtype.
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_MOBILE);
|
| mConnectivityDelegate.setNetworkSubtype(TelephonyManager.NETWORK_TYPE_LTE);
|
| Assert.assertEquals(ConnectionType.CONNECTION_4G, getCurrentConnectionType());
|
| - Assert.assertEquals(100.0, getCurrentMaxBandwidthInMbps(), 0);
|
| + Assert.assertEquals(ConnectionSubtype.SUBTYPE_LTE, getCurrentConnectionSubtype());
|
| }
|
|
|
| /**
|
| @@ -657,7 +653,7 @@ public class NetworkChangeNotifierTest {
|
| @UiThreadTest
|
| @MediumTest
|
| @Feature({"Android-AppBase"})
|
| - public void testNetworkChangeNotifierMaxBandwidthNotifications() {
|
| + public void testNetworkChangeNotifierConnectionSubtypeNotifications() {
|
| mReceiver.register();
|
| // Initialize the NetworkChangeNotifier with a connection.
|
| mConnectivityDelegate.setActiveNetworkExists(true);
|
| @@ -665,22 +661,22 @@ public class NetworkChangeNotifierTest {
|
| Intent connectivityIntent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
|
| mReceiver.onReceive(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
| connectivityIntent);
|
| - Assert.assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
|
| - mNotifier.resetHasReceivedMaxBandwidthNotification();
|
| + Assert.assertTrue(mNotifier.hasReceivedConnectionSubtypeNotification());
|
| + mNotifier.resetHasReceivedConnectionSubtypeNotification();
|
|
|
| // We shouldn't be re-notified if the connection hasn't actually changed.
|
| NetworkChangeNotifierTestObserver observer = new NetworkChangeNotifierTestObserver();
|
| NetworkChangeNotifier.addConnectionTypeObserver(observer);
|
| mReceiver.onReceive(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
| connectivityIntent);
|
| - Assert.assertFalse(mNotifier.hasReceivedMaxBandwidthNotification());
|
| + Assert.assertFalse(mNotifier.hasReceivedConnectionSubtypeNotification());
|
|
|
| // We should be notified if bandwidth and connection type changed.
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_ETHERNET);
|
| mReceiver.onReceive(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
| connectivityIntent);
|
| - Assert.assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
|
| - mNotifier.resetHasReceivedMaxBandwidthNotification();
|
| + Assert.assertTrue(mNotifier.hasReceivedConnectionSubtypeNotification());
|
| + mNotifier.resetHasReceivedConnectionSubtypeNotification();
|
|
|
| // We should be notified if the connection type changed, but not the bandwidth.
|
| // Note that TYPE_ETHERNET and TYPE_BLUETOOTH have the same +INFINITY max bandwidth.
|
| @@ -688,7 +684,7 @@ public class NetworkChangeNotifierTest {
|
| mConnectivityDelegate.setNetworkType(ConnectivityManager.TYPE_BLUETOOTH);
|
| mReceiver.onReceive(InstrumentationRegistry.getInstrumentation().getTargetContext(),
|
| connectivityIntent);
|
| - Assert.assertTrue(mNotifier.hasReceivedMaxBandwidthNotification());
|
| + Assert.assertTrue(mNotifier.hasReceivedConnectionSubtypeNotification());
|
| }
|
|
|
| /**
|
|
|