Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85a253dc authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Let testable callbacks use Network directly" am: e5408b8a am:...

Merge "Let testable callbacks use Network directly" am: e5408b8a am: 238b78fc am: bfbe741d am: 98056b48 am: 14095153

Change-Id: If0616c60bac301c7d983d94474cd4264bf7df214
parents 70ffc80c 14095153
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ open class TestableNetworkCallback private constructor(
    ) {
        expectCallback<Available>(net, tmt)
        if (suspended) {
            expectCallback<CallbackEntry.Suspended>(net, tmt)
            expectCallback<Suspended>(net, tmt)
        }
        expectCapabilitiesThat(net, tmt) { validated == it.hasCapability(NET_CAPABILITY_VALIDATED) }
        expectCallback<LinkPropertiesChanged>(net, tmt)
@@ -278,16 +278,23 @@ open class TestableNetworkCallback private constructor(
    @JvmOverloads
    open fun <T : CallbackEntry> expectCallback(
        type: KClass<T>,
        n: HasNetwork?,
        n: Network?,
        timeoutMs: Long = defaultTimeoutMs
    ) = pollForNextCallback(timeoutMs).also {
        val network = n?.network ?: NULL_NETWORK
        val network = n ?: NULL_NETWORK
        // 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.
        assertTrue(type.java.isInstance(it) && it.network == network,
                "Unexpected callback : $it, expected ${type.java} with Network[$network]")
    } as T

    @JvmOverloads
    open fun <T : CallbackEntry> expectCallback(
        type: KClass<T>,
        n: HasNetwork?,
        timeoutMs: Long = defaultTimeoutMs
    ) = expectCallback(type, n?.network, timeoutMs)

    fun expectAvailableCallbacks(
        n: HasNetwork,
        suspended: Boolean,