summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2023-03-27 17:52:53 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-03-27 17:52:53 +0000
commit52339c917ccd4ed440b044ed02eada57c6f6b154 (patch)
tree98770f125d911e5334d52ca67f21a7107b51fb4f
parent84fd6c78239f4bdeeabb75ac43bbe10daa0d35fb (diff)
parentf686be0b538211416fae578a38ad8e3fd8b36adf (diff)
Merge "Further simplification of collectValues." into udc-dev
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/coroutines/Flow.kt14
1 files changed, 2 insertions, 12 deletions
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 e1ba074ac860..ce8d93e2a0e7 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 <T> TestScope.collectValues(
flow: Flow<T>,
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
-): FlowValues<T> {
+): FlowValue<List<T>> {
val values = mutableListOf<T>()
backgroundScope.launch(context, start) { flow.collect(values::add) }
- return FlowValuesImpl {
+ return FlowValueImpl {
runCurrent()
values.toList()
}
@@ -83,17 +83,7 @@ interface FlowValue<T> : ReadOnlyProperty<Any?, T> {
operator fun invoke(): T
}
-/** @see collectValues */
-interface FlowValues<T> : ReadOnlyProperty<Any?, List<T>> {
- operator fun invoke(): List<T>
-}
-
private class FlowValueImpl<T>(private val block: () -> T) : FlowValue<T> {
override operator fun invoke(): T = block()
override fun getValue(thisRef: Any?, property: KProperty<*>): T = invoke()
}
-
-private class FlowValuesImpl<T>(private val block: () -> List<T>) : FlowValues<T> {
- override operator fun invoke(): List<T> = block()
- override fun getValue(thisRef: Any?, property: KProperty<*>): List<T> = invoke()
-}