Merge "Fallback to "Extended Compatibility" if Speed feature is not ready" into udc-dev am: dc02736824
am: b24b622c3c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22651125 Change-Id: Ia14eb54b4b0826dee20b761be9a22078849bdeed Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -36,6 +36,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -592,6 +593,65 @@ public class WifiHotspotRepositoryTest {
|
||||
assertThat(mWifiHotspotRepository.get6gAvailable()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_configNotShow_returnFalse() {
|
||||
mWifiHotspotRepository.mIsConfigShowSpeed = false;
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_5gBandNotSupported_returnFalse() {
|
||||
mWifiHotspotRepository.mIsConfigShowSpeed = true;
|
||||
mWifiHotspotRepository.mIs5gBandSupported = false;
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_throwExceptionWhenGet5gSapChannel_returnFalse() {
|
||||
mWifiHotspotRepository.mIsConfigShowSpeed = true;
|
||||
mWifiHotspotRepository.mIs5gBandSupported = true;
|
||||
doThrow(IllegalArgumentException.class).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP);
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
|
||||
doThrow(UnsupportedOperationException.class).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP);
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_throwExceptionWhenGet6gSapChannel_returnFalse() {
|
||||
mWifiHotspotRepository.mIsConfigShowSpeed = true;
|
||||
mWifiHotspotRepository.mIs5gBandSupported = true;
|
||||
doReturn(Arrays.asList(new WifiAvailableChannel(FREQ_5GHZ, OP_MODE_SAP))).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP);
|
||||
doThrow(IllegalArgumentException.class).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_6_GHZ, OP_MODE_SAP);
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
|
||||
doThrow(UnsupportedOperationException.class).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_6_GHZ, OP_MODE_SAP);
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_conditionsAreReady_returnTrue() {
|
||||
mWifiHotspotRepository.mIsConfigShowSpeed = true;
|
||||
mWifiHotspotRepository.mIs5gBandSupported = true;
|
||||
doReturn(Arrays.asList(new WifiAvailableChannel(FREQ_5GHZ, OP_MODE_SAP))).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS, OP_MODE_SAP);
|
||||
doReturn(Arrays.asList(new WifiAvailableChannel(FREQ_6GHZ, OP_MODE_SAP))).when(mWifiManager)
|
||||
.getUsableChannels(WifiScanner.WIFI_BAND_6_GHZ, OP_MODE_SAP);
|
||||
|
||||
assertThat(mWifiHotspotRepository.isSpeedFeatureAvailable()).isTrue();
|
||||
}
|
||||
|
||||
private void mockConfigSecurityType(int securityType) {
|
||||
mockConfig(securityType, SPEED_2GHZ);
|
||||
}
|
||||
|
@@ -237,4 +237,11 @@ public class WifiTetherMaximizeCompatibilityPreferenceControllerTest {
|
||||
|
||||
assertThat(builder.build().getBand()).isEqualTo(SoftApConfiguration.BAND_2GHZ);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_shouldHidePreference_returnFalse() {
|
||||
mController.mShouldHidePreference = true;
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
|
@@ -203,4 +203,11 @@ public class WifiTetherSecurityPreferenceControllerTest {
|
||||
.isEqualTo(SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
|
||||
assertThat(mPreference.getSummary().toString()).isEqualTo("WPA2-Personal");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_shouldHidePreference_returnFalse() {
|
||||
mController.mShouldHidePreference = true;
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
|
@@ -72,7 +72,10 @@ public class WifiTetherViewModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCleared_setAutoRefreshFalse() {
|
||||
public void onCleared_removeObservers() {
|
||||
mViewModel.getSecuritySummary();
|
||||
mViewModel.getSpeedSummary();
|
||||
|
||||
mViewModel.onCleared();
|
||||
|
||||
verify(mSecurityType).removeObserver(mViewModel.mSecurityTypeObserver);
|
||||
@@ -116,4 +119,11 @@ public class WifiTetherViewModelTest {
|
||||
assertThat(mViewModel.mSpeedSummary).isNotNull();
|
||||
verify(mSpeedType).observeForever(mViewModel.mSpeedTypeObserver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSpeedFeatureAvailable_verifyRepositoryIsCalled() {
|
||||
mViewModel.isSpeedFeatureAvailable();
|
||||
|
||||
verify(mWifiHotspotRepository).isSpeedFeatureAvailable();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user