Merge "[SB Refactor] Fix WifiViewModelIconParameterizedTest." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3f457fa75e
@@ -21,7 +21,9 @@ import androidx.annotation.VisibleForTesting
|
|||||||
/** Provides information about the current wifi network. */
|
/** Provides information about the current wifi network. */
|
||||||
sealed class WifiNetworkModel {
|
sealed class WifiNetworkModel {
|
||||||
/** A model representing that we have no active wifi network. */
|
/** A model representing that we have no active wifi network. */
|
||||||
object Inactive : WifiNetworkModel()
|
object Inactive : WifiNetworkModel() {
|
||||||
|
override fun toString() = "WifiNetwork.Inactive"
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A model representing that our wifi network is actually a carrier merged network, meaning it's
|
* A model representing that our wifi network is actually a carrier merged network, meaning it's
|
||||||
@@ -29,7 +31,9 @@ sealed class WifiNetworkModel {
|
|||||||
*
|
*
|
||||||
* See [android.net.wifi.WifiInfo.isCarrierMerged] for more information.
|
* See [android.net.wifi.WifiInfo.isCarrierMerged] for more information.
|
||||||
*/
|
*/
|
||||||
object CarrierMerged : WifiNetworkModel()
|
object CarrierMerged : WifiNetworkModel() {
|
||||||
|
override fun toString() = "WifiNetwork.CarrierMerged"
|
||||||
|
}
|
||||||
|
|
||||||
/** Provides information about an active wifi network. */
|
/** Provides information about an active wifi network. */
|
||||||
data class Active(
|
data class Active(
|
||||||
@@ -72,6 +76,24 @@ sealed class WifiNetworkModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
// Only include the passpoint-related values in the string if we have them. (Most
|
||||||
|
// networks won't have them so they'll be mostly clutter.)
|
||||||
|
val passpointString =
|
||||||
|
if (isPasspointAccessPoint ||
|
||||||
|
isOnlineSignUpForPasspointAccessPoint ||
|
||||||
|
passpointProviderFriendlyName != null) {
|
||||||
|
", isPasspointAp=$isPasspointAccessPoint, " +
|
||||||
|
"isOnlineSignUpForPasspointAp=$isOnlineSignUpForPasspointAccessPoint, " +
|
||||||
|
"passpointName=$passpointProviderFriendlyName"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
|
return "WifiNetworkModel.Active(networkId=$networkId, isValidated=$isValidated, " +
|
||||||
|
"level=$level, ssid=$ssid$passpointString)"
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal const val MIN_VALID_LEVEL = 0
|
internal const val MIN_VALID_LEVEL = 0
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import com.android.settingslib.AccessibilityContentDescriptions.WIFI_CONNECTION_
|
|||||||
import com.android.settingslib.AccessibilityContentDescriptions.WIFI_NO_CONNECTION
|
import com.android.settingslib.AccessibilityContentDescriptions.WIFI_NO_CONNECTION
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.common.shared.model.ContentDescription
|
import com.android.systemui.common.shared.model.ContentDescription
|
||||||
import com.android.systemui.statusbar.connectivity.WifiIcons
|
|
||||||
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_FULL_ICONS
|
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_FULL_ICONS
|
||||||
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_NO_INTERNET_ICONS
|
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_NO_INTERNET_ICONS
|
||||||
|
import com.android.systemui.statusbar.connectivity.WifiIcons.WIFI_NO_NETWORK
|
||||||
import com.android.systemui.statusbar.pipeline.StatusBarPipelineFlags
|
import com.android.systemui.statusbar.pipeline.StatusBarPipelineFlags
|
||||||
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
|
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
|
||||||
import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger
|
import com.android.systemui.statusbar.pipeline.shared.ConnectivityPipelineLogger
|
||||||
@@ -144,7 +144,12 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
|
|
||||||
/** A function that, given a context, calculates the correct content description string. */
|
/** A function that, given a context, calculates the correct content description string. */
|
||||||
val contentDescription: (Context) -> String,
|
val contentDescription: (Context) -> String,
|
||||||
)
|
|
||||||
|
/** A human-readable description used for the test names. */
|
||||||
|
val description: String,
|
||||||
|
) {
|
||||||
|
override fun toString() = description
|
||||||
|
}
|
||||||
|
|
||||||
// Note: We use default values for the boolean parameters to reflect a "typical configuration"
|
// Note: We use default values for the boolean parameters to reflect a "typical configuration"
|
||||||
// for wifi. This allows each TestCase to only define the parameter values that are critical
|
// for wifi. This allows each TestCase to only define the parameter values that are critical
|
||||||
@@ -158,12 +163,21 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
|
|
||||||
/** The expected output. Null if we expect the output to be null. */
|
/** The expected output. Null if we expect the output to be null. */
|
||||||
val expected: Expected?
|
val expected: Expected?
|
||||||
)
|
) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "when INPUT(enabled=$enabled, " +
|
||||||
|
"forceHidden=$forceHidden, " +
|
||||||
|
"showWhenEnabled=$alwaysShowIconWhenEnabled, " +
|
||||||
|
"hasDataCaps=$hasDataCapabilities, " +
|
||||||
|
"network=$network) then " +
|
||||||
|
"EXPECTED($expected)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@Parameters(name = "{0}")
|
@Parameters(name = "{0}") @JvmStatic fun data(): Collection<TestCase> = testData
|
||||||
@JvmStatic
|
|
||||||
fun data(): Collection<TestCase> =
|
private val testData: List<TestCase> =
|
||||||
listOf(
|
listOf(
|
||||||
// Enabled = false => no networks shown
|
// Enabled = false => no networks shown
|
||||||
TestCase(
|
TestCase(
|
||||||
@@ -215,11 +229,12 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
network = WifiNetworkModel.Inactive,
|
network = WifiNetworkModel.Inactive,
|
||||||
expected =
|
expected =
|
||||||
Expected(
|
Expected(
|
||||||
iconResource = WifiIcons.WIFI_NO_NETWORK,
|
iconResource = WIFI_NO_NETWORK,
|
||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
"${context.getString(WIFI_NO_CONNECTION)}," +
|
"${context.getString(WIFI_NO_CONNECTION)}," +
|
||||||
context.getString(NO_INTERNET)
|
context.getString(NO_INTERNET)
|
||||||
}
|
},
|
||||||
|
description = "No network icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TestCase(
|
TestCase(
|
||||||
@@ -231,7 +246,8 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
"${context.getString(WIFI_CONNECTION_STRENGTH[4])}," +
|
"${context.getString(WIFI_CONNECTION_STRENGTH[4])}," +
|
||||||
context.getString(NO_INTERNET)
|
context.getString(NO_INTERNET)
|
||||||
}
|
},
|
||||||
|
description = "No internet level 4 icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TestCase(
|
TestCase(
|
||||||
@@ -242,7 +258,8 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
iconResource = WIFI_FULL_ICONS[2],
|
iconResource = WIFI_FULL_ICONS[2],
|
||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
context.getString(WIFI_CONNECTION_STRENGTH[2])
|
context.getString(WIFI_CONNECTION_STRENGTH[2])
|
||||||
}
|
},
|
||||||
|
description = "Full internet level 2 icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -252,11 +269,12 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
network = WifiNetworkModel.Inactive,
|
network = WifiNetworkModel.Inactive,
|
||||||
expected =
|
expected =
|
||||||
Expected(
|
Expected(
|
||||||
iconResource = WifiIcons.WIFI_NO_NETWORK,
|
iconResource = WIFI_NO_NETWORK,
|
||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
"${context.getString(WIFI_NO_CONNECTION)}," +
|
"${context.getString(WIFI_NO_CONNECTION)}," +
|
||||||
context.getString(NO_INTERNET)
|
context.getString(NO_INTERNET)
|
||||||
}
|
},
|
||||||
|
description = "No network icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TestCase(
|
TestCase(
|
||||||
@@ -268,7 +286,8 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
"${context.getString(WIFI_CONNECTION_STRENGTH[2])}," +
|
"${context.getString(WIFI_CONNECTION_STRENGTH[2])}," +
|
||||||
context.getString(NO_INTERNET)
|
context.getString(NO_INTERNET)
|
||||||
}
|
},
|
||||||
|
description = "No internet level 2 icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TestCase(
|
TestCase(
|
||||||
@@ -279,7 +298,8 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
iconResource = WIFI_FULL_ICONS[0],
|
iconResource = WIFI_FULL_ICONS[0],
|
||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
context.getString(WIFI_CONNECTION_STRENGTH[0])
|
context.getString(WIFI_CONNECTION_STRENGTH[0])
|
||||||
}
|
},
|
||||||
|
description = "Full internet level 0 icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -309,7 +329,8 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
|
|||||||
iconResource = WIFI_FULL_ICONS[4],
|
iconResource = WIFI_FULL_ICONS[4],
|
||||||
contentDescription = { context ->
|
contentDescription = { context ->
|
||||||
context.getString(WIFI_CONNECTION_STRENGTH[4])
|
context.getString(WIFI_CONNECTION_STRENGTH[4])
|
||||||
}
|
},
|
||||||
|
description = "Full internet level 4 icon",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user