Add support for unknown Network to expectCallback
This patch allows not passing a network to expectCallback to allow receiving a callback when the network isn't known. This is supported in other expect* methods but somehow was missed in this one. Test: Ikev2VpnRunnerTest, which uses this ability Change-Id: Ifd20dd8789ff8b277bac3a73ddd23e2fe9febbca
This commit is contained in:
@@ -41,6 +41,7 @@ import kotlin.test.fail
|
|||||||
|
|
||||||
object NULL_NETWORK : Network(-1)
|
object NULL_NETWORK : Network(-1)
|
||||||
object ANY_NETWORK : Network(-2)
|
object ANY_NETWORK : Network(-2)
|
||||||
|
fun anyNetwork() = ANY_NETWORK
|
||||||
|
|
||||||
private val Int.capabilityName get() = NetworkCapabilities.capabilityNameOf(this)
|
private val Int.capabilityName get() = NetworkCapabilities.capabilityNameOf(this)
|
||||||
|
|
||||||
@@ -385,7 +386,7 @@ open class TestableNetworkCallback private constructor(
|
|||||||
val network = n ?: NULL_NETWORK
|
val network = n ?: NULL_NETWORK
|
||||||
// TODO : remove this .java access if the tests ever use kotlin-reflect. At the time of
|
// TODO : remove this .java access if the tests ever use kotlin-reflect. At the time of
|
||||||
// this writing this would be the only use of this library in the tests.
|
// this writing this would be the only use of this library in the tests.
|
||||||
assertTrue(type.java.isInstance(it) && it.network == network,
|
assertTrue(type.java.isInstance(it) && (ANY_NETWORK === n || it.network == network),
|
||||||
"Unexpected callback : $it, expected ${type.java} with Network[$network]")
|
"Unexpected callback : $it, expected ${type.java} with Network[$network]")
|
||||||
} as T
|
} as T
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user