Merge "[SB Refactor] Update wifi network to inactive if carrier merged is lost." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a0ae7d2d27
@@ -160,8 +160,10 @@ constructor(
|
||||
|
||||
val wifi = currentWifi
|
||||
if (
|
||||
wifi is WifiNetworkModel.Active &&
|
||||
wifi.networkId == network.getNetId()
|
||||
(wifi is WifiNetworkModel.Active &&
|
||||
wifi.networkId == network.getNetId()) ||
|
||||
(wifi is WifiNetworkModel.CarrierMerged &&
|
||||
wifi.networkId == network.getNetId())
|
||||
) {
|
||||
val newNetworkModel = WifiNetworkModel.Inactive
|
||||
currentWifi = newNetworkModel
|
||||
|
||||
@@ -994,7 +994,7 @@ class WifiRepositoryImplTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wifiNetwork_currentNetworkLost_flowHasNoNetwork() =
|
||||
fun wifiNetwork_currentActiveNetworkLost_flowHasNoNetwork() =
|
||||
testScope.runTest {
|
||||
var latest: WifiNetworkModel? = null
|
||||
val job = underTest.wifiNetwork.onEach { latest = it }.launchIn(this)
|
||||
@@ -1012,6 +1012,33 @@ class WifiRepositoryImplTest : SysuiTestCase() {
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
/** Possible regression test for b/278618530. */
|
||||
@Test
|
||||
fun wifiNetwork_currentCarrierMergedNetworkLost_flowHasNoNetwork() =
|
||||
testScope.runTest {
|
||||
var latest: WifiNetworkModel? = null
|
||||
val job = underTest.wifiNetwork.onEach { latest = it }.launchIn(this)
|
||||
|
||||
val wifiInfo =
|
||||
mock<WifiInfo>().apply {
|
||||
whenever(this.isPrimary).thenReturn(true)
|
||||
whenever(this.isCarrierMerged).thenReturn(true)
|
||||
}
|
||||
|
||||
getNetworkCallback()
|
||||
.onCapabilitiesChanged(NETWORK, createWifiNetworkCapabilities(wifiInfo))
|
||||
assertThat(latest is WifiNetworkModel.CarrierMerged).isTrue()
|
||||
assertThat((latest as WifiNetworkModel.CarrierMerged).networkId).isEqualTo(NETWORK_ID)
|
||||
|
||||
// WHEN we lose our current network
|
||||
getNetworkCallback().onLost(NETWORK)
|
||||
|
||||
// THEN we update to no network
|
||||
assertThat(latest is WifiNetworkModel.Inactive).isTrue()
|
||||
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wifiNetwork_unknownNetworkLost_flowHasPreviousNetwork() =
|
||||
testScope.runTest {
|
||||
|
||||
Reference in New Issue
Block a user