Merge "Fix forget button on wifi details page."

This commit is contained in:
TreeHugger Robot
2017-03-28 00:31:05 +00:00
committed by Android (Google) Code Review
3 changed files with 45 additions and 16 deletions

View File

@@ -84,8 +84,6 @@ public class WifiDetailPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mLifecycle = new Lifecycle();
mController = new WifiDetailPreferenceController(
mockAccessPoint, mContext, mLifecycle, mockWifiManager);
when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
@@ -93,11 +91,13 @@ public class WifiDetailPreferenceControllerTest {
when(mockAccessPoint.getRssi()).thenReturn(RSSI);
when(mockAccessPoint.getSecurityString(false)).thenReturn(SECURITY);
mController = new WifiDetailPreferenceController(
mockAccessPoint, mContext, mLifecycle, mockWifiManager);
setupMockedPreferenceScreen();
when (mockWifiInfo.getRssi()).thenReturn(RSSI);
when(mockWifiInfo.getRssi()).thenReturn(RSSI);
when(mockWifiManager.getConnectionInfo()).thenReturn(mockWifiInfo);
when(mockWifiManager.getWifiApConfiguration()).thenReturn(mockWifiConfig);
}
private void setupMockedPreferenceScreen() {
@@ -139,7 +139,6 @@ public class WifiDetailPreferenceControllerTest {
mController.onResume();
verify(mockWifiManager).getConnectionInfo();
verify(mockWifiManager).getWifiApConfiguration();
}
@Test
@@ -178,4 +177,29 @@ public class WifiDetailPreferenceControllerTest {
verify(mockSignalStrengthPref).setDetailText(expectedStrength);
}
@Test
public void forgetNetwork_ephemeral() {
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = "ssid";
// WifiConfiguration#isEphemeral will not be visible in robolectric until O is supported
wifiConfiguration.ephemeral = true;
when(mockAccessPoint.getConfig()).thenReturn(wifiConfiguration);
mController = new WifiDetailPreferenceController(
mockAccessPoint, mContext, mLifecycle, mockWifiManager);
mController.forgetNetwork();
verify(mockWifiManager).disableEphemeralNetwork(wifiConfiguration.SSID);
}
@Test
public void forgetNetwork_saved() {
mockWifiConfig.networkId = 5;
mController.forgetNetwork();
verify(mockWifiManager).forget(mockWifiConfig.networkId, null);
}
}