Refresh Wifi AP Config display when config changes

Change-Id: I6fe284355223cbcedd82f95d6415c4d6b660f39f
Fixes: 64757839
Test: robotests
Test: rerun ACTS WifiTetheringTest:test_change_wifi_hotspot_ssid_when_hotspot_enabled
This commit is contained in:
Fan Zhang
2017-09-01 11:10:37 -07:00
parent fe18f8e876
commit 5a8b70d3da
8 changed files with 102 additions and 30 deletions

View File

@@ -121,4 +121,20 @@ public class WifiTetherApBandPreferenceControllerTest {
verify(mListener, times(2)).onTetherConfigUpdated();
}
@Test
public void updateDisplay_shouldUpdateValue() {
// Set controller band index to 1 and verify is set.
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
mController.displayPreference(mScreen);
mController.onPreferenceChange(mListPreference, "1");
assertThat(mController.getBandIndex()).isEqualTo(1);
// Disable 5Ghz band
when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
// Call updateDisplay and verify it's changed.
mController.updateDisplay();
assertThat(mController.getBandIndex()).isEqualTo(0);
}
}

View File

@@ -99,4 +99,22 @@ public class WifiTetherPasswordPreferenceControllerTest {
verify(mListener, times(2)).onTetherConfigUpdated();
}
@Test
public void updateDisplay_shouldUpdateValue() {
// Set controller password to anything and verify is set.
mController.displayPreference(mScreen);
mController.onPreferenceChange(mPreference, "1");
assertThat(mController.getPassword()).isEqualTo("1");
// Create a new config using different password
final WifiConfiguration config = new WifiConfiguration();
config.preSharedKey = "test_1234";
when(mWifiManager.getWifiApConfiguration()).thenReturn(config);
// Call updateDisplay and verify it's changed.
mController.updateDisplay();
assertThat(mController.getPassword()).isEqualTo(config.preSharedKey);
assertThat(mPreference.getSummary()).isEqualTo(config.preSharedKey);
}
}

View File

@@ -16,6 +16,12 @@
package com.android.settings.wifi.tether;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.wifi.WifiConfiguration;
@@ -35,12 +41,6 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class WifiTetherSSIDPreferenceControllerTest {
@@ -104,4 +104,22 @@ public class WifiTetherSSIDPreferenceControllerTest {
verify(mListener, times(2)).onTetherConfigUpdated();
}
@Test
public void updateDisplay_shouldUpdateValue() {
// Set controller ssid to anything and verify is set.
mController.displayPreference(mScreen);
mController.onPreferenceChange(mPreference, "1");
assertThat(mController.getSSID()).isEqualTo("1");
// Create a new config using different SSID
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "test_1234";
when(mWifiManager.getWifiApConfiguration()).thenReturn(config);
// Call updateDisplay and verify it's changed.
mController.updateDisplay();
assertThat(mController.getSSID()).isEqualTo(config.SSID);
assertThat(mPreference.getSummary()).isEqualTo(config.SSID);
}
}