Issue#67 Extract runOnUIAwaitOnCurrent into separate module
This commit is contained in:
parent
4932b4b2e0
commit
689aee9702
12 changed files with 74 additions and 6 deletions
|
|
@ -110,6 +110,7 @@ dependencies {
|
|||
androidTestImplementation testFixtures(project(':core'))
|
||||
implementation project(':test-util-shared-robolectric')
|
||||
androidTestImplementation project(':test-util-shared-android')
|
||||
|
||||
implementation project(':test-util-android')
|
||||
androidTestImplementation project(':test-util-android')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
package org.fnives.test.showcase.testutils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
fun runOnUIAwaitOnCurrent(action: () -> Unit) {
|
||||
if (Looper.myLooper() === Looper.getMainLooper()) {
|
||||
action()
|
||||
} else {
|
||||
val deferred = CompletableDeferred<Unit>()
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
action()
|
||||
deferred.complete(Unit)
|
||||
}
|
||||
runBlocking { deferred.await() }
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package org.fnives.test.showcase.testutils.idling
|
|||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import kotlinx.coroutines.test.StandardTestDispatcher
|
|||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|||
import androidx.swiperefreshlayout.widget.listener
|
||||
import androidx.test.espresso.UiController
|
||||
import androidx.test.espresso.ViewAction
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.CoreMatchers.isA
|
||||
import org.hamcrest.Description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue