Merge "Add support for unknown Network to expectCallback"
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)
|
||||||
|
|
||||||
@@ -389,7 +390,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