diff --git a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt index d9c51e5201..c4e236e1d0 100644 --- a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt +++ b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkCallback.kt @@ -70,7 +70,7 @@ open class RecorderCallback private constructor( data class Reserved private constructor( override val network: Network, val caps: NetworkCapabilities - ): CallbackEntry() { + ) : CallbackEntry() { constructor(caps: NetworkCapabilities) : this(NULL_NETWORK, caps) } data class Available(override val network: Network) : CallbackEntry() @@ -399,12 +399,6 @@ open class TestableNetworkCallback private constructor( } } as T - // "Nothing" is the return type to declare a function never returns a value. - fun failWithErrorReason(errorMsg: String?, errorReason: String): Nothing { - val message = if (errorMsg != null) "$errorMsg : $errorReason" else errorReason - fail(message) - } - inline fun expect( network: HasNetwork, timeoutMs: Long = defaultTimeoutMs, diff --git a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt index 8f9014c816..8228440f54 100644 --- a/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt +++ b/staticlibs/testutils/devicetests/com/android/testutils/TestableNetworkOfferCallback.kt @@ -56,12 +56,6 @@ class TestableNetworkOfferCallback( history.add(CallbackEntry.Unneeded(request)) } - // TODO : move to some utility, this is copied from TestableNetworkCallback - fun failWithErrorReason(errorMsg: String?, errorReason: String): Nothing { - val message = if (errorMsg != null) "$errorMsg : $errorReason" else errorReason - fail(message) - } - inline fun expect( errorMsg: String? = null, predicate: (T) -> Boolean = { true } diff --git a/staticlibs/testutils/hostdevice/com/android/testutils/MiscAsserts.kt b/staticlibs/testutils/hostdevice/com/android/testutils/MiscAsserts.kt index 176546a4c0..de797b0ba4 100644 --- a/staticlibs/testutils/hostdevice/com/android/testutils/MiscAsserts.kt +++ b/staticlibs/testutils/hostdevice/com/android/testutils/MiscAsserts.kt @@ -142,4 +142,12 @@ fun assertEventuallyTrue( } Thread.sleep(pollIntervalMs) } -} \ No newline at end of file +} + +// "Nothing" is the return type to declare a function never returns a value. This is useful +// because the compiler will know the branch of the code calling this does not return, which +// lets check exhaustivity, infer return types, nullability and smart casts. +fun failWithErrorReason(errorMsg: String?, errorReason: String): Nothing { + val message = if (errorMsg != null) "$errorMsg : $errorReason" else errorReason + fail(message) +}