diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt index e1ba074ac860d..ce8d93e2a0e78 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt @@ -69,10 +69,10 @@ fun TestScope.collectValues( flow: Flow, context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, -): FlowValues { +): FlowValue> { val values = mutableListOf() backgroundScope.launch(context, start) { flow.collect(values::add) } - return FlowValuesImpl { + return FlowValueImpl { runCurrent() values.toList() } @@ -83,17 +83,7 @@ interface FlowValue : ReadOnlyProperty { operator fun invoke(): T } -/** @see collectValues */ -interface FlowValues : ReadOnlyProperty> { - operator fun invoke(): List -} - private class FlowValueImpl(private val block: () -> T) : FlowValue { override operator fun invoke(): T = block() override fun getValue(thisRef: Any?, property: KProperty<*>): T = invoke() } - -private class FlowValuesImpl(private val block: () -> List) : FlowValues { - override operator fun invoke(): List = block() - override fun getValue(thisRef: Any?, property: KProperty<*>): List = invoke() -}