Create a TetherInterfaceStateMachine when told the interface name.
Test: as follows
- built
- flashed
- booted
- runtest frameworks-net passes
Bug: 32163131
Bug: 62343300
Merged-In: I542e013aa19fefd3443588c9a81ee59cd669ab6f
Merged-In: I973bdc5b540cce66a9713cebfd5071ad4a4b0a08
Merged-In: I2104ecf8102c8f9541ee2d3ce6589b0081db4fe3
Change-Id: I2104ecf8102c8f9541ee2d3ce6589b0081db4fe3
(cherry picked from commit b912c50b197cc0fc49bb7897130581dd02d2af01)
diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java
index 281223e..0c45cf1 100644
--- a/tests/net/java/com/android/server/connectivity/TetheringTest.java
+++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java
@@ -235,32 +235,51 @@
mIntents.remove(bcast);
}
- @Test
- public void failingLocalOnlyHotspotLegacyApBroadcast() throws Exception {
+ public void failingLocalOnlyHotspotLegacyApBroadcast(
+ boolean emulateInterfaceStatusChanged) throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
// Emulate externally-visible WifiManager effects, causing the
// per-interface state machine to start up, and telling us that
// hotspot mode is to be started.
- mTethering.interfaceStatusChanged(mTestIfname, true);
+ if (emulateInterfaceStatusChanged) {
+ mTethering.interfaceStatusChanged(mTestIfname, true);
+ }
sendWifiApStateChanged(WIFI_AP_STATE_ENABLED);
mLooper.dispatchAll();
- verify(mConnectivityManager, atLeastOnce()).isTetheringSupported();
- verifyTetheringBroadcast(mTestIfname, ConnectivityManager.EXTRA_AVAILABLE_TETHER);
+ // If, and only if, Tethering received an interface status changed
+ // then it creates a TetherInterfaceStateMachine and sends out a
+ // broadcast indicating that the interface is "available".
+ if (emulateInterfaceStatusChanged) {
+ verify(mConnectivityManager, atLeastOnce()).isTetheringSupported();
+ verifyTetheringBroadcast(mTestIfname, ConnectivityManager.EXTRA_AVAILABLE_TETHER);
+ }
verifyNoMoreInteractions(mConnectivityManager);
verifyNoMoreInteractions(mNMService);
verifyNoMoreInteractions(mWifiManager);
}
@Test
- public void workingLocalOnlyHotspotEnrichedApBroadcast() throws Exception {
+ public void failingLocalOnlyHotspotLegacyApBroadcastWithIfaceStatusChanged() throws Exception {
+ failingLocalOnlyHotspotLegacyApBroadcast(true);
+ }
+
+ @Test
+ public void failingLocalOnlyHotspotLegacyApBroadcastSansIfaceStatusChanged() throws Exception {
+ failingLocalOnlyHotspotLegacyApBroadcast(false);
+ }
+
+ public void workingLocalOnlyHotspotEnrichedApBroadcast(
+ boolean emulateInterfaceStatusChanged) throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
// Emulate externally-visible WifiManager effects, causing the
// per-interface state machine to start up, and telling us that
// hotspot mode is to be started.
- mTethering.interfaceStatusChanged(mTestIfname, true);
+ if (emulateInterfaceStatusChanged) {
+ mTethering.interfaceStatusChanged(mTestIfname, true);
+ }
sendWifiApStateChanged(WIFI_AP_STATE_ENABLED, mTestIfname, IFACE_IP_MODE_LOCAL_ONLY);
mLooper.dispatchAll();
@@ -305,6 +324,17 @@
}
@Test
+ public void workingLocalOnlyHotspotEnrichedApBroadcastWithIfaceChanged() throws Exception {
+ workingLocalOnlyHotspotEnrichedApBroadcast(true);
+ }
+
+ @Test
+ public void workingLocalOnlyHotspotEnrichedApBroadcastSansIfaceChanged() throws Exception {
+ workingLocalOnlyHotspotEnrichedApBroadcast(false);
+ }
+
+ // TODO: Test with and without interfaceStatusChanged().
+ @Test
public void failingWifiTetheringLegacyApBroadcast() throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
@@ -331,6 +361,7 @@
verifyNoMoreInteractions(mWifiManager);
}
+ // TODO: Test with and without interfaceStatusChanged().
@Test
public void workingWifiTetheringEnrichedApBroadcast() throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
@@ -412,6 +443,7 @@
mTethering.getLastTetherError(mTestIfname));
}
+ // TODO: Test with and without interfaceStatusChanged().
@Test
public void failureEnablingIpForwarding() throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);