Wifi: Fix rototests for wifi tethering
This commit makes fixes to the wifi tethering rototests. These fixes are done by using the proper encoding for the AP bands. Bug: 146767071 Test: Run robotest Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi Change-Id: I4ddf6ea9328dabed09bc23d355efa188975316b6
This commit is contained in:
@@ -105,8 +105,8 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
|
||||
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
|
||||
// 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
|
||||
if (!isDualMode
|
||||
&& ((band & (SoftApConfiguration.BAND_5GHZ
|
||||
| SoftApConfiguration.BAND_2GHZ)) != 0)) {
|
||||
&& ((band & SoftApConfiguration.BAND_5GHZ) != 0)
|
||||
&& ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
|
||||
return SoftApConfiguration.BAND_5GHZ;
|
||||
} else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
|
||||
return SoftApConfiguration.BAND_2GHZ;
|
||||
|
@@ -49,6 +49,13 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
private static final String ALL_BANDS = "5.0 GHz Band preferred";
|
||||
private static final String TWO_GHZ_STRING = "2.4 GHz Band";
|
||||
private static final String FIVE_GHZ_STRING = "5.0 GHz Band";
|
||||
private static final String VAL_2GHZ_STR = "1";
|
||||
private static final String VAL_5GHZ_STR = "2";
|
||||
private static final String VAL_2_5_GHZ_STR = "3";
|
||||
private static final int VAL_2GHZ_INT = 1;
|
||||
private static final int VAL_5GHZ_INT = 2;
|
||||
private static final int VAL_2_5_GHZ_INT = 3;
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@@ -87,8 +94,11 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
when(mWifiManager.isDualModeSupported()).thenReturn(true);
|
||||
|
||||
// Create a new instance to pick the proper value of isDualModeSupported()
|
||||
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onPreferenceChange(mPreference, "-1");
|
||||
mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
|
||||
}
|
||||
@@ -125,22 +135,22 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
// -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option. This should be prevented from
|
||||
// being set since it is invalid for this configuration
|
||||
mController.onPreferenceChange(mPreference, "-1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(1);
|
||||
// 'Auto' option should be prevented from being set since
|
||||
// it is invalid for this configuration
|
||||
mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
|
||||
verify(mListener, times(1)).onTetherConfigUpdated(mController);
|
||||
|
||||
// set to 5 Ghz
|
||||
mController.onPreferenceChange(mPreference, "1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(1);
|
||||
mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
|
||||
verify(mListener, times(2)).onTetherConfigUpdated(mController);
|
||||
|
||||
// set to 2 Ghz
|
||||
mController.onPreferenceChange(mPreference, "0");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(0);
|
||||
mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
|
||||
verify(mListener, times(3)).onTetherConfigUpdated(mController);
|
||||
}
|
||||
@@ -152,23 +162,26 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
when(mWifiManager.isDualModeSupported()).thenReturn(true);
|
||||
|
||||
// Create a new instance to pick the proper value of isDualModeSupported()
|
||||
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
// -1 is SoftApConfiguration.BAND_ANY, for 'Auto' option.
|
||||
mController.onPreferenceChange(mPreference, "-1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(-1);
|
||||
// 'Auto' option
|
||||
mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
|
||||
verify(mListener, times(1)).onTetherConfigUpdated(mController);
|
||||
|
||||
// should revert to the default for 5 Ghz only since this is not supported with this config
|
||||
mController.onPreferenceChange(mPreference, "1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(-1);
|
||||
mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2_5_GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(ALL_BANDS);
|
||||
verify(mListener, times(2)).onTetherConfigUpdated(mController);
|
||||
|
||||
// set to 2 Ghz
|
||||
mController.onPreferenceChange(mPreference, "0");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(0);
|
||||
mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
|
||||
verify(mListener, times(3)).onTetherConfigUpdated(mController);
|
||||
}
|
||||
@@ -179,16 +192,16 @@ public class WifiTetherApBandPreferenceControllerTest {
|
||||
when(mWifiManager.getCountryCode()).thenReturn("US");
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
|
||||
|
||||
// Set controller band index to 1 and verify is set.
|
||||
// Set controller band index to 5GHz and verify is set.
|
||||
mController.displayPreference(mScreen);
|
||||
mController.onPreferenceChange(mPreference, "1");
|
||||
assertThat(mController.getBandIndex()).isEqualTo(1);
|
||||
mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
|
||||
|
||||
// Disable 5Ghz band
|
||||
when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
|
||||
|
||||
// Call updateDisplay and verify it's changed.
|
||||
mController.updateDisplay();
|
||||
assertThat(mController.getBandIndex()).isEqualTo(0);
|
||||
assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user