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

Commit e044a2a4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add SysuiTestCase.runOnMainThreadAndWaitForIdleSync()" into main

parents e428cb61 db6ed76f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -20,3 +20,11 @@ import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testCase

fun SysuiTestCase.testKosmos(): Kosmos = Kosmos().apply { testCase = this@testKosmos }

/** Run [f] on the main thread and return its result once completed. */
fun <T : Any> SysuiTestCase.runOnMainThreadAndWaitForIdleSync(f: () -> T): T {
    lateinit var result: T
    context.mainExecutor.execute { result = f() }
    waitForIdleSync()
    return result
}